Bitmap behaves like that because it allocates memory on the native heap for 
storing its bitmap data, meaning: it cannot use your Java int array and 
must make a copy instead. For getting around that problem you should 
reconsider what you are doing. Try to break your big (memory) problem into 
several smaller sub-problems. I don't know where your pixel int array 
originally comes from, but at some point you must have it either loaded 
from somewhere or constructed.

You could instead operate directly on an already allocated Bitmap object 
and modify its pixel data instead of having you int array as a step in 
between. So if you are loading your int array from a file for example, just 
apply that data directly to the Bitmap. If that array is constructed by 
your code, then change the algorithm to store its calculations directly in 
the Bitmap object.

But maybe you do not need a Bitmap object at all. If you want to draw on a 
Canvas object, then you could make use of the following method instead, 
which takes a Java int array as argument:

canvas.drawBitmap (int[] colors, int offset, int stride, float x, float y, 
int width, int height, boolean hasAlpha, Paint 
paint)<http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap%28int[],%20int,%20int,%20float,%20float,%20int,%20int,%20boolean,%20android.graphics.Paint%29>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to