Controlling and Monitoring Camera Settings and Image Options

The camera settings are stored using a Camera.Parameters object, accessible by calling the getParameters method on the Camera object.

In order to modify the camera settings, use the set* methods on the Parameters object before calling the Camera'setParameters method and passing in the modified Parameters object.

LISTING 11-13: Reading and modifying camera settings Available for download on Camera.Parameters parameters = camera.getParameters(); [ ... make changes ... ]


Android 2.0 (API level 5) introduced a wide range of Camera Parameters, each with a setter and getter including:

> [get/set]SceneMode Takes or returns a scene_mode_* static string constant from the Camera Parameters class. Each scene mode describes a particular scene type (party, beach, sunset, etc.).

> [get/set]FlashMode Takes or returns a flash_mode_* static string constant. Lets you specify the flash mode as on, off, red-eye reduction, or flashlight mode.

> [get/set]WhiteBalance Takes or returns a WHITE_BALANCE_* static string constant to describe the white balance of the scene being photographed.

> [get/set]ColorEffect Takes or returns a effect_* static string constant to modify how the image is presented. Available color effects include sepia tone or black and white.

> [get/set]FocusMode Takes or returns a focus_mode_* static string constant to specify how the camera autofocus should attempt to focus the camera.

Most of the parameters described above are useful primarily if you are replacing the native camera application. That said, they can also be useful for customizing the way the camera preview is displayed, allowing you to customize the live camera stream for augmented reality applications.

Camera Parameters can also be used to read or specify size, quality, and format parameters for the image, thumbnail, and camera preview. The following list explains how to set some of these values:

> JPEG and thumbnail quality Use the setJpegQuality and setJpegThumbnailQuality methods, passing in an integer value between 0 and 100, where 100 is the best quality.

> Image, preview, and thumbnail size Use setPictureSize, setPreviewSize, setJpegThumbnailSize to specify a height and width for the image, preview, and thumbnail respectively.

> Image and preview pixel format Use setPictureFormat and setPreviewFormat to set the image format using a static constant from the PixelFormat class.

> Preview frame rate Use setPreviewFrameRate to specify the preview frame rate in fps (frames per second).

Each device may potentially support a different subset of these parameter values. The Camera Parameters class also includes a range of getSupported* methods to find valid options to display to the user, or confirm that a desired parameter value is supported before assigning the value in code, as shown in Listing 11-14.

Checking for supported parameter values is particularly important when selecting valid preview or image sizes as each device's camera will potentially support a different subset.

LISTING 11-14: Confirming supported camera settings

Camera.Parameters parameters = camera.getParameters(); List<String> colorEffects = parameters.getSupportedColorEffects(); if (colorEffects.contains(Camera.Parameters.EFFECT_SEPIA)) parameters.setColorEffect(Camera.Parameters.EFFECT_SEPIA);


Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


  • Habte
    How to set camera.parameters in android for color effects?
    7 years ago
  • Cerdic
    How to use camera.getparameters().get supported color effects() methods?
    7 years ago

Post a comment