开发者

Bit depth issues on bitmaps and screens (white is not white)

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

Bit depth issues on bitmaps and screens (white is not white)

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.

Bit depth issues on bitmaps and screens (white is not white)

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

Bit depth issues on bitmaps and screens (white is not white)

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, t开发者_JS百科he 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!


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

getWindow().setFormat(PixelFormat.RGBA_8888);


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