#ff0000 <-> 255,0,0

Blitz3D Forums/Blitz3D Programming/#ff0000 <-> 255,0,0

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here is how you can break apart a hex color string into the individual RGB values
Graphics 640,480
hex_value=$ffaabbcc
Print Hex((hex_value And $FF0000) Shr 16)
Print Hex((hex_value And $FF00) Shr 8)
Print Hex(hex_value And $FF) 		
MouseWait()
End


In the above example, the first $ff is the alpha value. Then are listed the RGB values, $aa, $bb, $cc.

Since the Hex command converts numeric hex values into alphanumeric string values, in case you want to numerically alter the RGB values (something you cannot do to a string), then for actual usage, instead of Print..., do something like (leaving off the "Hex" command):
Graphics 640,480
hex_value=$ffaabbcc
my_red = ((hex_value And $FF0000) Shr 16)
my_green = ((hex_value And $FF00) Shr 8)
my_blue = (hex_value And $FF) 		
MouseWait()
End