当前位置: 首页>>代码示例>>Java>>正文


Java Parameters.setPreviewFormat方法代码示例

本文整理汇总了Java中android.hardware.Camera.Parameters.setPreviewFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.setPreviewFormat方法的具体用法?Java Parameters.setPreviewFormat怎么用?Java Parameters.setPreviewFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.Camera.Parameters的用法示例。


在下文中一共展示了Parameters.setPreviewFormat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startPreview

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
private void startPreview() {
	if (myCamera != null) {
		myCamera.stopPreview();
	} else {
		myCamera = getCameraInstance();
	}
	Parameters parameters = myCamera.getParameters();
	if (canOpenFlash) {
		if (camRecordEnabled) {
			parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
		}

	} else {
		parameters.setFlashMode(Parameters.FLASH_MODE_OFF);
	}

	parameters.setPreviewFormat(ImageFormat.NV21);
	myCamera.setParameters(parameters);
	myCamera.setPreviewCallbackWithBuffer(new MyPreview());
	myCamera.addCallbackBuffer(mCallbackBuf);
	myCamera.startPreview();
}
 
开发者ID:thmedialab,项目名称:DataDrivenBP,代码行数:23,代码来源:BPActivity.java

示例2: updateCamera

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
protected synchronized void updateCamera() throws RuntimeException {
	if (mPreviewStarted) {
		mPreviewStarted = false;
		mCamera.stopPreview();
	}

	Parameters parameters = mCamera.getParameters();
	mQuality = VideoQuality.determineClosestSupportedResolution(parameters, mQuality);
	int[] max = VideoQuality.determineMaximumSupportedFramerate(parameters);
	parameters.setPreviewFormat(mCameraImageFormat);
	parameters.setPreviewSize(mQuality.resX, mQuality.resY);
	parameters.setPreviewFpsRange(max[0], max[1]);

	try {
		mCamera.setParameters(parameters);
		mCamera.setDisplayOrientation(mOrientation);
		mCamera.startPreview();
		mPreviewStarted = true;
	} catch (RuntimeException e) {
		destroyCamera();
		throw e;
	}
}
 
开发者ID:ghazi94,项目名称:Android_CCTV,代码行数:24,代码来源:VideoStream.java

示例3: setCamera

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void setCamera(Camera camera) {
     mCamera = camera;
     if (mCamera != null) {
      Parameters parameters = mCamera.getParameters();
         mSupportedPreviewSizes = parameters.getSupportedPreviewSizes();
List<Integer> formatsList = parameters.getSupportedPreviewFormats();	//get supported preview formats
if(formatsList.contains(ImageFormat.NV21)) {	// formatsList is always not null.
	parameters.setPreviewFormat(ImageFormat.NV21);		//set preview format is NV21,default is NV21 (yuv420sp)
}

  	//  Set Focus mode depending on what is supported. MODE_AUTO is 
  	//  preferred mode.
// need not to test supported mode coz it has been tested in main activity.
  	if (msnFocusMode == 2)	{
  		parameters.setFocusMode( Camera.Parameters.FOCUS_MODE_INFINITY );
  	} else if (msnFocusMode == 1)	{
  		parameters.setFocusMode( Camera.Parameters.FOCUS_MODE_FIXED );
  	} else	{
  		// set to auto focus by default
  		parameters.setFocusMode( Camera.Parameters.FOCUS_MODE_AUTO);
  	}

  	/*if ((parameters.getMaxExposureCompensation() != 0 || parameters.getMinExposureCompensation() != 0)
      		&& ActivitySettings.msnPhotoTakenFrom == 1)	{	// screen mode.
      	parameters.setExposureCompensation(parameters.getMaxExposureCompensation());
      } */
  	parameters.setExposureCompensation(0);	// exposure is not adjusted. Seems that screen mode does not bring much benefit.
      

List<String> scenesList = parameters.getSupportedSceneModes();
if (scenesList != null && scenesList.contains(Camera.Parameters.SCENE_MODE_STEADYPHOTO)) {
	parameters.setSceneMode(Camera.Parameters.SCENE_MODE_STEADYPHOTO);	// this may crash in some devices.
}
boolean bSuccessful = setCameraParams(mCamera, parameters);

      requestLayout();
     } 
 }
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:39,代码来源:CameraPreview.java

