Camera effects in Android 2.0 and above

Download source code of this article.

This is a continuation of my previous article Programming camera in Android which explains how the program the Android camera hardware. This article concentrates on how to set camera effects. From Android 2.0 onwards we can set different effects such as color effect, white balance, zoom, etc. Android 2.0 onwards the camera API supports Anti-banding mode, color effects, scene mode, white balance, etc..

These effects can be programmatically set using camera parameters. Following code snippet sets the color effect to EFFECT_AQUA.

Camera.Parameters parameters = camera.getParameters();

parameters.setColorEffect(Camera.Parameters.EFFECT_AQUA);

camera.setParameters(parameters);

These effects depends on the camera hardware of the device and may not support all the available effects. following are some of the methods to support these effects:

Camera.Parameters.setColorEffect()
Camera.Parameters.getColorEffect()
Get or Set the color effects, supported color effects are:

Camera.Parameters.EFFECT_AQUA
Camera.Parameters.EFFECT_BLACKBOARD
Camera.Parameters.EFFECT_MONO
Camera.Parameters.EFFECT_NEGATIVE
Camera.Parameters.EFFECT_NONE
Camera.Parameters.EFFECT_POSTERIZE
Camera.Parameters.EFFECT_SEPIA
Camera.Parameters.EFFECT_SOLARIZE
Camera.Parameters.EFFECT_WHITEBOARD

Camera.Parameters.setFlashMode()
Camera.Parameters.getFlashMode()
Get or Set the flash mode, supported flash modes are:

Camera.Parameters.FLASH_MODE_AUTO
Camera.Parameters.FLASH_MODE_OFF
Camera.Parameters.FLASH_MODE_ON
Camera.Parameters.FLASH_MODE_RED_EYE
Camera.Parameters.FLASH_MODE_TORCH

Camera.Parameters.setSceneMode()
Camera.Parameters.getSceneMode()
Get or Set the scene mode, supported scene modes are:

Camera.Parameters.SCENE_MODE_ACTION
Camera.Parameters.SCENE_MODE_AUTO
Camera.Parameters.SCENE_MODE_BARCODE
Camera.Parameters.SCENE_MODE_BEACH
Camera.Parameters.SCENE_MODE_CANDLELIGHT
Camera.Parameters.SCENE_MODE_FIREWORKS
Camera.Parameters.SCENE_MODE_LANDSCAPE
Camera.Parameters.SCENE_MODE_NIGHT
Camera.Parameters.SCENE_MODE_NIGHT_PORTRAIT
Camera.Parameters.SCENE_MODE_PARTY
Camera.Parameters.SCENE_MODE_PORTRAIT
Camera.Parameters.SCENE_MODE_SNOW
Camera.Parameters.SCENE_MODE_SPORTS
Camera.Parameters.SCENE_MODE_STEADYPHOTO
Camera.Parameters.SCENE_MODE_SUNSET
Camera.Parameters.SCENE_MODE_THEATRE

Note that setting scene mode may effect other camera effects.

Camera.Parameters.setWhiteBalance()
Camera.Parameters.getWhiteBalance()
Get or Set the white balance, supported white balance modes are:

Camera.Parameters.WHITE_BALANCE_AUTO
Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT
Camera.Parameters.WHITE_BALANCE_DAYLIGHT
Camera.Parameters.WHITE_BALANCE_FLUORESCENT
Camera.Parameters.WHITE_BALANCE_INCANDESCENT
Camera.Parameters.WHITE_BALANCE_SHADE
Camera.Parameters.WHITE_BALANCE_TWILIGHT
Camera.Parameters.WHITE_BALANCE_WARM_FLUORESCENT

Camera.Parameters.setFocusMode()
Camera.Parameters.getFocusMode()
Get or Set the focus mode, supported focus modes are:

Camera.Parameters.FOCUS_MODE_AUTO
Camera.Parameters.FOCUS_MODE_EDOF
Camera.Parameters.FOCUS_MODE_FIXED
Camera.Parameters.FOCUS_MODE_INFINITY
Camera.Parameters.FOCUS_MODE_MACRO

All the camera hardware may not support these effects, to get the supported effects Camera.Parameters provides different methods. All these methods returns a list of strings. Some of them are:

Camera.Parameters.getSupportedAntibanding() Returns a list of anti-banding modes supported.
Camera.Parameters.getSupportedColorEffects() Returns a list of color effects supported.
Camera.Parameters.getSupportedFlashModes() Returns a list of flash modes supported.
Camera.Parameters.getSupportedFocusModes() Returns a list of focus modes supported.
Camera.Parameters.getSupportedSceneModes() Returns a list of scene modes supported.
Camera.Parameters.getSupportedWhiteBalance() Returns a list of white balance modes supported.

Setting some of the effects may change the other effects, for example setting scene mode may effect the flash mode, color effect, white balance, etc.

The sample application of this article is same as my previous article but with color effect and white balance effects added. When you clock on the color effect or white balance button, supported effects will be listed and the selected effect will be set.

Hope this piece of information is helpful to you.

Happy camera coding! Smile

15 Comments

Add yours →

  1. Thanks for the explanation.

  2. I am working on the external camera connectivity for android Tablet. I am having the tablet which supports external device connectivity. Is there any special thing i have to do for this? Kindly let me know your thoughts.

  3. Its realy Nice but i have some problem. actualy i want to create file upload.
    so i create html file and also create FileCommandHandler like that messagecommandhandler but i got only name of image. but i want to store it in sdcard. tell me ur opinion.
    thanks

  4. tks!! it’s very helpful

  5. Hey Varma. This is really good tutorial, Thanks 🙂
    I wanted to know how to add filter effects to an image in Android, like its possible in as3 using pixel bender.

  6. Hiiii Mr. Varma………
    The tutorial seems to be of great help…………
    if the coding is directly available in eclipse format on your portal rather than going to google groups and downloading each and every page of your work…..or could you mail me(ajayt059@gmail.com) all the sample programs of GPS application or especially GPS logger ,so that they ‘ll also help me in my curriculum………….please i need them for my curriculum project …..

  7. woww..!! nice tutorial

  8. hi varma ,

    thank you very much…
    and i need some small addition ..
    i want to save the images in sdcard and i am not able to .. please can help me out…..

  9. Can i set saturation, color hue, contrast in live front-camera using seekbar.
    if anyone have any idea please help me.

  10. Navdeep Agrawal

    May 18, 2015 — 2:18 pm

    Really very helpfull

Leave a Reply