3

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.

Jag
  • 517
  • 2
  • 5
  • 17

1 Answers1

2

You are probably using opencv or another library which also has Rect defined. Use android.graphics.Rect instead of Rect.

Regards

Damjan Dakic
  • 265
  • 1
  • 19