本文整理汇总了Java中android.hardware.Camera.Parameters.set方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.set方法的具体用法?Java Parameters.set怎么用?Java Parameters.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.Camera.Parameters
的用法示例。
在下文中一共展示了Parameters.set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCameraParams
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
* 设置摄像头为竖屏
*/
private void setCameraParams() {
if (mCamera != null) {
Parameters params = mCamera.getParameters();
params.set("orientation", "portrait");
mCamera.setParameters(params);
}
}
示例2: configureCameraParameters
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static void configureCameraParameters(Context context, int rotation) {
Parameters cameraParams = mCamera.getParameters();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) { // for 2.1 and
// before
if (isPortrait(context)) {
cameraParams.set(CAMERA_PARAM_ORIENTATION,
CAMERA_PARAM_PORTRAIT);
mCameraAngle = 90;
} else {
cameraParams.set(CAMERA_PARAM_ORIENTATION,
CAMERA_PARAM_LANDSCAPE);
mCameraAngle = 0;
}
} else { // for 2.2 and later
switch (rotation) {
case Surface.ROTATION_0: // This is display orientation
mCameraAngle = 90; // This is camera orientation
break;
case Surface.ROTATION_90:
mCameraAngle = 0;
break;
case Surface.ROTATION_180:
mCameraAngle = 270;
break;
case Surface.ROTATION_270:
mCameraAngle = 180;
// image
break;
default:
mCameraAngle = 90;
break;
}
Log.d(LogUtil.TAG, "angle: " + mCameraAngle);
mCamera.setDisplayOrientation(mCameraAngle);
}
cameraParams.setRecordingHint(true);
mCamera.setParameters(cameraParams);
}
开发者ID:chauhansaurabhb,项目名称:EndUserInteractioion_RequestResponse_Command,代码行数:40,代码来源:CameraUtil.java
示例3: setupCaptureParams
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private void setupCaptureParams(Parameters parameters) {
List<Size> supportedSizes = parameters.getSupportedPreviewSizes();
if (!findBestPreviewSize(supportedSizes, true, true)) {
Log.w(TAG, "No 4:3 ratio preview size supported.");
if (!findBestPreviewSize(supportedSizes, false, true)) {
Log.w(TAG, "Can't find a supported preview size smaller than 960x720.");
findBestPreviewSize(supportedSizes, false, false);
}
}
Log.d(TAG, "camera preview h = "
+ mCameraPreviewHeight + " , w = " + mCameraPreviewWidth);
parameters.setPreviewSize(mCameraPreviewWidth, mCameraPreviewHeight);
List<int[]> frameRates = parameters.getSupportedPreviewFpsRange();
int last = frameRates.size() - 1;
int minFps = (frameRates.get(last))[Parameters.PREVIEW_FPS_MIN_INDEX];
int maxFps = (frameRates.get(last))[Parameters.PREVIEW_FPS_MAX_INDEX];
parameters.setPreviewFpsRange(minFps, maxFps);
Log.d(TAG, "preview fps: " + minFps + ", " + maxFps);
List<String> supportedFocusModes = parameters.getSupportedFocusModes();
if (supportedFocusModes.indexOf(mTargetFocusMode) >= 0) {
parameters.setFocusMode(mTargetFocusMode);
} else {
// Use the default focus mode and log a message
Log.w(TAG, "Cannot set the focus mode to " + mTargetFocusMode +
" becuase the mode is not supported.");
}
parameters.set(CameraUtil.RECORDING_HINT, CameraUtil.FALSE);
mHorizontalViewAngle = parameters.getHorizontalViewAngle();
mVerticalViewAngle = parameters.getVerticalViewAngle();
}
示例4: surfaceCreated
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, acquire the camera and tell it where
// to draw.
try {
camera = Camera.open();
Parameters parameters = camera.getParameters();
Display display = ((WindowManager) mcontext.getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int dwidth = display.getWidth();
int dheight = display.getHeight()-40;
if(display.getRotation() == Surface.ROTATION_0)
{
mPreviewSize = getOptimalPreviewSize(parameters.getSupportedPreviewSizes(),dwidth, dheight);
} else if(display.getRotation() == Surface.ROTATION_90)
{
mPreviewSize = getOptimalPreviewSize(parameters.getSupportedPreviewSizes(),dheight,dwidth);
} else if(display.getRotation() == Surface.ROTATION_180)
{
mPreviewSize = getOptimalPreviewSize(parameters.getSupportedPreviewSizes(),dwidth, dheight);
} else if(display.getRotation() == Surface.ROTATION_270)
{
mPreviewSize = getOptimalPreviewSize(parameters.getSupportedPreviewSizes(),dheight,dwidth);
}
parameters.setPictureFormat(PixelFormat.JPEG);
parameters.set("jpeg-quality", 100);
camera.setParameters(parameters);
camera.setPreviewDisplay(holder);
} catch (Exception e) {
closeCamera();
}
}
示例5: openCamera
import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
* 初始化摄像头
*/
private void openCamera(SurfaceView surfaceView, int width, int height) {
if (!isPreview) {
camera = Camera.open();
}
if (camera != null && !isPreview) {
try {
Parameters parameters = camera.getParameters();
// 设置闪光灯为自动状态
parameters.setFlashMode(Parameters.FLASH_MODE_AUTO);
camera.setParameters(parameters);
// 设置预览照片的大小
parameters.setPreviewSize(width, height);
// 设置每秒显示4帧
parameters.setPreviewFrameRate(4);
// 设置图片格式
parameters.setPictureFormat(ImageFormat.JPEG);
// 设置JPG照片的质量
parameters.set("jpeg-quality", 100);
// 设置照片大小
parameters.setPictureSize(width, height);
// 通过SurfaceView显示取景画面
camera.setPreviewDisplay(surfaceView.getHolder());
// 如果是竖屏
if (surfaceView.getContext().getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
camera.setDisplayOrientation(90);
} else {
camera.setDisplayOrientation(0);
}
// 开始预览
camera.startPreview();
// 自动对焦
camera.autoFocus(null);
isPreview = true;
} catch (Exception e) {
e.printStackTrace();
}
}
}