LOCAL lnRgb, lnRed, lnGrn, lnBlu lnRgb = RGB(255,192,128) breakout_rgb(lnRgb, @lnRed, @lnGrn, @lnBlu) lcColor = "#" + RIGHT(TRANSFORM(lnRed, "@0"), 2) + RIGHT(TRANSFORM(lnGrn, "@0"), 2) + RIGHT(TRANSFORM(lnBlu, "@0"), 2) WAIT WINDOW lcColor FUNCTION breakout_rgb LPARAMETERS tnRgb, tnRed, tnGrn, tnBlu tnRed = BITAND(tnRgb, 0xff) tnGrn = BITAND(BITRSHIFT(tnRgb, 8), 0xff) tnBlu = BITAND(BITRSHIFT(tnRgb, 16), 0xff)Logically it is this operation:
int lnRgb, lnRed, lnGrn, lnBlu;
lnRed = (lnRgb & 0xff);
lnGrn = ((lnRgb >> 8) & 0xff);
lnBlu = ((lnRgb >> 16) & 0xff);
// Right now, values are broken out
// I'm not sure in C# how to convert them to hex forms. In C, you could use this:
char color[32];
sprintf(color, "#%02x%02x%02x", lnRed, lnGrn, lnBlu);