R0b0t1
2007-11-21 13:52:23
Well, I've looked at the SimilarColor source and I haven't found a way to translate it into C++ compatible code…
So. Uh… Any help?
So. Uh… Any help?
2007-11-21 13:52:23
2007-11-21 14:54:22
Function iSimilarColors(Color1, Color2, Tol: Integer): Boolean;
Var
Tole: Integer;
R1, G1, B1, R2, G2, B2: Integer;
RGBC: Array [1..3] Of Integer;
Begin
ColorToRGB(Color1, R1, G1, B1);
ColorToRGB(Color2, R2, G2, B2);
If(R1 > R2)Then
RGBC[1] := R1 - R2
Else RGBC[1] := R2 - R1;
If(G1 > G2)Then
RGBC[2] := G1 - G2
Else RGBC[2] := G2 - G1;
If(B1 > B2)Then
RGBC[3] := B1 - B2
Else RGBC[3] := B2 - B1;
Tole := AMax(RGBC);
If(Tol >= Tole)Then
Result := True;
End;
Begin
If(iSimilarColors(200, 233, 33))Then
Writeln('lol');
End.
2007-11-21 15:38:37
function ColorRGB(SColor, i: Integer): Extended;
var
Color: TColor;
begin
Color := ColorToRGB(SColor);
Result:= 0;
case i of
1:result:= GetRValue(Color);
2:result:= GetGValue(Color);
3:result:= GetBValue(Color);
end;
end;
function SimilarColors(Color1, Color2, Tolerance: Integer): Boolean;
begin
Result:=False;
if(Abs(Round(ColorRGB(Color1, 1))-Round(ColorRGB(Color2, 1)))<=Tolerance)then
begin
if(Abs(Round(ColorRGB(Color1, 2))-Round(ColorRGB(Color2, 2)))<=Tolerance)then
begin
if(Abs(Round(ColorRGB(Color1, 3))-Round(ColorRGB(Color2, 3)))<=Tolerance)then
begin
Result:= True;
end;
end;
end;
end;
2007-11-21 15:47:45
bool SimilarColors(Color1, Color2, Tole){
if(abs(GetRValue(Color1) - GetRValue(Color2)) <= Tole)
if(abs(GetGValue(Color1) - GetGValue(Color2)) <= Tole)
if(abs(GetBValue(Color1) - GetBValue(Color2)) <=Tole)
return true;
else return false;
else return false;
else return false;
}
2007-11-21 17:06:52
2007-11-21 17:15:44
From: mastaraymond
R := Color and $ff;
G := Color shr 8 and $ff;
B := Color shr 16 and $ff;
Faster.
function SimilarColors(Color1, Color2, Tolerance: Integer): Boolean;
begin
Result := ((Abs((Color1 and $ff) - (Color2 and $ff)) <= Tolerance) and
(Abs(((Color1 and $ff00) shr 8) - ((Color2 and $ff00) shr 8)) <= Tolerance) and
(Abs(((Color1 and $ff0000) shr 16) - ((Color2 and $ff0000) shr 16)) <= Tolerance));
end;
2007-11-22 10:12:57
2007-11-23 12:13:30