I am trying to convert the byte [] data that I am receiving in onPreviewFrame to jpeg using the following code.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
YuvImage yuv = new YuvImage(data, ImageFormat.NV21, previewWidth, previewHeight, null);
yuv.compressToJpeg(new Rect(0, 0, previewWidth, previewHeight), 0, baos);
....
but I am getting this error saying that
"The method compressToJpeg(Rect, int, OutputStream) in the type YuvImage is not applicable for the arguments (Rect, int, ByteArrayOutputStream)"
I have seen a lot of code in the web using the ByteArrayOutputStream. I have no idea why I am getting this error. Any help? Thank you.