简体   繁体   中英

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);

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM