Hi,

So the code above never actually gets the pixels of the orignial image
hence my woes. Pretty ridiculous error but hey, it's late and nearly
Christmas!

Anyway, I'd still be interested if anyone has an ideal for an optimal
implementation of inverse. I'd also like to learn more about the
Config enum.

Many thanks,

Gavin

On Dec 16, 11:51 pm, Gav <[email protected]> wrote:
> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to