Code example for Camera.Parameters

Methods: set, setPictureSize, setPreviewSize

0
            if (portrait) {
                cameraParams.set(CAMERA_PARAM_ORIENTATION,
                    CAMERA_PARAM_PORTRAIT);
            } 
            else { 
                cameraParams.set(CAMERA_PARAM_ORIENTATION,
                    CAMERA_PARAM_LANDSCAPE);
            } 
        } 
        else { // for 2.2 and later 
            int angle;
            Display display = mActivity.getWindowManager().getDefaultDisplay();
            switch (display.getRotation()) {
                case Surface.ROTATION_0: // This is display orientation
                    angle = 90; // This is camera orientation
                    break; 
                case Surface.ROTATION_90:
                    angle = 0;
                    break; 
                case Surface.ROTATION_180:
                    angle = 270;
                    break; 
                case Surface.ROTATION_270:
                    angle = 180;
                    break; 
                default: 
                    angle = 90;
                    break; 
            } 
            Log.v(LOG_TAG, "angle: " + angle);
            mCamera.setDisplayOrientation(angle);
        } 
 
        cameraParams.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
        cameraParams.setPictureSize(mPictureSize.width, mPictureSize.height);
        if (DEBUGGING) {
            Log.v(LOG_TAG, "Preview Actual Size - w: " + mPreviewSize.width
                + ", h: " + mPreviewSize.height);
            Log.v(LOG_TAG, "Picture Actual Size - w: " + mPictureSize.width
                + ", h: " + mPictureSize.height);
Stop searching for code, let great code find you!  Add Codota to your java IDE