Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert RGB INTO Hexa Value
Message
From
16/07/2007 09:48:37
 
 
To
16/07/2007 09:32:20
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01240526
Message ID:
01240667
Views:
20
>>>>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.

Let's not spend time arguing definitions. An integer is a whole number, period. In VFP an integer has a minimum value and a maximum, but that's VFP's own definiotin, or limitation if you want. An integer is by us humans counted in "groups of 10", usually called decimal numbers. A hex value is also a whole number, but counted in "groups og 16", or hexadecimal meaning 16 (hex=6, deci=10). "Group of 10" is not technically the same as "group of 16", but that's really not important. I have a university degree in mathematics, so I know very well what I am talking about. However, it is more than 30 years since I graduated, so I don't remember all the different technincal definitions in detail anymore. But I remember the basic, and an integer value is NOT the same as a hex value. But all programming languages I know, has a transparent two-way conversion, meaning that they can handle both integer values and hex values easily.

NB! I also don't have the ability to explain very well what I mean in english, so please be forgiving.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform