本文整理汇总了Java中android.hardware.Camera.Parameters.setRotation方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.setRotation方法的具体用法?Java Parameters.setRotation怎么用?Java Parameters.setRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.Camera.Parameters
的用法示例。
在下文中一共展示了Parameters.setRotation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CameraPreview
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public CameraPreview(Context context, Camera camera) {
super(context);
mCamera = camera;
Parameters parameters = mCamera.getParameters();
parameters.setRotation(90);
mCamera.setParameters(parameters);
// mCamera.setParameters())
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
// deprecated setting, but required on Android versions prior to 3.0
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
示例2: updateCameraOrientation
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
* 根据当前朝向修改保存图片的旋转角度
*/
private void updateCameraOrientation(){
if(mCamera!=null){
Parameters parameters = mCamera.getParameters();
//rotation参数为 0、90、180、270。水平方向为0。
int rotation=90+mOrientation==360?0:90+mOrientation;
//前置摄像头需要对垂直方向做变换,否则照片是颠倒的
if(mIsFrontCamera){
if(rotation==90) rotation=270;
else if (rotation==270) rotation=90;
}
parameters.setRotation(rotation);//生成的图片转90°
//预览图片旋转90°
mCamera.setDisplayOrientation(90);//预览转90°
mCamera.setParameters(parameters);
}
}
示例3: setRotationParameter
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static void setRotationParameter(Parameters parameters,
int cameraId, int orientation) {
// See android.hardware.Camera.Parameters.setRotation for
// documentation.
int rotation = 0;
if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
CameraInfo info =
CameraHolder.instance().getCameraInfo()[cameraId];
// CameraInfo info = new CameraInfo();
// Camera.getCameraInfo(cameraId, info);
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation - orientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + orientation) % 360;
}
}
parameters.setRotation(rotation);
}
示例4: updateOrientation
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private void updateOrientation()
{
if(mCamera == null || device_orientation == OrientationEventListener.ORIENTATION_UNKNOWN)
return;
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(getCameraId(),info);
int rotation = 0;
if(info.facing == CameraInfo.CAMERA_FACING_FRONT)
{
rotation = (info.orientation - device_orientation +360) % 360;
}
else
{
rotation = (info.orientation + device_orientation) % 360;
}
Parameters params = mCamera.getParameters();
params.setRotation(rotation);
mCamera.setParameters(params);
}
示例5: setDefaultParameters
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private static void setDefaultParameters(){
Parameters parameters = camera.getParameters();
if (parameters.getSupportedFocusModes().contains(
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
Size previewSize = CameraUtils.getLargePreviewSize(camera);
parameters.setPreviewSize(previewSize.width, previewSize.height);
Size pictureSize = CameraUtils.getLargePictureSize(camera);
parameters.setPictureSize(pictureSize.width, pictureSize.height);
parameters.setRotation(90);
camera.setParameters(parameters);
}