For who it concerns..
As is seems it is not possible within the android api to do color
keying directly, so I created a function to set all pixels manual. It
is based on the color located on pixel 0,0. If you want to use a given
color just replace it by its color value.
public Bitmap setTransparancy(Bitmap orgBitmap) {
int width = orgBitmap.getWidth();
int height = orgBitmap.getHeight();
int pix[] = new int[height * width];
orgBitmap.getPixels(pix, 0, width, 0, 0, width, height);
int nrPixels = pix.length;
int m_transPixel = pix[0]; //
assuming that the first pixel is
the transparant one
for(int i=0; i < nrPixels; i++) {
if (pix[i] == m_transPixel ) {
pix[i] = pix[i] & 0x00FFFFFF; // set to full
transparancy
}
}
return Bitmap.createBitmap(pix, width, height,
orgBitmap.getConfig
() );
}
Needless to say that you should do this at the start of your app or in
your gfx conversion as it is otherwise to time consuming.
Cheers,
Arjen
On Mar 19, 7:23 am, Tazzer <[email protected]> wrote:
> Hi,
>
> I am working on a 2d library for creating a game including sprite
> collisions, sorting and animation converting (.spr to Java classes/
> bmp's).
>
> At first I used png's with the background color being transparant (24
> bits png image) but I want to use 256 color bitmaps with the
> background color being transparant.
>
> Is this possible to do color keying in android? I looked at several
> other threads about this topic but the all ended without a solution.
>
> Also I am now using the canvas.drawBitmap to render my sprites, but
> will using opengl be faster?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---