I'm trying to create a bitmap from a view with this code :
public Bitmap getmyBitmap(View v)
{
Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
v.draw(c);
return b;
}
But I have an Out Of Memory problems. I can fix it by adding this option to the Manifest file android:largeHeap="true" which is not recommended !!
I'm thinking about the recycle of the view ,could be a solution?
this is the printStack:
11-25 15:31:46.556 2115-2115/com.myproject.android E/dalvikvm-heap﹕ Out of memory on a 4096016-byte allocation. 11-25 15:31:46.616
2115-2115/com.myproject.android E/dalvikvm-heap﹕ Out of memory on a 4096016-byte allocation. 11-25 15:31:46.666
2115-2115/com.myproject.android E/dalvikvm-heap﹕ Out of memory on a 4096016-byte allocation. 11-25 15:31:54.016
2115-2115/com.myproject.android E/dalvikvm-heap﹕ Out of memory on a 1879696-byte allocation. 11-25 15:31:54.016
2115-2115/com.myproject.android E/AndroidRuntime﹕ FATAL EXCEPTION: main