Hi, I'd like to have transparent images in my android-game but since
we use lots of images, png24 filesizes are just too large. So I'm
trying to achieve the same effect with two jpg files, one the actual
image and the other the alpha-information. Here's how I did it so far:

        public void AddBitmap(Bitmap b, Bitmap alpha) {
                int w = b.getWidth();
                int h = b.getHeight();
                Bitmap bc = b.copy(Config.ARGB_8888, true);

                long tick = SystemClock.uptimeMillis();

                for (int x = 0; x < w; x++) {
                        for (int y = 0; y < h; y++) {
                                int c = b.getPixel(x, y);
                                bc.setPixel(
                                                x, y,
                                                Color.argb(
                                                                //
Calculate alpha value from grayscale jpg
                                                                255 - 
(int)(((float)alpha.getPixel(x, y) / (float)-16777216) *
(255)),
                                                                Color.red(c),
                                                                Color.green(c),
                                                                Color.blue(c)
                                                                )
                                                );

                        }
                }

                Bitmap bnew = bc.copy(Config.ARGB_8888, false);
                _bitmaps.add(bnew);
        }

However, this runs too slow (for a 169x127 picture it takes
350-400ms). Is there another way to accomplish the same, just a little
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

Reply via email to