user562237
user562237

Reputation: 785

BItmap:out of memory error. how to get the original image size after compressing it in android

I have drawn an image manually on bitmap. But it has shown out of memory error. I, then reduced the size of the image which shows me the compressed form of the image. I need the original size of the image to be displayed which is then showing out of memory error. Kindly, help me out in resolving the issue. I am enclosing the part of the code too.

ImageView iv1 = new ImageView(mcontext);

BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;

BitmapFactory.decodeFile(pageViewManager.getPenToolPath() + pageViewManager.getCurrentPageIndex() + ".jpg");

bmp = BitmapFactory.decodeFile(pageViewManager.getPenToolPath() + pageViewManager.getCurrentPageIndex() + ".jpg", options);

iv1.setImageBitmap(bmp);

Upvotes: 2

Views: 633

Answers (1)

Alexis Dufrenoy
Alexis Dufrenoy

Reputation: 11946

The memory space used by an uncompressed picture is easy to calculate: it's the number of pixels*the color depth, the number of pixels itself is height*width. For example, for an image of 1000*800 in 24 bits (3 bytes), the memory size will be:

1000*800*3=2400000 bytes or 2,4 Mb

Upvotes: 0

Related Questions