Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ALPHA_8 bitmaps and getPixel

Tags:

android

bitmap

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() ?

like image 591
Mitrescu Catalin Avatar asked Feb 12 '12 08:02

Mitrescu Catalin


People also ask

What are bitmaps in Android?

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.

How do I know if my Android BMP is empty?

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.

What is bitmap config?

A bitmap configuration describes how pixels are stored. This affects the quality (color depth) as well as the ability to display transparent/translucent colors.


1 Answers

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

like image 58
usethe4ce Avatar answered Sep 20 '22 14:09

usethe4ce