在ICS位图装载了错误的像素格式 [英] Bitmaps on ICS are loaded with wrong pixel format

查看:181
本文介绍了在ICS位图装载了错误的像素格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了以下问题。当任何位图是从资源由冰淇淋三明治运行的应用程序加载时,它很可能会呈现不正确,就好像它已经德coded到格式,这不同于当前窗口的格式,与没有施加抖动。但是,两者的解码格式和窗口形式已显式设置:

I encountered the following problem. When any bitmap is loaded from resources by an application running on Ice Cream Sandwich, it will likely be rendered incorrectly as if it has been decoded to the format, which differs from the current window format, with no dither applied. However, both, the decoding format and window format have been explicitly set:

BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.RGBA_8888;

getWindow().setFormat(PixelFormat.RGBA_8888);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);

下面是从的测试应用截图:// WWW .curious-creature.org / 2010/12/08 /位图质量分带和 - 抖动/>这篇文章与ICS 4.0.3(它给出了HTC HD2相同的结果)在模拟器中运行:

Here are screenshots of the test app taken from this article running on Emulator with ICS 4.0.3 (it gives the same results on HTC HD2):

RGBA_8888 (32位)的窗口格式,各种位图解码格式:

RGBA_8888 (32-bits) window format, various bitmap decoding formats:

RGB_565 (16位)的窗口格式,各种位图解码格式:

RGB_565 (16-bits) window format, various bitmap decoding formats:

几件事情可以注意到:

  • 抖动标志没有被考虑不时;
  • 的ICS默认窗口格式似乎是 RGB_565 ;
  • 唯一值得期待的梯度将出现 RGB_565 窗口格式 RGBA_8888 位图解码格式
  • Dithering flag is not taken into account from time to time;
  • The default window format for ICS seems to be RGB_565;
  • The only good looking gradient appears with RGB_565 window format and RGBA_8888 bitmap decoding format.

这个问题也有报道这些问题,但仍然没有办法可以解决的有:

This problem has also been reported in these questions, but still no solution can be found there:

<一个href="http://stackoverflow.com/questions/8636388/gradient-compatibility-issue-ics-defaults-to-fewer-colors-than-all-the-$p$pviou">Gradient兼容性问题 - ICS默认的颜色比Android

Android中可怕的背景图像质量

该quistion是,如何处理所有这些格式在ICS,更precise,如何使 RGBA_8888 ICS负载位图格式,以及如何设置窗口格式 RGBA_8888 所以这些位图正确显示?

The quistion is, how to deal with all these formats on ICS, to be more precise, how to make ICS load bitmaps with RGBA_8888 format and how to set the window format to RGBA_8888 so these bitmaps are displayed correctly?

推荐答案

我绝对可以向你保证,窗口的默认格式为RGB888。这实际上是做了默认的Andr​​oid 2.3,而且由于他们一直没有改变。在这一点上,我会考虑RGB565窗口去precated,因为基本上目前所有设备都32bpp的显示。

I can definitely assure you that the default window format is RGB888. This was actually made the default in Android 2.3, and has not been changed since them. At this point I would consider RGB565 windows deprecated, since basically all current devices have 32bpp displays.

你说你也会在HTC HD2上运行这一点,但因为没有正式构建了它,我会怀疑你有什么结果。

You say you are also running this on the HTC HD2, but since there is no official build for it I would be suspicious of any result you get there.

我觉得仿真器仍然可以使用16bpp的显示,所以在这方面我不会依赖于它的结果完全符合你通常会在设备上看到的。

I think the emulator may still use 16bpp displays, so in this area I would not rely on its results to exactly match what you will typically see on devices.

这篇关于在ICS位图装载了错误的像素格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