Skip to content Skip to sidebar Skip to footer

Bitmapfactory Null Issue In Android

I am trying to create bitmap class using bitmapfactory. I get camera preview image in YUV format and decode manually to grayscale image. When i try to create bitmap object via Bitm

Solution 1:

BitmapFactory is used to create an image from a image file that was encoded using JPEG or PNG. If you just toss raw data at it, the function has no idea what encoding you're using. RGB? YUV? 24-bit? 32-bit?

AFAIK there's no native way to create an image from YUV data, you'd at least have to convert it to RGB first. Here is an answer that demonstrates it: Getting frames from Video Image in Android.

Of course, you can use the NDK to create a native conversion function, which will be a lot faster. Or you could scan the documentation for a YUV converter, but the only thing I found in a quick scan is YuvImage, which will only allow you to convert this to a JPEG stream.

Post a Comment for "Bitmapfactory Null Issue In Android"