Logman Posted March 25, 2009 Share Posted March 25, 2009 (edited) From time to time I need to convert 24bit RGB color depth to 16bit depth, exactly to RGB555 (15bit: rrrrrggggg0bbbbb) and vice versa. I wrote a two simple conversion functions. Maybe there is a faster way for converting color depth, will anyone know (GDI, WinAPI)?Func _ConvertRGB_24b_to_16b555($R, $G, $B) $R = BitShift($R, 3) $G = BitShift($G, 3) $B = BitShift($B, 3) $R = BitShift($R, -11) $G = BitShift($G, -6) Return Hex(BitOR($R, $G, $B), 4) EndFunc Func _ConvertRGB_16b555_to_24b($16b, ByRef $R, ByRef $G, ByRef $B) $R = BitShift($16b, 11) $R = Hex (BitShift($R, -3), 2) $G = BitAND ($16b, "0x7C0") ;mask $G = Hex (BitShift($G, 3), 2) $B = BitAND ($16b, "0x1F") ;mask $B = Hex (BitShift($B, -3), 2) EndFunc Edited March 25, 2009 by Logman Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now