public class

Camera.Parameters

extends Object
java.lang.Object
   ↳ android.hardware.Camera.Parameters

Class Overview

Handles the parameters for pictures created by a Camera service.

To make camera parameters take effect, applications have to call Camera.setParameters. For example, after setWhiteBalance is called, white balance is not changed until Camera.setParameters() is called.

Different devices may have different camera capabilities, such as picture size or flash modes. The application should query the camera capabilities before setting parameters. For example, the application should call getSupportedColorEffects before calling setEffect. If the camera does not support color effects, getSupportedColorEffects will return null.

Summary

Constants
String ANTIBANDING_50HZ
String ANTIBANDING_60HZ
String ANTIBANDING_AUTO
String ANTIBANDING_OFF
String EFFECT_AQUA
String EFFECT_BLACKBOARD
String EFFECT_MONO
String EFFECT_NEGATIVE
String EFFECT_NONE
String EFFECT_POSTERIZE
String EFFECT_SEPIA
String EFFECT_SOLARIZE
String EFFECT_WHITEBOARD
String FLASH_MODE_AUTO Flash will be fired automatically when required.
String FLASH_MODE_OFF Flash will not be fired.
String FLASH_MODE_ON Flash will always be fired during snapshot.
String FLASH_MODE_RED_EYE Flash will be fired in red-eye reduction mode.
String FLASH_MODE_TORCH Constant emission of light during preview, auto-focus and snapshot.
String FOCUS_MODE_AUTO Auto-focus mode.
String FOCUS_MODE_FIXED Focus is fixed.
String FOCUS_MODE_INFINITY Focus is set at infinity.
String FOCUS_MODE_MACRO
String SCENE_MODE_ACTION
String SCENE_MODE_AUTO
String SCENE_MODE_BEACH
String SCENE_MODE_CANDLELIGHT
String SCENE_MODE_FIREWORKS
String SCENE_MODE_LANDSCAPE
String SCENE_MODE_NIGHT
String SCENE_MODE_NIGHT_PORTRAIT
String SCENE_MODE_PARTY
String SCENE_MODE_PORTRAIT
String SCENE_MODE_SNOW
String SCENE_MODE_SPORTS
String SCENE_MODE_STEADYPHOTO
String SCENE_MODE_SUNSET
String SCENE_MODE_THEATRE
String WHITE_BALANCE_AUTO
String WHITE_BALANCE_CLOUDY_DAYLIGHT
String WHITE_BALANCE_DAYLIGHT
String WHITE_BALANCE_FLUORESCENT
String WHITE_BALANCE_INCANDESCENT
String WHITE_BALANCE_SHADE
String WHITE_BALANCE_TWILIGHT
String WHITE_BALANCE_WARM_FLUORESCENT
Public Methods
String flatten()
Creates a single string with all the parameters set in this Parameters object.
String get(String key)
Returns the value of a String parameter.
String getAntibanding()
Gets the current antibanding setting.
String getColorEffect()
Gets the current color effect setting.
String getFlashMode()
Gets the current flash mode setting.
String getFocusMode()
Gets the current focus mode setting.
int getInt(String key)
Returns the value of an integer parameter.
int getJpegQuality()
Returns the quality setting for the JPEG picture.
int getJpegThumbnailQuality()
Returns the quality setting for the EXIF thumbnail in Jpeg picture.
Camera.Size getJpegThumbnailSize()
Returns the dimensions for EXIF thumbnail in Jpeg picture.
int getPictureFormat()
Returns the image format for pictures.
Camera.Size getPictureSize()
Returns the dimension setting for pictures.
int getPreviewFormat()
Returns the image format for preview pictures got from Camera.PreviewCallback.
int getPreviewFrameRate()
Returns the setting for the rate at which preview frames are received.
Camera.Size getPreviewSize()
Returns the dimensions setting for preview pictures.
String getSceneMode()
Gets the current scene mode setting.
List<String> getSupportedAntibanding()
Gets the supported antibanding values.
List<String> getSupportedColorEffects()
Gets the supported color effects.
List<String> getSupportedFlashModes()
Gets the supported flash modes.
List<String> getSupportedFocusModes()
Gets the supported focus modes.
List<Integer> getSupportedPictureFormats()
Gets the supported picture formats.
List<Camera.Size> getSupportedPictureSizes()
Gets the supported picture sizes.
List<Integer> getSupportedPreviewFormats()
Gets the supported preview formats.
List<Integer> getSupportedPreviewFrameRates()
Gets the supported preview frame rates.
List<Camera.Size> getSupportedPreviewSizes()
Gets the supported preview sizes.
List<String> getSupportedSceneModes()
Gets the supported scene modes.
List<String> getSupportedWhiteBalance()
Gets the supported white balance.
String getWhiteBalance()
Gets the current white balance setting.
void remove(String key)
void removeGpsData()
Removes GPS latitude, longitude, altitude, and timestamp from the parameters.
void set(String key, int value)
Sets an integer parameter.
void set(String key, String value)
Sets a String parameter.
void setAntibanding(String antibanding)
Sets the antibanding.
void setColorEffect(String value)
Sets the current color effect setting.
void setFlashMode(String value)
Sets the flash mode.
void setFocusMode(String value)
Sets the focus mode.
void setGpsAltitude(double altitude)
Sets GPS altitude.
void setGpsLatitude(double latitude)
Sets GPS latitude coordinate.
void setGpsLongitude(double longitude)
Sets GPS longitude coordinate.
void setGpsTimestamp(long timestamp)
Sets GPS timestamp.
void setJpegQuality(int quality)
Sets Jpeg quality of captured picture.
void setJpegThumbnailQuality(int quality)
Sets the quality of the EXIF thumbnail in Jpeg picture.
void setJpegThumbnailSize(int width, int height)
Sets the dimensions for EXIF thumbnail in Jpeg picture.
void setPictureFormat(int pixel_format)
Sets the image format for pictures.
void setPictureSize(int width, int height)
Sets the dimensions for pictures.
void setPreviewFormat(int pixel_format)
Sets the image format for preview pictures.
void setPreviewFrameRate(int fps)
Sets the rate at which preview frames are received.
void setPreviewSize(int width, int height)
Sets the dimensions for preview pictures.
void setRotation(int rotation)
Sets the orientation of the device in degrees.
void setSceneMode(String value)
Sets the scene mode.
void setWhiteBalance(String value)
Sets the white balance.
void unflatten(String flattened)
Takes a flattened string of parameters and adds each one to this Parameters object.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ANTIBANDING_50HZ

