android 相机旋转了90度,导致图片旋转

ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compressToJpeg(new Rect(0, 0, size.width, size.height), 80, stream);
Bitmap bmp = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size());


Matrix matrix = new Matrix();
matrix.setRotate(90);
bmp = Bitmap.createBitmap(bmp, 0, 0, size.width, size.height, matrix, false);
//图片旋转后
Rect imageRect = finder_view.getScanAreaRect(size.height, size.width);
bmp = Bitmap.createBitmap(bmp, imageRect.left, imageRect.top, imageRect.width(), imageRect.height());
//此时的bmp已经只包含了框内的画面
stream.reset();
display.setImageBitmap(bmp);

你可能感兴趣的:(android 相机旋转了90度,导致图片旋转)