在android中固定摄像头方向

在android中固定摄像头方向,android,camera,Android,Camera,我有一个可以拍照的应用程序。我的问题是存储在设备上的图像的方向。我解决预览方向使用了很多方法,但它不影响图像保存在设备上。 我用来解决问题的方法: Camera.Parameters parameters = camera.getParameters(); parameters.set("orientation", "portrait"); camera.setParameters(parameters); & & & 在AndroidMainfest.

我有一个可以拍照的应用程序。我的问题是存储在设备上的图像的方向。我解决预览方向使用了很多方法,但它不影响图像保存在设备上。 我用来解决问题的方法:

Camera.Parameters parameters = camera.getParameters();
parameters.set("orientation", "portrait");
camera.setParameters(parameters);
&

&

& 在AndroidMainfest.xml中

android:screenOrientation="portrait"
还有android开发者官方网站上描述的方法,上面说: “如果要使相机图像以与显示器相同的方向显示,可在此地址中使用以下代码”:

所有这些方法都适用于相机预览方向,但不适用于保存的图像。 我也不想用这个:

String path = pictureFile.getPath().toString();
Bitmap bmp = BitmapFactory.decodeFile(path);
Matrix matrix = new Matrix();
matrix.postRotate(90);
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
因为这种方法使用保存的图像,旋转并再次保存,从而降低图像质量。
除了这个方法,还有别的想法吗?谢谢

您可以执行无损旋转,如下所示:。
android:screenOrientation="portrait"
String path = pictureFile.getPath().toString();
Bitmap bmp = BitmapFactory.decodeFile(path);
Matrix matrix = new Matrix();
matrix.postRotate(90);
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);