代码之家  ›  专栏  ›  技术社区  ›  bobobobo

黑莓手机上的RGB 565格式

  •  0
  • bobobobo  · 技术社区  · 15 年前

    在示例代码中,RIM将位图视为 565 RGB format ,而不是通常的 8888 ARGB format 你上了桌面,

    例如:

    net.rim.device.api.system.Bitmap bitmap =
      net.rim.device.api.system.Bitmap.getBitmapResource( "BlackBerry.png" );
    GLUtils.glTexImage2D(gl, 0, GL10.GL_RGB, GL10.GL_UNSIGNED_SHORT_5_6_5, bitmap, null);
    

    但是,磁盘上的位图是8888 ARGB——为什么示例代码使用565 RGB,我可以使用8888 ARGB,每像素4字节,而不是每像素2字节?

    1 回复  |  直到 15 年前
        1
  •  0
  •   bobobobo    15 年前

    好吧,我想我明白了。

    GLUtils.glTexImage2D(gl, 0, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, bitmap, null);
    

    这很有效,尽管看起来不应该这样(似乎函数会自动处理 Bitmap 如有需要,则为R5G6B5;如有需要,则为A8R8G8B8。)

    还有glTexImage2D(http://www.blackberry.com/developers/docs/5.0.0api/javax/microedition/khronos/opengles/GL10.html#glTexImage2D(int,int,int,int,int,int,int,int,java.nio.Buffer))比GLUtils版本低一点。