我创建了一个相机应用程序:
mCamera =Camera.open()
mCamera.setDisplayOrientation(90);
我捕捉图像和视频确定。但结果不是旋转90。 摄像机的运行结果如何与相机视图相同? 或者设置结果输出相同的setDisplayOrientation?
答案 0 :(得分:1)
在捕获后使用Android中的EXIF界面旋转图像
ExifInterface exif;
try {
exif = new ExifInterface(filePath);
int orientation = exif.getAttributeInt(
ExifInterface.TAG_ORIENTATION, 0);
Log.d("EXIF", "Exif: " + orientation);
Matrix matrix = new Matrix();
if (orientation == 6) {
matrix.postRotate(90);
Log.d("EXIF", "Exif: " + orientation);
} else if (orientation == 3) {
matrix.postRotate(180);
Log.d("EXIF", "Exif: " + orientation);
} else if (orientation == 8) {
matrix.postRotate(270);
Log.d("EXIF", "Exif: " + orientation);
}
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(),
bmp.getHeight(), matrix, true);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}