Canvas.drawBitmap(int[] colors, ...) creates wrong alpha blending

132 views
Skip to first unread message

Toothy Bunny

unread,
Dec 10, 2008, 2:26:59 PM12/10/08
to Android Developers
Hi All,
I'm trying to use Canvas.drawBitmap(int[] colors, int offset, int
stride, int x, int y, int width, int height, boolean hasAlpha, Paint
paint) to draw an integer color array containing an image pixels array
in the format of ARGB_8888 (with alpha channel).

This function is provided in SDK 1.0 to draw a color pixel array
directly without creating an intermediate Bitmap. However, I found
this function does not perform alpha blending at all.

The attached picture is the screen shot of my test result. Left screen
shot is the correct result if I create a Bitmap from the color array
first then draw the created Bitmap. Right screen shot is the wrong
result if I draw the color array directly. I noticed in the wrong
rendering, all pixels are treated as either completely opaque or
completely transparent. if a pixel has a alpha value other than 0xFF
or 0x00 (translucent pixel), it will be rendered incorrectly.

I hope anyone in Android team can give some suggestions for this
issue. I'm currently thinking this is a bug.

Hongkun
OmniGSoft

Toothy Bunny

unread,
Dec 10, 2008, 2:31:59 PM12/10/08
to Android Developers
I could not find a way to attach pictures with my post, so I post the
screen shot on the web, and here is the link:

The test screen shot:
http://www.omnigsoft.com/TechnicalSupport/TestResult.png

The original PNG image (with alpha channel) I used for the test:
http://www.omnigsoft.com/TechnicalSupport/pngWithAlpha.png

Hongkun
OmniGSoft

Mike Reed

unread,
Dec 11, 2008, 11:47:06 AM12/11/08
to android-d...@googlegroups.com
Sounds like a good bug. Can you file it as one, and I'll take a look?
Reply all
Reply to author
Forward
0 new messages