Reputation: 110510
I need to create a yuv image in NV21 format for testing purpose.
From this posting, Displaying YUV Image in Android, I see it does:
YuvImage yuvImage = new YuvImage(data, PictureFormat.NV21, width, height, null);
How can I get 'data'? to passing in yuvImage? Can I load it from a resource file, what should be the resource file format?
Upvotes: 1
Views: 1376
Reputation: 141
You can get your desired Parameter (data) by Converting the resource Drawable to Bytearray then use it to get the YUV image :
Resources res = getResources();
Drawable drawable = res.getDrawable(R.drawable.my_pic);
Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] bitMapData = stream.toByteArray();
Upvotes: 1