I have a routine that manipulates a Bitmap to convert form RGB to Grayscale.
It works fine usually, but when I try to use it on a Bitmap which is 1088kb in size it gives me this Error:
java.lang.OutOfMemoryError
I am using the Emulator. 1088kb is not a very big picture, how can it be exhausting the memory?
To be precise the application that does invoke the problematic code includes another Activity on the back-stack that has a ListView of pictures thumbnails.
This is the method:
public Bitmap toGrayscale(Bitmap bmpOriginal)
{
int width, height;
height = bmpOriginal.getHeight();
width = bmpOriginal.getWidth();
Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
Canvas c = new Canvas(bmpGrayscale);
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
c.drawBitmap(bmpOriginal, 0, 0, paint);
return bmpGrayscale;
}