Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Code to create a contrasting color
Message
De
25/10/2010 18:58:33
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01486509
Message ID:
01486932
Vues:
58
>>>>I have an app where I am cropping images. Everything works great thanks to GdiPlusX. I create a shape object with MouseDown / MouseMove to mark the crop area. My question is how to get the contrasting color so the shape border will show against all the different colors in the image. I know I can get the color at the mouse down point but how do I get a light color if the image is dark, etc. I assume this is an easy one if you know what you are doing.
>>>
>>>What if you use XOR operation to draw the selection box border?
>>
>>
>>I looked at that but how would I use it. I have one value; the current color. What would be the 2nd value?
>
>Try
>
>lnNewColor = BITXOR(lnCurrentColor, 0xFFFFFFFF)
>
Actually only 0xFFFFFF because the colors are three-byte integers... but this will not be the contrasting color. Something that's medium bright, say 0x7f7f7f will have 0x808080 as its opposite color, and the difference is one in each of r, g and b. For actual contrast I'd rather add a fixed number to each of components - something between 90 and 127 - and then discard the overflow bit. In the case of 7f7f7f, 127+90=217, so we get 0xd9d9d9. Of course, each of r, g, b would need to be calculated %256.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform