Board index » cppbuilder » Getting TColor variable from RGB

Getting TColor variable from RGB

How to get a TColor variable when we know the 3 values of the RGBTRIPLE?
Is there an inverse of ColorToRGB  ?

Thanks
Xavier

 

Re:Getting TColor variable from RGB


have a look at RGB() macro.

Ciao

Re:Getting TColor variable from RGB


 Like this?

HDC        hDC = GetDC( Handle);
COLORREF   Col = GetNearestColor(hDC,RGB(R,G,B));
 TColor    Tcol = static_cast<TColor>(Col);

Bart

"Xavier" <x...@mail.cpod.fr> schreef in bericht news:3c8ccecd_2@dnews...

Quote
> How to get a TColor variable when we know the 3 values of the RGBTRIPLE?
> Is there an inverse of ColorToRGB  ?

> Thanks
> Xavier

Re:Getting TColor variable from RGB


The easiest way is generally:

// these could be bytes instead of ints
int redv; // initialized elsewhere to your tristimulus R value
int greenv; // initialized elsewhere to your tristimulus G value
int bluev; // initialized elsewhere to your tristimulus B value
...
TColor colorVar = TColor( RGB(redv, greenv, bluev) );

Quote
> How to get a TColor variable when we know the 3 values of the RGBTRIPLE?

[snip]

Zack.

Other Threads