Is there any way to compress image without fully loading it into memory?
As I understand BitmapFactory.decodeStream
and similar methods load everything in memory and only after loading entire picture it can be compressed via Bitmap.compress
My task is to send picture from android to server
You could use a BitmapRegionDecoder to read only a part of the original image, then compress and upload each part separately.
BitmapRegionDecoder can be used to decode a rectangle region from an image. BitmapRegionDecoder is particularly useful when an original image is large and you only need parts of the image.
To create a BitmapRegionDecoder, call newInstance(...). Given a BitmapRegionDecoder, users can call decodeRegion() repeatedly to get a decoded Bitmap of the specified region.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With