开发者

BitmapFactory.decodeByteArray doesn't keep color information when pixel is fully transparent

I use the BitmapFactory.decodeByteArray to generate a Bitmap from a PNG image. Then I use Bitmap.getPixels to retrive all the pixel data. The problem is that when a pixel is set as fully transparent, all the color data seams to be discarded. 0x0000ff00 is being returned as 0x00000000. If I create an image from code which has transparent pixels I make a copy, render that to a canvas, use Canvas.drawColor(0xff000000, Mode.DST_ATOP) and then get all the correct color values with getPixels and then add that with the alpha values I got from the first getPixels call. I can't do that now since the color information seams to be gone. Is there any way to ma开发者_Python百科ke sure that the color information is stored when generating a Bitmap from a PNG file using the BitmapFactory?


try setting BitmapFactory.Options.inDither = false, it should do the trick. Took the wisdom from here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