How i can set rgb color?

11.1k views Asked by At

How i can set rgb color to anything component? FireMonkey, C++ Builder XE8. I have used this code but its useless...

Rectangle1->Fill->Color = RGB(255, 50, 103);
Rectangle1->Fill->Color = (TColor)RGB(255, 50, 103);

May be i must use RGBA? But i dont know how to do it.

I did it.

UnicodeString s ; 
s =  "0xFF" ; 
s +=  IntToHex ( 255 ,  2 ); 
s +=  IntToHex ( 50 ,  2 ); 
s +=  IntToHex ( 103 ,  2 ); 
Rectangle1 -> Fill -> Color  =  StringToColor ( s );
1

There are 1 answers

1
Anthony Burg On

This function will allow you to convert int specified RGB values to a TAlphaColor, which is what is used by FireMonkey.

TAlphaColor GetAlphaColor (int R, int G, int B)
{
    TAlphaColorRec acr;
    acr.R = R;
    acr.G = G;
    acr.B = B;
    acr.A = 255;
    return acr.Color;
}