我试着从相机上拍摄一张照片,下面的代码可以工作,但我注意到两个问题,第一个问题是输出的质量与相机预览相比很差,第二个问题是位图变得旋转
public static Bitmap getSourceBitmap(byte[] data, int width, int height, boolean isFrontCamera) {
YuvImage yuvimage = new YuvImage(data, ImageFormat.NV21, width, height, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
yuvimage.compressToJpeg(new Rect(0, 0, width, height), 100, baos);
byte[] jdata = baos.toByteArray();
BitmapFactory.Options bitmapFatoryOptions = new BitmapFactory.Options();
bitmapFatoryOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bmp = BitmapFactory.decodeByteArray(jdata, 0, jdata.length, bitmapFatoryOptions);
return Bitmap.createBitmap(bmp, 0, 0, mWidth, mHeight, m, true);
}
谢谢您
暂无答案!
目前还没有任何答案,快来回答吧!