1
votes

I need to get the pixels info from a Jpeg image without instanciating a Bitmap and then pass it to the JNI.

It is impossible with android to get anything else than a jpeg image from camera (except if you need a low resolution in which case you can use thePreviewCallback), so I got the byte[] from the jpegCallback.

Is it possible to get pixels info in an int[] without using Bitmap.getPixels() ?

2
Since you're trying to avoid the memory constraints of Java and pass the image to JNI, why not decode it in native code? In that case, you wouldn't have 2 copies of the image and avoid the wasted time of passing it to JNI. - BitBank

2 Answers

1
votes

If you don't want to construct a Bitmap, your only option is to decode the JPEG buffer yourself; this means either finding another Java JPEG decompression library, or using JNI and a C JPEG library such as libjpeg. Or, you can write one from scratch, which I don't recommend unless you're already pretty conversant with image compression routines, and you have plenty of time for implementation and debugging.

As Scott asked, why is using Bitmap unacceptable? No matter what route you take, you'll have to call something to decompress the image data, and using BitmapFactory.decodeByteArray is a straightforward, known-to-work option.

0
votes

I do not see how this is possible with the standard Android APIs. I'm sure there are 3rd party JPEG libraries you could use (Googling finds may possibilities). Why are you trying to avoid Bitmaps? If it is a memory constraint, you might want to decode small horizontal chunks with BitmapRegionDecoder