Question

I have a transparent PNG image representing a bluetooth icon with a blue glow, exported from photoshop:

enter image description here

On a HTC Desire, a simple imageview is created, and the PNG is used as a bitmap. If the background arround the imageview is white, there are differences between nuances. If the background is black, than the differences are hidden. enter image description here

If I use ADB to do a screen capture, the problem is not visible: enter image description here

Possible causes: The screen uses a higher bit depth rate than what is used for the bitmap. Eg. RGB24 vs RGB16. By doing so, the screen has a wider number of nuances for white than what is possible for the bitmap encoding. When displayed, the bitmap's pixels are approximated to the new bit depth requirements, but fail to properly match the background nuance because of the approximations used. Eg. RGB16->RGB24 would mean C24 = 255*C16/31 .

If I use the screen capture software, the bit depths are probably downscaled to a narrower bit depth value (RGB16) so all the nuances merge together and are approximated to the simpler, 16bit colors. This is why I used a photo camera to illustrate the problem.

The Question is how to fix this?

I already tried loading the bitmap with parameters such as: resample.inPreferredConfig = Config.ARGB_8888; But to no use.

I simply need to display a transparent image, such as an icon with GFX effects: shadows, glows, etc. I would be happy to use a grayscale mask as well (Black=>White mask to indicate the pixel transparency, but didn't find a way for that either).

Thanks for your time!

Was it helpful?

Solution

This probably has nothing to do with bit depth.

The "whitish square" you described is in your screenshot as well. It is possible you can't see it on your computer monitor if your monitor is not properly calibrated.

OTHER TIPS

You can just set the Window format before setting the contentView in an Activity.

getWindow().setFormat(PixelFormat.RGBA_8888);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top