我正在开发使用自定义相机的Android应用程序,我的相机方向是肖像,但图像保存在风景和图像划痕,并接受三星所有设备正常工作,请提前感谢任何解决方案。 这是我设置的相机定位方法。
public void updateCameraRotation(){
try {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, info);
int rotation = this.getWindowManager().getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0: degrees = 0; break; //Natural orientation
case Surface.ROTATION_90: degrees = 90; break; //Landscape left
case Surface.ROTATION_180: degrees = 180; break;//Upside down
case Surface.ROTATION_270: degrees = 270; break;//Landscape right
}
int rotate = (info.orientation - degrees + 360) % 360;
Camera.Parameters params = myCamera.getParameters();
params.setRotation(rotate);
myCamera.setParameters(params);
} catch (Exception e) {
e.printStackTrace();
}
}
答案 0 :(得分:0)
我用这段代码解决了这个问题:
deviceName=Util.getInstance().getDeviceName();
if(deviceName.contains("Samsung")||deviceName.equalsIgnoreCase("Samsung")){
if (bitmap.getWidth() > bitmap.getHeight()) {
Matrix matrix = new Matrix();
matrix.postRotate(90);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}
}