should that be Find_Color:=BestChoice; ??
Yes, it should be, Also noticed a typo in my groupings, it wouldn't
affect anything but I like to make it clear.
So now I have this for the function:
function Find_Color(Constref ColorArray :TVGA256Array; R ,G ,B : Word) : Byte;
Var
Dist,Closest:Double;
I,BestChoice:Byte;
Begin
Closest:=200000;
For I:= 0 to 255 do
Begin
Dist := ((R-ColorArray[i].R)*(R-ColorArray[i].R))
+ ((G-ColorArray[i].G)*(G-ColorArray[i].G))
+ ((B-ColorArray[i].B)*(B-ColorArray[i].B));
If Dist < Closest Then
Begin
Closest:=Dist;
BestChoice:=I;
End;
End;
Find_Color:=BestChoice;
end;
I have 2 arrays that are not [0..255], one is [1..14] the other is
[0..15] is there a way I could expand this scheme to use those arrays
as well? The For loop would need to adjust to the size of the arrays
somehow.
James
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal