mbColorLib: Initial commit (still some issues)

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5452 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-12-08 23:14:26 +00:00
parent 17b82f66f4
commit 5d7f9b43bf
97 changed files with 19214 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
unit RGBCMYKUtils;
interface
uses
{$IFDEF FPC}LCLIntf,{$ELSE} Windows,{$ENDIF}
Graphics, Math;
function CMYtoTColor(C, M, Y: integer): TColor;
procedure RGBtoCMY(clr: TColor; var C, M, Y: integer);
function CMYKToTColor (C, M, Y, K: integer): TColor;
procedure ColorToCMYK(clr: TColor; var C, M, Y, K: integer);
function GetCValue(c: TColor): integer;
function GetMValue(c: TColor): integer;
function GetYValue(c: TColor): integer;
function GetKValue(c: TColor): integer;
implementation
function CMYtoTColor(C, M, Y: integer): TColor;
begin
Result := RGB(255 - C, 255 - M, 255 - Y);
end;
procedure RGBtoCMY(clr: TColor; var C, M, Y: integer);
begin
C := 255 - GetRValue(clr);
M := 255 - GetGValue(clr);
Y := 255 - GetBValue(clr);
end;
function CMYKToTColor (C, M, Y, K: integer): TColor;
begin
Result := RGB(255 - (C + K), 255 - (M + K), 255 - (Y + K));
end;
procedure ColorToCMYK(clr: TColor; var C, M, Y, K: integer);
begin
C := 255 - GetRValue(clr);
M := 255 - GetGValue(clr);
Y := 255 - GetBValue(clr);
K := MinIntValue([C, M, Y]);
C := C - K;
M := M - K;
Y := Y - K;
end;
function GetCValue(c: TColor): integer;
var
d: integer;
begin
ColorToCMYK(c, Result, d, d, d);
end;
function GetMValue(c: TColor): integer;
var
d: integer;
begin
ColorToCMYK(c, d, Result, d, d);
end;
function GetYValue(c: TColor): integer;
var
d: integer;
begin
ColorToCMYK(c, d, d, Result, d);
end;
function GetKValue(c: TColor): integer;
var
d: integer;
begin
ColorToCMYK(c, d, d, d, Result);
end;
end.