2012-01-22 25 views

答えて

2

ドキュメントを参照しましたか?

Canvas API

あなたは使用することができます。そのような

public Canvas (Bitmap bitmap) 

    Since: API Level 1 
    Construct a canvas with the specified bitmap to draw into. The bitmap must be mutable. 
    The initial target density of the canvas is the same as the given bitmap's density. 
    Parameters 

    bitmap Specifies a mutable bitmap for the canvas to draw into. 
5

何かが動作するはずです:

http://developer.android.com/reference/android/view/View.html#getDrawingCache(boolean)

public void toJPEGFile(){ 
    File folder = new File(Environment.getExternalStorageDirectory()+"/folder/"); 
    if(!folder.exists()) folder.mkdirs(); 

    try { 
     this.setDrawingCacheEnabled(true); 
     FileOutputStream fos = new FileOutputStream(new File(Environment.getExternalStorageDirectory()+"/folder/file")); 
     Bitmap bitmap = this.getDrawingCache(); 
     bitmap.compress(CompressFormat.JPEG, 100, fos); 
     fos.flush(); 
     fos.close(); 
    } catch (FileNotFoundException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 



} 
+0

正確なコードを投稿する人が学ぶ助けにはなりません。 – JoxTraex

+0

'bitmap.recycle()'を使用してビットマップを終了したらメモリを解放する必要があります – jcw

+0

folderAppointmentとは何ですか?私は宣言されたようなものを持っていないので、私はnullpointerを得ます/ –

関連する問題