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.
精彩评论