Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hex value
Message
 
À
01/08/1999 11:59:46
Senna Dwipayana
Indo Rebel Apparel Cv
Bandung, Indonésie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00248674
Message ID:
00248676
Vues:
25
>Hi All,
>I need to convert hex color value to RGB Value, is there any code can do it ?
>
>TIA

Hi Senna,

You can convert the hexidecimal value directly, depending on what the source of the value is. For example, lndec = 0xFD, will assign the value 253 to lndec. If, however, you have the hex value as a string then lndec = EVALUATE('0x' + "FD"), will produce the same result.

Now, there are a couple of ways to retrieve the individual color values. Easiest, is to use the RGBComp() function in Foxtools. Another way is to use the bit functions to mask out the individual values. Here's how:
* Using RGBComp - Requires Foxtools
STORE 0 TO lnred, lngreen, lnblue
* lncolor is the color to break down
= RGBComp(lncolor, @lnred, @lngreen, @lnblue)
* Using the bit manipulation functions
lnblue = BITAND(lncolor, 255)
lncolor = BITRSHIFT(lncolor, 8)
lngreen = BITAND(lncolor, 255)
lncolor = BITRSHIFT(lncolor, 8)
lnred = BITAND(lncolor, 255)
Additionally, there are variations on the bit shifting above and also you could use integer division.

hth,
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform