位图和屏幕上的位深度问题(白色不是白色)
我有一个透明的 PNG 图像,代表带有蓝色光芒的蓝牙图标,从 Photoshop 导出:
在 HTC 上希望,创建一个简单的imageview,并使用PNG作为位图。 如果图像视图周围的背景是白色,则细微差别之间存在差异。如果背景是黑色,则差异会被隐藏。
如果我使用 ADB 进行屏幕捕获,则问题不可见:
可能的原因: 屏幕使用的位深度率高于位图所使用的位深度率。例如。 RGB24 与 RGB16。通过这样做,屏幕上的白色细微差别数量比位图编码所能提供的要多。显示时,位图的像素近似于新的位深度要求,但由于使用的近似值而无法正确匹配背景的细微差别。例如。 RGB16->RGB24 意味着 C24 = 255*C16/31 。
如果我使用屏幕捕获软件,位深度可能会缩小到更窄的位深度值 (RGB16),因此所有细微差别都会合并在一起并近似为更简单的 16 位颜色。这就是为什么我用相机来说明问题。
问题是如何解决这个问题?
我已经尝试使用以下参数加载位图: resample.inPreferredConfig = Config.ARGB_8888; 但没有用。
我只需要显示透明图像,例如具有 GFX 效果的图标:阴影、发光等。我也很乐意使用灰度蒙版(黑色 => 白色蒙版来指示像素透明度,但没有'也找不到办法)。
感谢您抽出时间!
I have a transparent PNG image representing a bluetooth icon with a blue glow, exported from photoshop:
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.
If I use ADB to do a screen capture, the problem is not visible:
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 Activity 中设置 contentView 之前设置 Window 格式。
You can just set the Window format before setting the contentView in an Activity.
这可能与位深度无关。
您所描述的“白色方块”也在您的屏幕截图中。如果您的显示器未正确校准,您可能无法在计算机显示器上看到它。
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.