當前位置: 首頁>>代碼示例>>Java>>正文


Java Parameters.set方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:yun2win,項目名稱:yun2win-sdk-android,代碼行數:11,代碼來源:MovieRecorderView.java

示例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();
}
 
開發者ID:asm-products,項目名稱:nexus-camera,代碼行數:35,代碼來源:WideAnglePanoramaModule.java

示例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();
    }
}
 
開發者ID:IanEH,項目名稱:YASFA1,代碼行數:37,代碼來源:CameraLayout.java

示例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();
		}
	}
}
 
開發者ID:leleliu008,項目名稱:Newton_for_Android_AS,代碼行數:44,代碼來源:CameraManager.java


注:本文中的android.hardware.Camera.Parameters.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。