getPixel()和getRGB()的问题

用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也是可用的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值