How does one convert 16-bit RGB565 to 24-bit RGB888?

后端 未结 8 863
深忆病人
深忆病人 2020-11-27 03:22

I’ve got my hands on a 16-bit rgb565 image (specifically, an Android framebuffer dump), and I would like to convert it to 24-bit rgb888 for viewing on a normal monitor.

8条回答
  •  春和景丽
    2020-11-27 04:00

    You could shift and then or with the most significant bits; i.e.

    Red 10101 becomes 10101000 | 101 => 10101101
        12345         12345---   123    12345123
    

    This has the property you seek, but it's not the most linear mapping of values from one space to the other. It's fast, though. :)

    Cletus' answer is more complete and probably better. :)

提交回复
热议问题