示例4: updateCamera

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
protected synchronized void updateCamera() throws RuntimeException {
	
	// The camera is already correctly configured
	if (mUpdated) return;
	
	if (mPreviewStarted) {
		mPreviewStarted = false;
		mCamera.stopPreview();
	}

	Parameters parameters = mCamera.getParameters();
	mQuality = VideoQuality.determineClosestSupportedResolution(parameters, mQuality);
	int[] max = VideoQuality.determineMaximumSupportedFramerate(parameters);
	
	double ratio = (double)mQuality.resX/(double)mQuality.resY;
	mSurfaceView.requestAspectRatio(ratio);
	
	parameters.setPreviewFormat(mCameraImageFormat);
	parameters.setPreviewSize(mQuality.resX, mQuality.resY);
	parameters.setPreviewFpsRange(max[0], max[1]);

	try {
		mCamera.setParameters(parameters);
		mCamera.setDisplayOrientation(mOrientation);
		mCamera.startPreview();
		mPreviewStarted = true;
		mUpdated = true;
	} catch (RuntimeException e) {
		destroyCamera();
		throw e;
	}
}
 
开发者ID:galme,项目名称:ROLF-EV3,代码行数:33,代码来源:VideoStream.java

示例5: configureForPreview

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public void configureForPreview(int viewWidth, int viewHeight) {
    final Parameters params = mNativeCamera.getNativeCameraParameters();
    final CameraSize previewSize = getOptimalSize(params.getSupportedPreviewSizes(), viewWidth, viewHeight);

    params.setPreviewSize(previewSize.getWidth(), previewSize.getHeight());
    params.setPreviewFormat(ImageFormat.NV21);
    mNativeCamera.updateNativeCameraParameters(params);
    mNativeCamera.setDisplayOrientation(getRotationCorrection());
    CLog.d(CLog.CAMERA, "Preview size: " + previewSize.getWidth() + "x" + previewSize.getHeight());
}
 
开发者ID:linglongxin24,项目名称:VideoCamera,代码行数:11,代码来源:CameraWrapper.java

示例6: updateCamera

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
protected synchronized void updateCamera() throws RuntimeException {
	
	// The camera is already correctly configured
	if (mUpdated) return;
	
	if (mPreviewStarted) {
		mPreviewStarted = false;
		mCamera.stopPreview();
	}

	Parameters parameters = mCamera.getParameters();
	mQuality = VideoQuality.determineClosestSupportedResolution(parameters, mQuality);
	int[] max = VideoQuality.determineMaximumSupportedFramerate(parameters);
	
	double ratio = (double)mQuality.resX/(double)mQuality.resY;
	mSurfaceView.requestAspectRatio(ratio);
	
	parameters.setPreviewFormat(mCameraImageFormat);
	parameters.setPreviewSize(mQuality.resX, mQuality.resY);
	//int cur_fr = mQuality.framerate * 1000;
	//if(max[0] < cur_fr && cur_fr < max[1])
	//	max[0] = max[1] = cur_fr;
	parameters.setPreviewFpsRange(max[0], max[1]);
       parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);   //focus

	try {
		mCamera.setParameters(parameters);
		mCamera.setDisplayOrientation(mOrientation);
		mCamera.startPreview();
		//mCamera.cancelAutoFocus();
		mPreviewStarted = true;
		mUpdated = true;
	} catch (RuntimeException e) {
		destroyCamera();
		throw e;
	}
}
 
开发者ID:xunboo,项目名称:JJCamera,代码行数:38,代码来源:VideoStream.java


注:本文中的android.hardware.Camera.Parameters.setPreviewFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。