Android High Resolution Image Processing

From experiments and from reading other posts like this one, it seems that it is difficult to process high-resolution images on Android, because there is a limit on the amount of memory a virtual machine will allow to allocate.

Downloading an 8 megapixel camera takes about 20 MB of memory.

I understand that a simple solution is to reduce the image size at boot (BitmapFactory offers this option), but I would still like to process the image in full resolution: the camera shoots 8MP, why should I use only 4MP and reduce the quality.

Does anyone know of good workarounds for this?

+6
source share
3 answers

2 things:

  • Checkout the gallery at Honeycomb. It does tile based rendering. You can enlarge the image and you see that the current part is higher than the other parts. If you swap around, you see its rendering.

  • When using native code (NDK), there is no resource limit. So you can try to download all the native data and somehow get some of it using JNI, but I doubt it is better than a cell phone gallery.

+1
source

In an environment with limited resources, I believe that your only solution is to divide and win: for example. caching / tile (as in: tile)

Instead of loading and processing the image, you immediately load / save managed image chunks from the raw data file to perform your processing. This is not trivial and can become really complicated depending on the type of processing you want to do, but this is the only way if you do not want to include in the image quality.

+2
source

Indeed, it is difficult. But in case the image is in some continuous raster format, you can play it (see java.nio.ByteBuffer) - this way you get a byte buffer without highlighting it.

+2
source

Source: https://habr.com/ru/post/904612/


All Articles