【发布时间】:2017-06-01 10:47:21
【问题描述】:
当我使用自定义相机拍摄照片时,我被困在无法更改照片方向的地方。我想手动处理方向。当调用 Camera.PictureCallback 时,我不知道如何在 onConfigurationchanged 中旋转图片。未拍摄照片时,我已成功更改方向。我没有在任何图像视图中设置图像,而是在表面视图中显示它。这是我为它设置框架布局和表面的代码:
Framelayout camera_view = (FrameLayout) findViewById(R.id.camera_view);
CameraSurfaceCreater mCameraView = new CameraSurfaceCreater(this, mCamera, CameraSetter.this);//create a SurfaceView to show camera data
camera_view.addView(mCameraView);//add the SurfaceView to the layout
拍照时:
Camera.PictureCallback mPicture = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
pictaken = true;
}
};
并且在 onConfiguration 中改变了:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
if(!isPictureTaken){
setCameraDisplayOrientation(CameraSetter.this, 0, mCamera);
}else {
//dont know how to rotate a photo when picture is taken
}
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
if(!isPictureTaken){
setCameraDisplayOrientation(CameraSetter.this, 0, mCamera);
}
}
}
感谢任何帮助。在拍摄照片并且用户更改方向后,我是否必须旋转框架布局或我必须做的事情。
【问题讨论】:
标签: android android-camera android-orientation android-framelayout