Since: API Level 5

Constant Value: "50hz"

public static final String ANTIBANDING_60HZ

Since: API Level 5

Constant Value: "60hz"

public static final String ANTIBANDING_AUTO

Since: API Level 5

Constant Value: "auto"

public static final String ANTIBANDING_OFF

Since: API Level 5

Constant Value: "off"

public static final String EFFECT_AQUA

Since: API Level 5

Constant Value: "aqua"

public static final String EFFECT_BLACKBOARD

Since: API Level 5

Constant Value: "blackboard"

public static final String EFFECT_MONO

Since: API Level 5

Constant Value: "mono"

public static final String EFFECT_NEGATIVE

Since: API Level 5

Constant Value: "negative"

public static final String EFFECT_NONE

Since: API Level 5

Constant Value: "none"

public static final String EFFECT_POSTERIZE

Since: API Level 5

Constant Value: "posterize"

public static final String EFFECT_SEPIA

Since: API Level 5

Constant Value: "sepia"

public static final String EFFECT_SOLARIZE

Since: API Level 5

Constant Value: "solarize"

public static final String EFFECT_WHITEBOARD

Since: API Level 5

Constant Value: "whiteboard"

public static final String FLASH_MODE_AUTO

Since: API Level 5

Flash will be fired automatically when required. The flash may be fired during preview, auto-focus, or snapshot depending on the driver.

Constant Value: "auto"

public static final String FLASH_MODE_OFF

Since: API Level 5

Flash will not be fired.

Constant Value: "off"

public static final String FLASH_MODE_ON

Since: API Level 5

Flash will always be fired during snapshot. The flash may also be fired during preview or auto-focus depending on the driver.

Constant Value: "on"

public static final String FLASH_MODE_RED_EYE

Since: API Level 5

Flash will be fired in red-eye reduction mode.

Constant Value: "red-eye"

public static final String FLASH_MODE_TORCH

Since: API Level 5

Constant emission of light during preview, auto-focus and snapshot. This can also be used for video recording.

Constant Value: "torch"

public static final String FOCUS_MODE_AUTO

Since: API Level 5

Auto-focus mode.

Constant Value: "auto"

public static final String FOCUS_MODE_FIXED

Since: API Level 5

