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. Uploads disabled in browser

hey guys,
is there anyway to upload an image from android/simulator through a
web page?

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

2. displaying a simple MessageBox

Well I just want to display a simple messagebox

this.showAlert(""); does not work for me

how should I go about it

I simply want a messagebox with singlebutton of whom I can set title
and the text displayed
something like this

MessageBox("any stupid text ");


thank you

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

3. Streaming Media to Android Success!!!!

4. How to get the picture(like a .jpg picture) in Android?

5. 'Keytool error' when building

6. Image Zoom

7. How can I change a ListView to ExpandableList