chanobol icon indicating copy to clipboard operation
chanobol copied to clipboard

Check Available Memory In ImageActivity

Open eugenkiss opened this issue 10 years ago • 2 comments

and use a scaled down version of the image if necessary to prevent OutOfMemoryError. See http://stackoverflow.com/a/4544944/283607

But ideally, deep zoom should take care of all this.

But how to calculate exactly how much memory bitmap will need etc. (it's probably easy formula but need to find it first).

eugenkiss avatar Feb 16 '15 19:02 eugenkiss

Doesnt picasso just handle this automatically?

mitchross avatar Feb 23 '15 19:02 mitchross

The problem is more subtle. I could simply resize every image such that it is not larger than the screen size. But what about high-res pictures that contain a lot of text as is very common on 4Chan? If I take the approach of always resizing than the text will be unreadable or at least very blurry when zooming in. If I never resize, high-res images might lead to an Out of Memory error. Ion has this deep zoom functionality where it automatically tiles high-res images such that they do not (or rather should not but still often do) lead to an out of memory error. But then the deep zoom functionality is fragile and reduces image quality for some reason. So the best compromise heuristic should be "do not resize unless the memory is low and then only reduce size as much as is needed to prevent an Out of Memory error". This is what this issue is about.

Btw, I use Ion and not Picasso anymore. Picasso simply crashes with "bitmap too large" if either side is larger than 4096 so it is worse than Ion in this respect.

eugenkiss avatar Feb 23 '15 19:02 eugenkiss