Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
 To: mk sharma
  Where is mk sharma?
 mumbai
 India
 mk sharma
 Tags
Subject: RE: rgb value
Thread ID: 209705 Message ID: 209722 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Tuesday, December 30, 2008 3:49:58 PM         
   


> hot calculate the value of RGB()
>
> rgbvalue=RGB(61,100,186)
>
> ?rgbvalue
>
> result = 12215357
>
> what is the calculation method to get the value 12215357
>
> warm regards,
> mk.


any natural color is a mix of three colors red,green,blue colors.With these three colors can construct any color.
lnColor=GETCOLOR()                            &&get  any color
lnRed=BITAND(lnColor,255)                     &&red component  R
lnGreen=BITAND(BITRSHIFT(lnColor,8),255)      &&green component G
lnBlue=BITAND(BITRSHIFT(lnColor,16),255)      &&blue component  B
nColor = lnRed + lnGreen*256 + lnBlue*256*256 &&method to calculate the rgb color

messagebox("RGB("+trans(lnRed)+","+trans(lnGreen)+","+trans(LnBlue)+") ="+trans(nColor),0+32)


you can work arround with three other methods
always use
nColor = lnRed + lnGreen*256 + lnBlue*256*256

to return the RGB color.
**********************
method2
=ycolor(getcolor())

function ycolor
lparameters tnColor
local lnRed,lnGreen,lnBlue
lnRed	= bitrshift(bitand(tnColor, 0x0000FF),0)
lnGreen	= bitrshift(bitand(tnColor, 0x00FF00),8)
lnBlue	= bitrshift(bitand(tnColor, 0xFF0000),16)
messagebox("RGB("+trans(lnRed)+","+trans(lnGreen)+","+trans(lnBlue)+")",0+32+4096)
return trans(lnRed)+","+trans(lnGreen)+","+trans(lnBlue)

***********************
method3
If you can use gdiPlus (download at VFPX) this is the code to obtain the R,G,B of any color
*do system.app  &&(system.app must be on any folder.Execute it before)
 with _screen.system.drawing
     with .color.fromRGB(getcolor())
	red=.r
	green=.g
	blue=.b 
     endwith
endwith
messagebox(trans(red)+"  "+trans(green)+"   "+trans(blue) )

*********************
metyhod4 foxtools.fll
set library to home()+"\foxtools" addi
xcolor=getcolor()
clea
nRedVal=0
nGreenVal=0
nBlueVal=0
=RGBComp( xcolor, @nRedVal, @nGreenVal, @nBlueVal )
messagebox("color="+trans(xcolor)+"----RGB("+trans(nRedval)+","+trans(nGreenVal)+","+trans(nBlueVal)+")")


regards

ENTIRE THREAD

rgb value Posted by mk sharma @ 12/30/2008 2:41:02 PM
RE: rgb value Posted by Cetin Basoz @ 12/30/2008 2:48:16 PM
RE: rgb value Posted by Yousfi Benameur @ 12/30/2008 3:49:58 PM