marpis
2009-12-25 12:53:34
I don't know if this works how I think it works, but it should find the minimum tolerance with which all colors in the array "Colors: TIntegerArray" are found. So if you input clGreen, clRed, and clBlue it will result a very high tolerance, but if you input (clBlue - 1), (clBlue + 1) it will result a fairly small tolerance.
Please people, test it and tell me how you think it could be used! I don't commit it before it gets approved :rolleyes:
Please people, test it and tell me how you think it could be used! I don't commit it before it gets approved :rolleyes:
Function BestTolerance(Colors: TIntegerArray): Integer;
Var
I, II, Tol, H: Integer;
Begin
Result := -1;
H := High(Colors);
For I := 0 To H Do
For II := 0 To H Do
Begin
If (I = II) Then
Continue;
For Tol := 0 To 300 Do
If SimilarColors(Colors[I], Colors[II], Tol) Then
If (Tol > Result) Then
Begin
Result := Tol;
Break;
End;
End;
End;