Converting an image captured by camera to grayscale

by Sharmila » Thu, 09 Jul 2009 06:22:41 GMT


Sponsored Links
 Hi guys,
I have a camera application that captures a 640x480 image.I want to
convert this image to grayscale.I know I have to use the setSaturatio
(float sat) in the ColorMatrix method to zero but I dnt know how I can
set it to grayscale...
Can someone please help me out?
Thanks.
--~--~---------~--~----~------------~-------~--~----~



Converting an image captured by camera to grayscale

by Jack Ha » Thu, 09 Jul 2009 07:39:23 GMT


 You can try something like the following:

    Bitmap grayscaleBitmap = Bitmap.createBitmap(
        colorBitmap.getWidth(), colorBitmap.getHeight(),
        Bitmap.Config.RGB_565);
    Canvas c = new Canvas(grayscaleBitmap);
    Paint p = new Paint();
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0);
    ColorMatrixColorFilter cmcf = new ColorMatrixColorFilter(cm);
    p.setColorFilter(cmcf);
    c.drawBitmap(colorBitmap, 0, 0, p);

--
Jack Ha
Open Source Development Center
obilestick together

The views, opinions and statements in this email are those of
the author solely in their individual capacity, and do not
necessarily represent those of T-Mobile USA, Inc.




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. lost android phone - privacy

I lost my android dev phone 1, during my vacation. I changed my gmail
password as soon as I could.

The phone must have been turned off as soon as it was found.  I can
safely assume that anyone using that phone is NOT using my gmail
address any longer.

The data connection had been disabled on that phone before the phone
was lost. So, when a new APN is added, as  relogin would be required,
the current user of that phone must be using a gmail account different
from mine.

Now the question is about the gmail client on that phone. Does gmail
client clear all cache when a relogin occurs?

I am sure that the cached emails are not deleted as long as there is
no relogin attempt, but is there a time-limit?



--~--~---------~--~----~------------~-------~--~----~

2. can i play gif?

Hi Dear,

i am trying to play a gif by

  is = context.getResources().openRawResource
(R.drawable.animated_gif);
  mMovie = Movie.decodeStream(is);

but mMovie remains null.

BitmapDecode.java example in apiDemo is not working either

i am using this code
http://www.anddev.org/how_to_play_gif_file_in_android-t3492.html
--~--~---------~--~----~------------~-------~--~----~

3. HorizontalScrollView snap to page?

4. Android Developer Support from Sprint

5. Downloading ADC2 judging application

6. Support for divx and wmv formats in PV opencore

7. application code for SDK 1.5 and 1.6