我正在拍照,将其保存为文件并显示它,因为你可以看到主要的imageView
,然后我使用:
val filteredImage = bitmap.copy(Bitmap.Config.ARGB_8888,true)
我使用这个filteredImage
变量在图像上应用滤镜,因为它现在是可变的。
问题是:正如你在下面的小图片中看到的方向变化,我搜索了很多,但我找不到任何解决方案。
当我用复制的替换主ImageView
的位图时,我得到了这个:
原始图像可能包含Exif方向数据,这些数据在bitmap.copy()上丢失。
@Override
public void onPictureTaken(CameraView cameraView, byte[] data) {
// Find out if the picture needs rotating by looking at its Exif data
ExifInterface exifInterface = new ExifInterface(new ByteArrayInputStream(data));
int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
int rotationDegrees = 0;
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
rotationDegrees = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotationDegrees = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
rotationDegrees = 270;
break;
}
// Create and rotate the bitmap by rotationDegrees
}