How can I convert a hex rgb color value to non hex
I want people to be able to enter a hex color value (like from Photoshop)and for this color value to be shown in the color selector dialogue.
such as : someone enters FFFFFF into the masked edit object, presses enter and suddenly the selected color in the color selector is white.
any ideas?
thanks
Re: How can I convert a hex rgb color value to non hex
To get a hex value from a value, use:
Hexvalue = Hex$(Val(<YourValue>))
To convert a Hex value to a normal value, simply use this expression:
Value = Val(<YourHexvalue>)
For example will Val("0x64") produce 100
Re: How can I convert a hex rgb color value to non hex
Actually: Val("0x"+text) should do the trick. At least to give you a full RGB number. Then use GetRed(), GetGreen(), GetBlue() to get the three separate colours from it.
Re: How can I convert a hex rgb color value to non hex
Hmm.. I tried:
set selected color of color selector
Val("0x"+getData$( "masked edit" ))
and it isn't giving me correct colors.. What am I doing wrong?
Re: How can I convert a hex rgb color value to non hex
Quote:
Originally Posted by HolyMonkey
Hmm.. I tried:
set selected color of color selector
Val("0x"+getData$( "masked edit" ))
and it isn't giving me correct colors.. What am I doing wrong?
Quote:
Originally Posted by Dynasoft
Then use GetRed(), GetGreen(), GetBlue() to get the three separate colours from it.
Or, you can use Mid$() to get each part of the hex number and val them individually. I'll let someone else example that one.
Re: How can I convert a hex rgb color value to non hex
I'll report back if I figure this out, but so fat nothing I try reproduces the corect color. :(
There wouldnt happen to be an extension that converts hex color values to this sort of RGB value that the color-selector wants (and back) is there? ;)
Re: How can I convert a hex rgb color value to non hex
Val("0x" + Mid$(getData$( "masked edit" ), 0, 2))
Val("0x" + Mid$(getData$( "masked edit" ), 2, 2))
Val("0x" + Mid$(getData$( "masked edit" ), 4, 2))
GetRGB(Val("0x" + Mid$(getData$( "masked edit" ), 0, 2)), Val("0x" + Mid$(getData$( "masked edit" ), 2, 2)), Val("0x" + Mid$(getData$( "masked edit" ), 4, 2)))
(MMF2 needs macros badly)
Re: How can I convert a hex rgb color value to non hex
but I dont want the red, green, and blue seperately, I want the RGB value (one number)
Sorry if I'm being stupid here, but the color selector wants one number, not the three seperate values... what is the full formula I use to take FFFFFF and convert it to the RGB value that the color selector object needs so that it displays white?
Re: How can I convert a hex rgb color value to non hex
There's a formula in bold at the bottom of my post.
Re: How can I convert a hex rgb color value to non hex
I apreciate it very much Jamie (and everyone else) BUT even this formula is not giving me the correct color... I need to check the other related code and see if I'm introducing another bug elsewhere that is corrupting the numbers....
Has anyone tried or is anyone willing to try making an actual example to make sure the formula effects the color selector as intended?