首页  编辑  

根据一个颜色返回一个合适的对比色

Tags: /超级猛料/Picture.图形图像编程/颜色处理/   Date Created:

function GetContrastingColor(Color: TColor): TColor;

begin

Color := ColorToRGB(Color); // convert system-defined colors

if (Color+Color shr 8+Color shr 16) and $0000FF>= $180 then

Result := clBlack

else

Result := clWhite;

end;

function GetContrastingColor(Color: TColor): TColor;

begin

Color := ColorToRGB(Color); // convert system-defined colors

Result :=

(Color+$000080) and $0000FF+ // red component

(Color+$008000) and $00FF00+ // green component

(Color+$800000) and $FF0000; // blue component

end;