Sunday, 8 September 2013

How to get YUV data from a Bitmap?

How to get YUV data from a Bitmap?

I am looking for a way to get YUV data of a Bitmap and store it in a byte
array byte[] mYUVData;
Does anyone have any ideas on how I can do that?
The code I wrote does not seem to work as it should:
byte[] mYUVData;
int[] mRGBData; //assume that this contains information
int bytes = mImageWidth * mImageHeight *4;
ByteBuffer buffer = ByteBuffer.allocate(bytes); //Create a new buffer
mBitmap.copyPixelsToBuffer(buffer);
byte[] array = buffer.array();
mYUVData = array;
System.arraycopy(array, 0, mDrawOnTop.mYUVData, 0, array.length);

No comments:

Post a Comment