80,472
社区成员




if (data.length != 0)
{
previewSize = camera.getParameters().getPreviewSize();//后面用于获取长、宽
yuv = new YuvImage(data, ImageFormat.NV21,previewSize.width, previewSize.height, null);
LogUtil.i("previewSize", previewSize.width+" "+previewSize.height);
// Decode image from the retrieved buffer to JPEG
yuv = new YuvImage(data, ImageFormat.NV21,previewSize.width, previewSize.height, null);
yuv.compressToJpeg(new Rect(0, 0,previewSize.width, previewSize.height),100, baos);
rawImage = baos.toByteArray();
// This is the same image as the preview but in JPEG
// and not rotated
bitmap = BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length);
// We rotate the same Bitmap
// 旋转
matrix.postRotate(90);
bitmap = Bitmap.createBitmap(bitmap, 0, 0,previewSize.width, previewSize.height,matrix, false);
// We dump the rotated Bitmap to the stream
bitmap.compress(CompressFormat.JPEG,100, rotatedStream);
rawImage = rotatedStream.toByteArray();
// rawImage就是最后要用的视频流了
代码如上。我运行后发现,rawImage的大小比原本data[]大,还有增加的趋势。应该是哪里写错了……
这里没声明的变量都是全局的。rawImage 要清空么?
能否帮忙看下,谢谢~