I am trying to load a movement map from a PNG image. In order to save memory after I load the bitmap I do something like that.
`Bitmap mapBmp = tempBmp.copy(Bitmap.Config.ALPHA_8, false);`
If I draw the mapBmp I can see the map but when I use getPixel() I get always 0 (zero).
Is there a way to retrieve ALPHA information from a bitmap other than with getPixel() ?
A bitmap is simply a rectangle of pixels. Each pixel can be set to a given color but exactly what color depends on the type of the pixel. The first two parameters give the width and the height in pixels. The third parameter specifies the type of pixel you want to use.
You can do a check when you want to return the BitMap look to see if the ArrayList of Paths is bigger than 0 and return the BitMap if so, or else return null.
A bitmap configuration describes how pixels are stored. This affects the quality (color depth) as well as the ability to display transparent/translucent colors.
Seems to be an Android bug in handling ALPHA_8
. I also tried copyPixelsToBuffer
, to no avail. Simplest workaround is to waste lots of memory and use ARGB_8888
.
Issue 25690
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With