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. AccountManager and Google App Engine

I am also interested in this.  If it is indeed possible to access the
authentication token for the Google accounts associated with the phone
itself, and to subsequently pass those to GAE so that backend
functionality can proceed to use the various GAE and other Google
services without requiring authentication, it seems like it's going to
be a significant draw to GAE for Android devs.




-- 

2. ScrollView scroll timeout ?

Hi,

Is there no way to change the timeout to scroll in ScrollView? In the
source, it's set to:

    static final int ANIMATED_SCROLL_GAP = 250;

so any drags will be blocked for 250ms. This has the appearance of the
ScrollView being stuck for a bit before it moves. This makes small
scroll gestures difficult to work with. There's no way around this?

Thanks

-- 

3. Android Eclair -- hangs after gralloc/mapFrameBufferLocked

4. I Didn't come here to cause no trouble, I just came to do the Android Market Shuffle!

5. RESET SQLite AUTOINCREMENT

6. Service runnning while PowerManager decides to sleep ?

7. Donut to Eclair