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.setFlashMode() Camera.Parameters.getFlashMode() |
Get or Set the flash mode, supported flash modes are:
Camera.Parameters.FLASH_MODE_AUTO |
| Camera.Parameters.setSceneMode() Camera.Parameters.getSceneMode() |
Get or Set the scene mode, supported scene modes are:
Camera.Parameters.SCENE_MODE_ACTION 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.setFocusMode() Camera.Parameters.getFocusMode() |
Get or Set the focus mode, supported focus modes are:
Camera.Parameters.FOCUS_MODE_AUTO |
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! ![]()
{ 11 comments… read them below or add one }
Thanks for the explanation.
Thank you
Great work keep it coming
Thank you Ron
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.
Actually current Camera API doesn’t provide us to choose which camera to use if multiple camera is there in the device. But this could be available in future APIs. This thread may help you to get more details: http://code.google.com/p/android/issues/detail?id=1120
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
tks!! it’s very helpful
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.
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 …..
woww..!! nice tutorial