Camera setParameters - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Camera setParameters method.

This code example shows how to use the following methods:setParameters
    /** 
     * Helper method for setting the camera parameters 
     */ 
    public void setParameters(Parameters params) {
        try { 
            mCamera.setParameters(params);
        } catch (Exception e) {
            Log.e(TAG, "Error setting camera parameters");
        } 
    } 
 
    /** 
     * Helper method for starting up the camera preview 
     */ 
    public void startCameraPreview(SurfaceHolder surfaceHolder) throws Exception {
        mCamera.setErrorCallback(mCameraErrorCallback);
        mCamera.setPreviewDisplay(surfaceHolder);
        mCamera.startPreview();
        Thread.sleep(WAIT_GENERIC);
    } 
10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters
                            @Override 
                            public void onClick(DialogInterface dialog, int witch) {
                                // 選択されたインデックスを覚えておく 
                                mCurrentFlashModeIndex = witch;
                                // カメラパラメータを取得して 
                                Parameters params = mCamera.getParameters();
                                // フラッシュモードを取得して 
                                String flashMode = mSupportedFlashModes[witch];
                                // カメラパラメータにフラッシュモードをセット 
                                params.setFlashMode(flashMode);
                                // カメラパラメータをカメラにセット 
                                mCamera.setParameters(params);
                                // 勝手に閉じないので閉じる 
                                dialog.dismiss();
                            } 
                        }).show();
    } 
 
    private void showToast(String text) {
        Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, setPreviewDisplay, startPreview
 
} 
 
 
private void startCamera(SurfaceHolder sh, int width, int height) {
    Camera.Parameters p = mCam.getParameters();
    // Camera.Size s = p.getSupportedPreviewSizes().get(0); 
    p.setPreviewSize(width, height);
 
    mCam.setParameters(p);
 
    try { 
        mCam.setPreviewDisplay(sh);
    } catch (Exception e) {
    } 
 
    mCam.startPreview();
} 
 
private void stopCamera() { 

10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, setPreviewDisplay
      if (theCamera == null) {
        throw new IOException();
      } 
      camera = theCamera;
    } 
    theCamera.setPreviewDisplay(holder);
 
    if (!initialized) {
      initialized = true;
      configManager.initFromCameraParameters(theCamera);
      if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
        setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
        requestedFramingRectWidth = 0;
        requestedFramingRectHeight = 0;
      } 
    } 
 
    Camera.Parameters parameters = theCamera.getParameters();
    String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
    try { 

10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, setPreviewDisplay, startPreview
		if(!isView){//ÊÇ·ñÒѾ­ÏÔʾ
    		myCamera = Camera.open();
    	} 
		if(myCamera != null && !isView){
            try { 
            	Camera.Parameters myParameters = myCamera.getParameters();
            	myParameters.setPictureFormat(PixelFormat.JPEG);
            	myParameters.setPreviewSize(320, 445);//ÆÁÄ»´óС
            	myCamera.setParameters(myParameters);
    			myCamera.setPreviewDisplay(mySurfaceHolder);
    			myCamera.startPreview();//Á¢¼´ÔËÐÐPreview
    		}  
            catch (IOException e) {//²¶»ñÒì³£
    			e.printStackTrace();//´òÓ¡´íÎóÐÅÏ¢
    		}   
            isView = true;//½«ÊÇ·ñÏÔʾ±ê־λÉèÖóÉtrue
    	} 
	} 
	@Override 
	public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) {}
10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters
      lightOn = false;
      if (mCamera == null) {
    	  Log.d(TAG, "Y U NO HAVE CAMERA!");
        return; 
      } 
      Parameters parameters = mCamera.getParameters();
      if (parameters == null) {
    	  Log.d(TAG, "Y U NO HAVE CAMERA PARAMS!");
        return; 
      } 
      List<String> flashModes = parameters.getSupportedFlashModes();
      String flashMode = parameters.getFlashMode();
      // Check if camera flash exists 
      if (flashModes == null) {
    	  Log.d(TAG, "Y U NO HAVE FLASH!");
        return; 
      } 
      Log.i(TAG, "Flash mode: " + flashMode);
      Log.i(TAG, "Flash modes: " + flashModes);
      if (!Parameters.FLASH_MODE_OFF.equals(flashMode)) {

10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, setPreviewDisplay, startPreview
     
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
 
    	if(camera!=null)
        { 
	    	Camera.Parameters p = camera.getParameters();
	        // Camera.Size s = p.getSupportedPreviewSizes().get(0); 
	        p.setPreviewSize(width, height);
	 
	        camera.setParameters(p);
	 
	        try { 
	        	camera.setPreviewDisplay(holder);
	        } catch (Exception e) {
	        } 
	 
	        camera.startPreview();
        } 
    } 
     

10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters
	 *  
	 * @param state			The requested state 
	 *  
	 */ 
	protected void toggleTorch(boolean state) {
		mParameters = mCamera.getParameters();
 
		// Make sure that torch mode is supported 
		// 
		if ( this.isCapable() ) {
			if (state) {
				mParameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
			} else { 
				mParameters.setFlashMode(Camera.Parameters.FLASH_MODE_ON);
			} 
 
			// Commit the camera parameters 
			// 
			mCamera.setParameters(mParameters);
 

10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters
        return true; 
    } 
 
    private void setFlashMode(Camera camera, String mode) {
        Log.v(TAG, "Setting flash mode: " + mode);
        Camera.Parameters params = camera.getParameters();
        params.setFlashMode(mode);
        camera.setParameters(params);
    } 
 
} 
9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getParameters, setParameters, setPreviewDisplay
	{ 
		// This method is called when the surface changes, e.g. when it's size 
		// is set. 
		// We use the opportunity to initialize the camera preview display 
		// dimensions. 
		Camera.Parameters p = camera.getParameters();
		p.setPreviewSize(width, height);
		camera.setParameters(p);
 
		// We also assign the preview display to this surface... 
		try { 
			camera.setPreviewDisplay(holder);
		} catch (IOException e) {
			e.printStackTrace();
		} 
	} 
 
	public void surfaceDestroyed(SurfaceHolder holder)
	{ 
		// Once the surface gets destroyed, we stop the preview mode and release 
10
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Camera setParameters Questions & Answers:

Other Camera setParameters Examples

101:				params = camera.getParameters();
102:				params.setFlashMode(Parameters.FLASH_MODE_TORCH);
103:				camera.setParameters(params);
104:				camera.startPreview();
105:				isFlashOn = true;
-
123:				params = camera.getParameters();
124:				params.setFlashMode(Parameters.FLASH_MODE_OFF);
125:				camera.setParameters(params);
126:				camera.stopPreview();
127:				isFlashOn = false;

Read More

setParameters Method Overview
Changes the settings for this Camera service.
See Code Examples for other Android Camera Methods: