The Graphics unit contains the following functions:
function FPColorToTColorRef(const FPColor: TFPColor): TColorRef;
begin
Result:=((FPColor.Red shr 8) and $ff)
or (FPColor.Green and $ff00)
or ((FPColor.Blue shl 8) and $ff0000);
end;
function FPColorToTColor(const FPColor: TFPColor): TColor;
begin
Result:=TColor(FPColorToTColorRef(FPColor));
end;
function TColorToFPColor(const c: TColorRef): TFPColor;
begin
Result.Red:=(c and $ff);
Result.Red:=Result.Red+(Result.Red shl 8);
Result.Green:=(c and $ff00);
Result.Green:=Result.Green+(Result.Green shr 8);
Result.Blue:=(c and $ff0000) shr 8;
Result.Blue:=Result.Blue+(Result.Blue shr 8);
Result.Alpha:=FPImage.alphaOpaque;
end;
function TColorToFPColor(const c: TColor): TFPColor;
begin
Result:=TColorToFPColor(TColorRef(c));
end;
Notice that the unit has:
FPColorToTColor to convert TFPColor to TColor.
TColorToFPColor to convert TColor to TFPColor.
Everything is fine with that. The problem appears when converting between TFPColor and TColorRef.
The unit has FPColorToTColorRef to convert TFPColor to TColorRef, but when it comes to converting TColorRef to TFPColor the function name is TColorToFPColor, not TColorRefToFPColor, which is the same name as above.
Not only that the function name is not intuitive but looking at the LCL interfaces I think it may be a source of misunderstandings(bugs).
Might be a good idea to change the name of the function "TColorToFPColor(const c: TColorRef): TFPColor;" to "TColorRefToFPColor" so that the names would be consistent.