getting rgb values from a color

jonnie_c

Registered User.
Local time
Today, 20:22
Joined
May 11, 2002
Messages
25
i am trying to figure out a way to get the RGB values from a color.
(e.g. if the ForeColor of a label is Green (65280), then i would like to find out that this is (0,255,0)).
can anybody help me this this or give me an idea?
 
Found this in a Google search:

"Where each red/green/blue level is from 0 to 255, add together
Red+Green*256+Blue*65536, and that's your color value."

If it's correct, think that finding the correct formula to reverse the process
will be both educational and illuminating.

Good luck and please post back.
 
thank you very much for your prompt reply. the formula you provided looks to be legit and i will try to work it out from that. I will post the solution when i get it
smile.gif
 
this is what i used:
blue = num / 65536
green = (num Mod 65536) / 256
red = (num Mod 65536) Mod 256

seems to work except my green is sometimes one number off depending on the values of red and blue (i have never been the best when it comes to math). any ideas why?
 

Users who are viewing this thread

Back
Top Bottom