2

Given a JPEG Encoded byte array taken from a camera, I need to decode it and display its image (bitmap) in my application. From searching around, I've found that there are two primary ways to go about this: use NDK Jpeg Decoding library or use BitmapFactory.decodeByteArray. This is for an experimental embedded device being developed that runs on Android with a built-in camera.

I would greatly prefer to develop the application in SDK not NDK if possible at all, but many people seemed to handle this problem by going straight to NDK, which bugged me a bit.

  • Is there some sort of inherent limitation in BitmapFactory.decodeByteArray that forces you to handle this problem by using libjpeg in NDK (Perhaps speed? Incompatibility?)

Performance isn't a big consideration unless if it takes say more than 45 seconds to decode the image and display it.

This is an important decision I need to make upfront, so I'd appreciate any thoughtful answers. Thank you so much.

1

1 Answer 1

2

Here is a really good example / explanation how you can decode images on device efficiently without using NDK : Displaying Bitmap Efficiently. You have an option to decode bitmap from stream or file so it depends on your needs. But in most of my applications I am using the same method and it's working great. So I suggest you to take a look at the SDK example.

Hope it will helps you.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the prompt response. I will always be receiving the image data via JPEG encoded bytes, so as long as there is no known issue with it, I will go ahead and use this method. Although it still seems very strange to me that people opt to go for the NDK method to tackle this problem...
If you need only to decode stream and show it in your application, there is no need of using NDK, because you can achieve this using Java and Android SDK in a really good way. In my apps I have to decrypt first the image and than decode the decrypted stream and I have never had an issue with that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.