|
-
Feb 19th, 2003, 12:32 PM
#1
Thread Starter
Member
Determine Colour Value (Level of Darkness not 16777215 for white!)
Hi,
I am trying to determine the value of a colour (any colour), so that I can tell how dark/light this colour is. Unfortunately the long value in vb ie. 16777215 for White does not tell you accurately enough if a colour is dark or light.
I want to be able to change the colour of text to white if the back colour has been selected to dark.
I have searched the web for a couple of hours now and cannot find anything. Your help would be very welcome.
Thanks
TC
-
Feb 19th, 2003, 01:33 PM
#2
Not sure how you would determine a dark color from light but this might help.
You can separate the RGB components from a color value using this code
Code:
Dim lngColor As Long
Dim Red As Long
Dim Green As Long
Dim Blue As Long
lngColor = 16777215
Red = lngColor And &HFF&
Green = (lngColor \ &H100&) And &HFF&
Blue = (lngColor \ &H10000) And &HFF&
You can convert the RGB values to Hue, Saturation or Luminance. Search Google for the code.
-
Feb 19th, 2003, 01:43 PM
#3
Thread Starter
Member
Hi brucevde,
Thanks for your posting but I've looked at Hue, Saturation and Luminance. None of them determine how dark/light the colour is. That is something called the 'colour value' but it doesn't relate to the value in vb.
Thanks anyway
TC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|