Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Faster RGB Inversion Function

Status
Not open for further replies.

darrellblackhawk

Programmer
Aug 30, 2002
846
US
Code:
* Function:	InvertIntRGB()
* Descript:	Inverts an integer RGB value
* Pass:		R,G,B (Output i.e. Pass in by reference)
*			They will contain the numeric (dec)
*			RGB values upon return
*
*			bDecString (Input)
*			If .t., the function will return a
*			comma separated, zero padded decimal
*			string.
*
* Note:		The real numeric values are in R,G,B upon exit
*
* 			Useful to perform masking and other
*			paint functions
function InvertIntRGB
  lparam I, R, G, B, bDecString
  local cRGB

  =IntToRGB(bitxor(I,16777215),@R,@G,@B)

  cRGB = ;
    right(trans(R,"@0"),2) + ;
    right(trans(G,"@0"),2) + ;
    right(trans(B,"@0"),2)

  return iif(bDecString, ;
    padl(trans(R),3,"0")+","+ ;
    padl(trans(G),3,"0")+","+ ;
    padl(trans(B),3,"0"), ;
    cRGB)

endfunc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top