I'm sorry that I'm not good at English.
I want to make a real-time image manipulation app.(Binarization, color inverse...etc.)
It needs speed, so I want to manipulate it as byte[]
, without converting to Image
or Bitmap
.
The format of image that I got from camera was YUV(NV21)
, but because I don't know about this format, I convert it to JPEG.
but it also doesn't work as I expected.(I thought it would be one byte per one pixel or three byte per one pixel.)
So,
- How can I do such
manipulation(binarization, color inverse)
as JPEG byte array? - or How can I convert NV21 format byte array to RGB byte array?
and I used the method to convert NV21
to JPEG
.
YuvImage yuvimage = new YuvImage(bytes, ImageFormat.NV21, width, height, null);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
yuvimage.compressToJpeg(new Rect(0, 0, width, height), 100, outputStream);
and I got yuv
image byte array from onPreviewFrame(Camra.PreviewCallback)
.