本文整理匯總了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);
}