Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert RGB INTO Hexa Value
Message
From
16/07/2007 09:32:20
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
16/07/2007 09:20:09
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01240526
Message ID:
01240660
Views:
17
>>>Bernhart,
>>>
>>>I don't believe you will have any speed gain by using hex over integer, so I suggest use integer all the time. If you try ?rgb(0,255,255) in the command window, you will see 16776960, so instead of rgb(x,y,z), use
>>>the value which the rgb() function gives.
>>
>>What is the difference between a hex and an integer, except the notation?
>
>Nothing really....! My point was that instead of spending a lot of time to try to save a few milliseconds, I would rather use the value returned by RGB() directly. There must be a reason why RGB() returns integer values, and not hex.

OK, I'll repeat: hex is integer is hex is integer is hex is integer (*).

Hex is not a different type of number. It's a way of representing one. Tracy is the same Tracy no matter how many different cameras you take her pictures with. My language reads the same words regardless of whether they were printed in Cyrillic or Latin.

Rgb() returns an integer. Hex returns an integer. Try
?0xcecece
and you'll get an integer. Even better, if
?0x0000ff==255
returns a .f. I promise to drink an American beer.

So, why does rgb() return an integer? Because it always did. Why is it not displaying the result in hex? Because Fox has displayed all numeric results in base ten since its inception. Want it to display in hex? Use trans(rgb(), "@0")

Put two objects on a form. Set one's color to rgb(144,144,144), the other one's to 0x909090. Check their colors in the debugger. If they are different, I'll drink a Corona.

----
(*) actually, you can write fractions in hex as well, if you want. The code to calculate the hex digits to the right of the heximal point is trivial to write.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform