android.graphics.Bitmap.Config - How to implement an Inverse Filter?

by Gav » Wed, 17 Dec 2008 07:51:37 GMT


Sponsored Links
 Hey!

I am looking to make custom filters which manipulate the pixels of a
Bitmap. Before I can start I need to read up more on the Configs and
how they are encoded in the bitmap. I like to use examples so here's
my Inverse function;

        public Bitmap invert(final Bitmap d) {
                int index, r, g, b;
                int picw = d.getWidth();
                int pich = d.getHeight();

                int[] pix = new int[picw * pich];

                for (int y = 0; y < pich; y++){
                        for (int x = 0; x < picw; x++) {

                                index = y * picw + x;
                                r = 255 - ((pix[index] >> 16) & 0xff);
                                g = 255 - ((pix[index] >> 8) & 0xff);
                                b = 255 - (pix[index] & 0xff);

                                pix[index] = 0xff000000 | (r << 16) | (g << 8) 
| b;
                        }
                }

                return Bitmap.createBitmap(pix, picw, pich, d.getConfig());

The bitmap returned is a white out which leads me to believe that my
assumption about the encoding of the RGB values is wrong. Upon further
investigation I found that the image could be any of the following
configs;

ALPHA_8
ARGB_4444
ARGB_8888
RGB_565

Which I would like to learn more about, can anyone point me in the
direction of an explanation of how these encodings work? I was wary of
material I found as it might not be the same standard Google uses.

If you can recommend a better way of inverting a Bitmap the
information would also be of substantial benefit for me.

Many thanks, any help or comments would be greatly appreciated!

Gav
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Android Market Developers site

Hi All

I have recently paid to join the Android Developers site and paid my
$25. I am now trying to sign in here:

http://market.android.com/publish/signup

But all I get is a blank Distribution agreement with no button to
accept it.

Because of this I am unable to sign in. This has been like this for
several days now so I don't think it's something that is temporarily
down. I have tried this in IE 8 and chrome and get the same result.

Thanks

-- 

2. NATURAL U.S.A PUZZZZYYY MMMIILLLKKKYYY BOOOBBSSSS

NATURAL U.S.A PUZZZZYYY MMMIILLLKKKYYY BOOOBBSSSS

   http://businessmang.blogspot.com/

       http://businessmang.blogspot.com/

            http://businessmang.blogspot.com/

-- 

3. TIPS FOR HEALTHY AND BEAUTY TIPS

4. Good opportunity for the shoppingreps .com

5. Listening to Settings application Intents

6. tabwidget page moving

7. Programatically answering a call