Focus is fixed. The camera is always in this mode if the focus is not adjustable. If the camera has auto-focus, this mode can fix the focus, which is usually at hyperfocal distance. Applications should not call autoFocus(AutoFocusCallback) in this mode.

Constant Value: "fixed"

public static final String FOCUS_MODE_INFINITY

Since: API Level 5

Focus is set at infinity. Applications should not call autoFocus(AutoFocusCallback) in this mode.

Constant Value: "infinity"

public static final String FOCUS_MODE_MACRO

Since: API Level 5

Constant Value: "macro"

public static final String SCENE_MODE_ACTION

Since: API Level 5

Constant Value: "action"

public static final String SCENE_MODE_AUTO

Since: API Level 5

Constant Value: "auto"

public static final String SCENE_MODE_BEACH

Since: API Level 5

Constant Value: "beach"

public static final String SCENE_MODE_CANDLELIGHT

Since: API Level 5

Constant Value: "candlelight"

public static final String SCENE_MODE_FIREWORKS

Since: API Level 5

Constant Value: "fireworks"

public static final String SCENE_MODE_LANDSCAPE

Since: API Level 5

Constant Value: "landscape"

public static final String SCENE_MODE_NIGHT

Since: API Level 5

Constant Value: "night"

public static final String SCENE_MODE_NIGHT_PORTRAIT

Since: API Level 5

Constant Value: "night-portrait"

public static final String SCENE_MODE_PARTY

Since: API Level 5

Constant Value: "party"

public static final String SCENE_MODE_PORTRAIT

Since: API Level 5

Constant Value: "portrait"

public static final String SCENE_MODE_SNOW

Since: API Level 5

Constant Value: "snow"

public static final String SCENE_MODE_SPORTS

Since: API Level 5

Constant Value: "sports"

public static final String SCENE_MODE_STEADYPHOTO

Since: API Level 5

Constant Value: "steadyphoto"

public static final String SCENE_MODE_SUNSET

Since: API Level 5

Constant Value: "sunset"

public static final String SCENE_MODE_THEATRE

Since: API Level 5

Constant Value: "theatre"

public static final String WHITE_BALANCE_AUTO

Since: API Level 5

Constant Value: "auto"

public static final String WHITE_BALANCE_CLOUDY_DAYLIGHT

Since: API Level 5

Constant Value: "cloudy-daylight"

public static final String WHITE_BALANCE_DAYLIGHT

Since: API Level 5

Constant Value: "daylight"

public static final String WHITE_BALANCE_FLUORESCENT

Since: API Level 5

Constant Value: "fluorescent"

public static final String WHITE_BALANCE_INCANDESCENT

Since: API Level 5

Constant Value: "incandescent"

public static final String WHITE_BALANCE_SHADE

Since: API Level 5

Constant Value: "shade"

public static final String WHITE_BALANCE_TWILIGHT

Since: API Level 5

Constant Value: "twilight"

public static final String WHITE_BALANCE_WARM_FLUORESCENT

Since: API Level 5

Constant Value: "warm-fluorescent"

Public Methods

public String flatten ()

Since: API Level 1

Creates a single string with all the parameters set in this Parameters object.

The unflatten(String) method does the reverse.

Returns
  • a String with all values from this Parameters object, in semi-colon delimited key-value pairs

public String get (String key)

Since: API Level 1

Returns the value of a String parameter.

Parameters
key the key name for the parameter
Returns
  • the String value of the parameter

public String getAntibanding ()

Since: API Level 5

Gets the current antibanding setting.

Returns
  • one of ANTIBANDING_XXX string constant. null if antibanding setting is not supported.

public String getColorEffect ()

Since: API Level 5

Gets the current color effect setting.

Returns
  • one of EFFECT_XXX string constant. null if color effect setting is not supported.

public String getFlashMode ()

Since: API Level 5

Gets the current flash mode setting.

Returns
  • one of FLASH_MODE_XXX string constant. null if flash mode setting is not supported.

public String getFocusMode ()

Since: API Level 5

Gets the current focus mode setting.

Returns

public int getInt (String key)

Since: API Level 1

Returns the value of an integer parameter.

Parameters
key the key name for the parameter
Returns
  • the int value of the parameter

public int getJpegQuality ()

Since: API Level 5

Returns the quality setting for the JPEG picture.

Returns
  • the JPEG picture quality setting.

public int getJpegThumbnailQuality ()

Since: API Level 5

Returns the quality setting for the EXIF thumbnail in Jpeg picture.

