VBGamer |
|||||||||||||||||||||||||||
RE: 16bit colour - (Newbieish) Corre (1 reply, 0 views) (2000-Aug-28) If you're using 555 mode (actually 15 bits) you'll do like this (I'm assuming that you want to specify the red, green and blue components in the range 0-255):
Function RGB15(Red As Byte, Green As Byte, Blue As Byte) As Integer
'Convert colour values from the range 0-255 to the range 0-31
Red = Red \ 8
Green = Green \ 8
Blue = Blue \ 8
'Calculate color
RGB15 = Blue + Green * 2 ^ 5 + Red * 2 ^ 10
End Function
If you're using 565 mode, you'll do something like this:
Function RGB16(Red As Byte, Green As Byte, Blue As Byte) As Integer
'Convert colour values from the range 0-255 to the range 0-31
Red = Red \ 8
Blue = Blue \ 8
'Convert colour value from the range 0-255 to the range 0-63
Green = Green \ 4
'Calculate color
RGB16 = Blue + Green * 2 ^ 5 + Red * 2 ^ 11
End Function
hth
/Corre
|