Expert Software Company : News

joi, 13 mai 2010

Convert Color to RGB

lnRGBColor = RGB(64,128,255)
loColor = Color2RGB(lnRGBColor)
? lnRGBColor, loColor.cRGB
? loColor.nR, loColor.nG, loColor.nB
RETURN
* Converts color number into RGB components and RGB() string
FUNCTION Color2RGB
LPARAMETERS tnColor
* nColor = nR + nG*256 + nB*256*256

LOCAL loColor
loColor = CREATEOBJECT("Empty")
ADDPROPERTY(loColor, "nR", BITAND(tnColor, 0xFF))
ADDPROPERTY(loColor, "nG", BITAND(BITRSHIFT(tnColor, 8), 0xFF))
ADDPROPERTY(loColor, "nB", BITAND(BITRSHIFT(tnColor, 16), 0xFF))
ADDPROPERTY(loColor, "cRGB", "RGB(" + ;
TRANSFORM(loColor.nR) + "," + ;
TRANSFORM(loColor.nG) + "," + ;
TRANSFORM(loColor.nB) + ")")
RETURN loColor

Niciun comentariu:

Trimiteți un comentariu