用DirectGraphics.getPixels(int[] ..., TYPE_INT_xxxx_xxxx) 得到的颜色值不准确。因为nokia的手机内部使用的是TYPE_USHORT_565_RGB的格式,在getPixels(int[])时需要进行映射。更严重的是,不同位置的同种颜色的点,get出来的颜色值也可能不一样(遇到过了这种情况,但还没发现规律。如果你知道,请告诉我:)。比如白色(0xffffffff),getPixel(int[])得到的结果是0xf8fcf8。
其实MIDP2.0的Image.getRGB()也有一样的问题,例如用wtk2.2, 所有的颜色都会被映射到"4096色",即0xabcdef,其中a=b,c=d,e=f。并且MIDP2.0中有相应的说明:
The returned values are not guaranteed to be identical to values from the original source, such as from createRGBImage or from a PNG image. Color values may be resampled to reflect the display capabilities of the device (for example, red, green or blue pixels may all be represented by the same gray value on a grayscale device). On devices that do not support alpha blending, the alpha value will be 0xFF for opaque pixels and 0x00 for all other pixels (see Alpha Processing for further discussion.) On devices that support alpha blending, alpha channel values may be resampled to reflect the number of levels of semitransparency supported.
Nokia的文档里没有说明.
nokia ui中,可以通过DirectGraphics.getNativePixelFormat()来得到系统的像素格式,6600返回的是565(DirectGraphics.TYPE_USHORT_565_RGB),实际测试中,USHORT_4444_ARGB也是可用的。
getPixel()和getRGB()的问题
最新推荐文章于 2022-10-26 19:12:10 发布