Code archives/BlitzPlus Gui/R, G, B To LockedFormat Short/Int
This code has been declared by its author to be Public Domain code.
Download source code
| This is an example of how you go about converting 0-255 r,g,b elements into 1 Short or Integer. Pass the mode as returned by "LockedFormat()" along with the colour you wish to convert and it will return the correct Short/Int.|
Remember: Modes 1, and 2 you need to PokeShort, otherwise it's PokeInt.
Function ConvertRGB(r,g,b,Mode=0) Select Mode Case 1 Col=((r/8) Shl 11) Or ((g/4) Shl 5) Or (b/8) Return Col Case 2 Col=((r/8) Shl 10) Or ((g/8) Shl 5) Or (b/8) Return Col Default Col=(r Shl 16) Or (g Shl 8) Or b Return Col End Select End Function
Code Archives Forum