private void updateCameraParametersPreference() { // Set picture size. String pictureSize = mPreferences.getString(KEY_PICTURE_SIZE, null); if (pictureSize == null) { initialCameraPictureSize(this, mParameters); } else { List<Size> supported = mParameters.getSupportedPictureSizes(); setCameraPictureSize(pictureSize, supported, mParameters); } // Set the preview frame aspect ratio according to the picture size. Size size = mParameters.getPictureSize(); PreviewFrameLayout frameLayout = (PreviewFrameLayout) findViewById(R.id.frame_layout); frameLayout.setAspectRatio((double) size.width / size.height); // Set a preview size that is closest to the viewfinder height and has // the right aspect ratio. List<Size> sizes = mParameters.getSupportedPreviewSizes(); Size optimalSize = getOptimalPreviewSize(sizes, (double) size.width / size.height); if (optimalSize != null) { mParameters.setPreviewSize(optimalSize.width, optimalSize.height); } mParameters.setJpegQuality(85); updateFlashModeParameter(); }
public static List<Camera.Size> getResolutionList(Camera camera) { Parameters parameters = camera.getParameters(); List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes(); return previewSizes; }
public void setCamera(Camera cameraObj) { this.camera = cameraObj; Parameters parameters = camera.getParameters(); supportedPreviewSizes = parameters.getSupportedPreviewSizes(); requestLayout(); }