Hi,
this patch moves InvertColor function from SourceEditorProcs to Graphics and adds RGBToColor function, which composes TColor from red, green and blue component like Windows.RGB.

  Tombo
Index: ide/sourceeditprocs.pas
===================================================================
--- ide/sourceeditprocs.pas     (revision 9891)
+++ ide/sourceeditprocs.pas     (working copy)
@@ -98,24 +98,6 @@
   BGBlue: Integer;
   TokenStart: Integer;
 
-  function InvertColor(AColor: TColor): TColor;
-  var Red, Green, Blue: integer;
-  begin
-    Red:=(AColor shr 16) and $ff;
-    Green:=(AColor shr 8) and $ff;
-    Blue:=AColor and $ff;
-    if Abs($80-Red)+Abs($80-Green)+Abs($80-Blue)<$140 then begin
-      Red:=Red+$a0;
-      Green:=Green+$a0;
-      Blue:=Blue+$a0;
-    end else begin
-      Red:=$ff-Red;
-      Green:=$ff-Green;
-      Blue:=$ff-Blue;
-    end;
-    Result:=((Red and $ff) shl 16)+((Green and $ff) shl 8)+(Blue and $ff);
-  end;
-
   procedure SetFontColor(NewColor: TColor);
   var
     FGRed: Integer;
Index: lcl/graphics.pp
===================================================================
--- lcl/graphics.pp     (revision 9891)
+++ lcl/graphics.pp     (working copy)
@@ -1302,10 +1302,12 @@
 function ColorToString(Color: TColor): AnsiString;
 function StringToColor(const S: shortstring): TColor;
 procedure GetColorValues(Proc: TGetColorStringProc);
+function InvertColor(AColor: TColor): TColor;
 
 Function Blue(rgb: TColor): BYTE;
 Function Green(rgb: TColor): BYTE;
 Function Red(rgb: TColor): BYTE;
+function RGBToColor(R, G, B: Byte): TColor;
 procedure RedGreenBlue(rgb: TColor; out Red, Green, Blue: Byte);
 function FPColorToTColor(const FPColor: TFPColor): TColor;
 function TColorToFPColor(const c: TColor): TFPColor;
@@ -1639,6 +1641,30 @@
   for I := Low(Colors) to High(Colors) do Proc(Colors[I].Name);
 end;
 
+function InvertColor(AColor: TColor): TColor;
+var
+  R, G, B: Integer;
+begin
+  R := AColor and $ff;
+  G := (AColor shr 8) and $ff;
+  B := (AColor shr 16) and $ff;
+
+  if Abs($80 - R) + Abs($80 - G) + Abs($80 - B) < $140 then
+  begin
+    Inc(R, $a0);
+    Inc(G, $a0);
+    Inc(B, $a0);
+  end
+  else
+  begin
+    R := $ff - R;
+    G := $ff - G;
+    B := $ff - B;
+  end;
+  
+  Result := ((B and $ff) shl 16) or ((G and $ff) shl 8) or (R and $ff);
+end;
+
 Function Blue(rgb: TColor): BYTE;
 begin
   Result := (rgb shr 16) and $000000ff;
@@ -1654,6 +1680,11 @@
   Result := rgb and $000000ff;
 end;
 
+function RGBToColor(R, G, B: Byte): TColor;
+begin
+  Result := (B shl 16) or (G shl 8) or R;
+end;
+
 procedure RedGreenBlue(rgb: TColor; out Red, Green, Blue: Byte);
 begin
   Red := rgb and $000000ff;

Reply via email to