Page 1 of 1

converting from 24bit rgb to 16bit 565 and back

Posted: Tue Jul 01, 2008 11:37 pm
by idle
might save some google time if you ever want to do this.

Code: Select all


;RGB ->16bit

wCout.w
lCout.l

r = Red(color1) >> 3 
g = Green(color1) >> 2 
b = Blue(color1) >> 3
              
wCout = (r << 11) | (g << 5) | b;

;16 bit -> RGB 

color1 = wCout & $FFFF) 
        
r =(((color1 & $F800) >> 11) <<3)
g =(((color1 & $07E0) >> 5) <<2 )
b =((color1 & $001f) <<3 )
            
lCout = RGB(r,g,b)