Returns
  • the JPEG quality setting of the EXIF thumbnail.

public Camera.Size getJpegThumbnailSize ()

Since: API Level 5

Returns the dimensions for EXIF thumbnail in Jpeg picture.

Returns
  • a Size object with the height and width setting for the EXIF thumbnails

public int getPictureFormat ()

Since: API Level 1

Returns the image format for pictures.

Returns
  • the PixelFormat int representing the picture format

public Camera.Size getPictureSize ()

Since: API Level 1

Returns the dimension setting for pictures.

Returns
  • a Size object with the height and width setting for pictures

public int getPreviewFormat ()

Since: API Level 1

Returns the image format for preview pictures got from Camera.PreviewCallback.

Returns
  • the PixelFormat int representing the preview picture format.

public int getPreviewFrameRate ()

Since: API Level 1

Returns the setting for the rate at which preview frames are received.

Returns
  • the frame rate setting (frames per second)

public Camera.Size getPreviewSize ()

Since: API Level 1

Returns the dimensions setting for preview pictures.

Returns
  • a Size object with the height and width setting for the preview picture

public String getSceneMode ()

Since: API Level 5

Gets the current scene mode setting.

Returns
  • one of SCENE_MODE_XXX string constant. null if scene mode setting is not supported.

public List<String> getSupportedAntibanding ()

Since: API Level 5

Gets the supported antibanding values.

Returns
  • a List of ANTIBANDING_XXX string constants. null if antibanding setting is not supported.

public List<String> getSupportedColorEffects ()

Since: API Level 5

Gets the supported color effects.

Returns
  • a List of EFFECT_XXX string constants. null if color effect setting is not supported.

public List<String> getSupportedFlashModes ()

Since: API Level 5

Gets the supported flash modes.

Returns
  • a List of FLASH_MODE_XXX string constants. null if flash mode setting is not supported.

public List<String> getSupportedFocusModes ()

Since: API Level 5

Gets the supported focus modes.

Returns
  • a List of FOCUS_MODE_XXX string constants. This method will always return a list with at least one element.

public List<Integer> getSupportedPictureFormats ()

Since: API Level 5

Gets the supported picture formats.

Returns
  • a List of Integer objects (values are PixelFormat.XXX). This method will always return a list with at least one element.

public List<Camera.Size> getSupportedPictureSizes ()

Since: API Level 5

Gets the supported picture sizes.

Returns
  • a List of Size objects. This method will always return a list with at least one element.

public List<Integer> getSupportedPreviewFormats ()

Since: API Level 5

Gets the supported preview formats.

Returns
  • a List of Integer objects. This method will always return a list with at least one element.

public List<Integer> getSupportedPreviewFrameRates ()

Since: API Level 5

Gets the supported preview frame rates.

Returns
  • a List of Integer objects (preview frame rates). null if preview frame rate setting is not supported.

public List<Camera.Size> getSupportedPreviewSizes ()

Since: API Level 5

Gets the supported preview sizes.

Returns
  • a List of Size object. This method will always return a list with at least one element.

public List<String> getSupportedSceneModes ()

Since: API Level 5

Gets the supported scene modes.

Returns
  • a List of SCENE_MODE_XXX string constant. null if scene mode setting is not supported.

public List<String> getSupportedWhiteBalance ()

Since: API Level 5

Gets the supported white balance.

Returns
  • a List of WHITE_BALANCE_XXX string constants. null if white balance setting is not supported.

public String getWhiteBalance ()

Since: API Level 5

Gets the current white balance setting.

Returns
  • one of WHITE_BALANCE_XXX string constant. null if white balance setting is not supported.

public void remove (String key)

Since: API Level 1

public void removeGpsData ()

Since: API Level 5

Removes GPS latitude, longitude, altitude, and timestamp from the parameters.

public void set (String key, int value)

Since: API Level 1

Sets an integer parameter.

Parameters
key the key name for the parameter
value the int value of the parameter

public void set (String key, String value)

Since: API Level 1

Sets a String parameter.

Parameters
key the key name for the parameter
value the String value of the parameter

public void setAntibanding (String antibanding)

Since: API Level 5

Sets the antibanding.

Parameters
antibanding ANTIBANDING_XXX string constant.

public void setColorEffect (String value)

Since: API Level 5

Sets the current color effect setting.

Parameters
value EFFECT_XXX string constants.

public void setFlashMode (String value)

