Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting getcolor() to rgb
Message
From
28/07/2006 16:33:27
 
 
To
28/07/2006 15:44:28
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01141334
Message ID:
01141376
Views:
20
>Is there a way to convert a getcolor value to the 3 values from RGB?

here is a function that I wrote:
************************************************************************************************
*  Routine for returning the individual RBG values from a color value
*
FUNCTION GetRGBValues
LPARAMETERS pnRGBValue
LOCAL lcRGBString
lcRGBString = GetRValue(pnRGBValue) + "," + GetBValue(pnRGBValue) + "," + GetGValue(pnRGBValue)
RETURN lcRGBString


PROCEDURE GetRValue
	LPARAMETER pnRGBColorValue
	LOCAL lnRValue, lnNdx
	lnRValue = pnRGBColorValue
	FOR lnNdx=8 TO 31
		lnRValue = BITCLEAR(lnRValue,lnNdx)
	ENDFOR
	RETURN TRANSFORM(INT(lnRValue))
ENDPROC


PROCEDURE GetGValue
	LPARAMETER pnRGBColorValue
	LOCAL lnBValue, lnNdx
	lnBValue = BITRSHIFT(pnRGBColorValue,16)
	FOR lnNdx=8 TO 31
		lnBValue = BITCLEAR(lnBValue,lnNdx)
	ENDFOR
	RETURN TRANSFORM(INT(lnBValue))
ENDPROC


PROCEDURE GetBValue
	LPARAMETER pnRGBColorValue
	LOCAL lnGValue, lnNdx
	lnGValue = BITRSHIFT(pnRGBColorValue,8)
	FOR lnNdx=8 TO 31
		lnGValue = BITCLEAR(lnGValue,lnNdx)
	ENDFOR
	RETURN TRANSFORM(INT(lnGValue))
ENDPROC
Previous
Reply
Map
View

Click here to load this message in the networking platform