Results 1 to 3 of 3

Thread: Determine Colour Value (Level of Darkness not 16777215 for white!)

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    England
    Posts
    34

    Question 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

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    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.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    England
    Posts
    34
    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
  •  



Click Here to Expand Forum to Full Width