Since: API Level 5

Sets the flash mode.

Parameters
value FLASH_MODE_XXX string constants.

public void setFocusMode (String value)

Since: API Level 5

Sets the focus mode.

Parameters
value FOCUS_MODE_XXX string constants.

public void setGpsAltitude (double altitude)

Since: API Level 5

Sets GPS altitude. This will be stored in JPEG EXIF header.

Parameters
altitude GPS altitude in meters.

public void setGpsLatitude (double latitude)

Since: API Level 5

Sets GPS latitude coordinate. This will be stored in JPEG EXIF header.

Parameters
latitude GPS latitude coordinate.

public void setGpsLongitude (double longitude)

Since: API Level 5

Sets GPS longitude coordinate. This will be stored in JPEG EXIF header.

Parameters
longitude GPS longitude coordinate.

public void setGpsTimestamp (long timestamp)

Since: API Level 5

Sets GPS timestamp. This will be stored in JPEG EXIF header.

Parameters
timestamp GPS timestamp (UTC in seconds since January 1, 1970).

public void setJpegQuality (int quality)

Since: API Level 5

Sets Jpeg quality of captured picture.

Parameters
quality the JPEG quality of captured picture. The range is 1 to 100, with 100 being the best.

public void setJpegThumbnailQuality (int quality)

Since: API Level 5

Sets the quality of the EXIF thumbnail in Jpeg picture.

Parameters
quality the JPEG quality of the EXIF thumbnail. The range is 1 to 100, with 100 being the best.

public void setJpegThumbnailSize (int width, int height)

Since: API Level 5

Sets the dimensions for EXIF thumbnail in Jpeg picture.

Parameters
width the width of the thumbnail, in pixels
height the height of the thumbnail, in pixels

public void setPictureFormat (int pixel_format)

Since: API Level 1

Sets the image format for pictures.

Parameters
pixel_format the desired picture format (PixelFormat.YCbCr_420_SP (NV21), PixelFormat.RGB_565, or PixelFormat.JPEG)
See Also

public void setPictureSize (int width, int height)

Since: API Level 1

Sets the dimensions for pictures.

Parameters
width the width for pictures, in pixels
height the height for pictures, in pixels

public void setPreviewFormat (int pixel_format)

Since: API Level 1

Sets the image format for preview pictures.

If this is never called, the default format will be YCbCr_420_SP, which uses the NV21 encoding format.

Parameters
pixel_format the desired preview picture format, defined by one of the PixelFormat constants. (E.g., PixelFormat.YCbCr_420_SP (default), PixelFormat.RGB_565, or PixelFormat.JPEG)
See Also

public void setPreviewFrameRate (int fps)

Since: API Level 1

Sets the rate at which preview frames are received.

Parameters
fps the frame rate (frames per second)

public void setPreviewSize (int width, int height)

Since: API Level 1

Sets the dimensions for preview pictures.

Parameters
width the width of the pictures, in pixels
height the height of the pictures, in pixels

public void setRotation (int rotation)

Since: API Level 5

Sets the orientation of the device in degrees. For example, suppose the natural position of the device is landscape. If the user takes a picture in landscape mode in 2048x1536 resolution, the rotation should be set to 0. If the user rotates the phone 90 degrees clockwise, the rotation should be set to 90. Applications can use OrientationEventListener to set this parameter. The camera driver may set orientation in the EXIF header without rotating the picture. Or the driver may rotate the picture and the EXIF thumbnail. If the Jpeg picture is rotated, the orientation in the EXIF header will be missing or 1 (row #0 is top and column #0 is left side).

Parameters
rotation The orientation of the device in degrees. Rotation can only be 0, 90, 180 or 270.
Throws
IllegalArgumentException if rotation value is invalid.

public void setSceneMode (String value)

Since: API Level 5

Sets the scene mode. Other parameters may be changed after changing scene mode. For example, flash and supported flash mode may be changed to "off" in night scene mode. After setting scene mode, applications should call getParameters to know if some parameters are changed.

Parameters
value SCENE_MODE_XXX string constants.

public void setWhiteBalance (String value)

Since: API Level 5

Sets the white balance.

Parameters
value WHITE_BALANCE_XXX string constant.

public void unflatten (String flattened)

Since: API Level 1

Takes a flattened string of parameters and adds each one to this Parameters object.

The flatten() method does the reverse.

Parameters
flattened a String of parameters (key-value paired) that are semi-colon delimited