怎么把ARGB1555 转化为 ARGB4444

http://14546904.blog.hexun.com/56248561_d.html

注:0xF800,0x07E0,0x001F是 RGB565的bit mask
    0xFF0000,0xFF00,0xFF是RGB888的bit mask
RGB565--->RGB888
Color为SHORT
Red=(unsigned char)((Color&0xF800)>>8);
Green=(unsigned char)((Color&0x07E0)>>3);
Blue=(unsigned char)((Color&0x1F)<<3);

RGB888---> RGB565
COLOR为INT
Red=(unsigned char)((Color&0xFF0000)>>19);
Green=(unsigned char)((Color&0xFF00)>>10);
Blue=(unsigned char)((Color&0xFF)>>3);
 
 
1.RGB888 ->RGB555
#define RGB15(r, g, b) ( ((r>>3)<<10) | ((g>>3)<<5) | (b>>3) ) // 5:5:5 mode

#define R555(p) ( (BYTE) ( (p>>11) ) )

#define G555(p) ( (BYTE) ( (p>>5)&63 ) )

#define B555(p) ( (BYTE) ( (p)&31 ) )

 

2.RGB888 -> RG B565
#define RGB16(r, g, b) ( ((r>>3)<<11) | ((g>>2)<<5) | (b>>3) ) // 5:6:5 mode

#define R565(p) ( (BYTE) ( (p>>11) <<3) )

#define G565(p) ( (BYTE) ( (p>>5)&63 <<2) )

#define B565(p) ( (BYTE) ( (p)&31 <<3) )

 

3.ARGB8888 -> ARGB1555
#define ARGB1555(a,r,g,b) ( (a<<15) | ((r>>3)<<10) | ((g>>3)<<5) | (b>>3) )

 

4.ARGB8888 -> ARGB4444
#define ARGB4444(a,r,g,b) ( ((a>>4)<<12) | ((r>>4)<<8) | ((g>>4)<<4) | (b>>4) )

 

RGB 5:6:5 or 5:5:5 --> 5:6:5 or 5:5:5

#define RGB555_BYTE(r,g,b) ( ((r)<<10) | ((g)<<5) | (b) ) // 5:5:5

#define RG B565_BYTE(r,g,b) ( ((r)<<11) | ((g)<<5) | (b) ) // 5:6:5
 
在c#里怎么做?
 
ARGB1555 rgb1555;
ARGB4444 rgb4444;
rgb4444 = ((rgn1555>>15)<<12)|(((rgb1555&0x9c00)>>10)<<8)|(((rgb1555&0x03E0)>>5)<<4)|
((rgb1555&0x001F)>>1)

你可能感兴趣的:(怎么把ARGB1555 转化为 ARGB4444)