Creating a bitmap from a byte array that is unpacked from a JPEG file via libjpeg

I used libjpeg (C library) to decompress a JPEG file. Now I have an unsigned char array. How to create a bitmap from this array in JNI?

+4
source share
1 answer

Yes, it is possible , but there must be a strong justification for this path. For best performance, use

Bitmap bm = BitmapFactory.decodeByteArray(jpegArray, 0, jpegArray.length); 

Even if you need to decode the same jpeg twice - once in C, once in Java, it will save you both from programming efforts and from runtime.

Please note that Android has a built-in libjpeg (see /system/lib on your device), and decodeByteArray() uses it and is highly optimized.

+5
source

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


All Articles