Does there exist an equivalent function in FMX for ColorToRGB
?
You can use TAlphaColorRec to get R,G,B or longint values (in Delphi XE3+FireMonkey2 - I'm not sure about XE2)
Try this, add two buttons and a TRectangle to a Firemonkey form and add these for the onClick events:
procedure TForm1.btnBrownClick(Sender: TObject);
var
r: System.Byte;
aColor: TAlphaColor;
rgbValue: longint;
begin
aColor:= TAlphaColorRec.Brown; //$A52A2A
r:= TAlphaColorRec(aColor).R;
ShowMessage('Red component of Brown is: $'+IntToHex(r,2));
Rectangle1.Fill.Color:= aColor;
rgbValue:= TAlphaColorRec(aColor).Color;
ShowMessage('Brown is: $'+IntToHex(rgbValue,8));
end;
procedure TForm1.btnRedderClick(Sender: TObject);
var
aColor: TAlphaColor;
rgbValue: longint;
begin
aColor:= TAlphaColorRec.Brown;
TAlphaColorRec(aColor).R:= 255; //$A52A2A becomes $FF2A2A
Rectangle1.Fill.Color:= aColor;
rgbValue:= TAlphaColorRec(aColor).Color;
ShowMessage('Redder Brown is: $'+IntToHex(rgbValue,8));
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With