我正在尝试使用以下代码将收到的onPreviewFrame中的byte[]数据转换为jpeg格式。
ByteArrayOutputStream baos = new ByteArrayOutputStream();
YuvImage yuv = new YuvImage(data, ImageFormat.NV21, previewWidth, previewHeight, null);
yuv.compressToJpeg(new Rect(0, 0, previewWidth, previewHeight), 0, baos);
....
但是我得到了这个错误,说
"YuvImage中的compressToJpeg(Rect、int、OutputStream)方法对于参数(Rect、int、ByteArrayOutputStream)不适用"
我在网上看到了很多使用ByteArrayOutputStream的代码。我不知道为什么会出现这个错误。有什么帮助吗?谢谢。