[SWU]怎么将RGB888转化为RGB565

[SWU]如何将RGB888转化为RGB565?
求代码参考,例如0xAABBCC如何转化为RGB565?

------解决方案--------------------

unsigned short int RGB888toRGB565(unsigned long int pixel)
{
    int r = (pixel >> 16) & 0xFF;
    int g = (pixel >> 8) & 0xFF;
    int b = pixel & 0xFF;

    unsigned short B = (b >> 3)                 & 0x001F;
    unsigned short G = ((g >> 2) << 5)      & 0x07E0;
    unsigned short R = ((red >> 3) << 11) & 0xF800;

    return (unsigned short int) (R 
------解决方案--------------------
 G 
------解决方案--------------------
 B);
}