Board index » delphi » Getting RGB Values from a TColor ?

Getting RGB Values from a TColor ?

Hello All,

  How can I get the individual RGB values from a tcolor? If I had a tcolor
var that had its color set previously to 127,122,133 how could I know this
and get these values from the current color? Is there a standard function I
cannot find for doing this?

  Thanks ahead of time!

  Dave.

 

Re:Getting RGB Values from a TColor ?


Quote
Dave wrote:
>   How can I get the individual RGB values from a tcolor? If I had a tcolor
> var that had its color set previously to 127,122,133 how could I know this
> and get these values from the current color? Is there a standard function I
> cannot find for doing this?

  First, use the ColorToRGB function. Then use GetRValue, GetGValue and
GetBValue to get the RGB components.

Cheers,
--
Marko Peric       lonew...@tig.com.au
http://homepages.tig.com.au/~lonewolf

Re:Getting RGB Values from a TColor ?


tcolor is an integer as :

 $ddbbggrr
where dd is zero
      bb is the blue byte
      gg is the green byte
      rr is the red byte

Rene

Quote
Dave wrote:

> Hello All,

>   How can I get the individual RGB values from a tcolor? If I had a tcolor
> var that had its color set previously to 127,122,133 how could I know this
> and get these values from the current color? Is there a standard function I
> cannot find for doing this?

>   Thanks ahead of time!

>   Dave.

--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com

Re:Getting RGB Values from a TColor ?


Quote
Rene Tschaggelar <tschagge...@access.ch> wrote in message

news:373428A4.FC01E807@access.ch...

Quote
> tcolor is an integer as :
>  $ddbbggrr
> where dd is zero

Actually "dd" can be $00, $01, $02, $80 or $FF.  See the explanation under
TColor at
www.efg2.com/lab/library/Delphi/Graphics/VCLRTL.htm

efg
_________________________________
efg's Computer Lab:       www.efg2.com/lab
Delphi Books:  www.efg2.com/lab/TechBooks/Delphi.htm

Earl F. Glynn     E-Mail:  EarlGl...@att.net
Overland Park, KS  USA

Re:Getting RGB Values from a TColor ?


Quote
> >   How can I get the individual RGB values from a tcolor? If I had a tcolor
> > var that had its color set previously to 127,122,133 how could I know this
> > and get these values from the current color? Is there a standard function I
> > cannot find for doing this?

>   First, use the ColorToRGB function. Then use GetRValue, GetGValue and
> GetBValue to get the RGB components.

Whoa, thats absolutely cool ! When I tried to isolate Red, Green and Blue values
out of a TColor (in $0000BBGGRR), then at first:

I copied the Hexnumber to a string and copied the needed pair of numbers out of
it and transformed the number back to a hex. But after a time, this seemed even
to me not only slow (consider pixel amount of DIN 4 Bitmap) but also a cheap
trick. So second:

I shifted the unneeded hexnumbers (shl and shr) out and then filled it with
zeroes by shifting it back. Took some time for me to get this idea. Went faster
now.

Now I will try GetXValue as soon as I can.

Other Threads