I got bored so i made a findcolor replica, however, the one from scar is still way more efficient because this doesn't use the GetDiBits api for which the api calls should be enabled.
And FindColorTolerance:Code:function FindColor2(var x, y: Integer; color, x1, y1, x2, y2: Integer): Boolean; var p1, p2: TPoint; begin if(x1 < x2)then begin p1.X := x1; p2.X := x2; end else begin p1.X := x2; p2.X := x1; end; if(y1 < y2)then begin p1.Y := y1; p2.Y := y2; end else begin p1.Y := y2; p2.Y := y1; end; Result := False; for x := p1.X to p2.X do begin for y := p1.Y to p2.Y do begin if(GetColor(x, y) = color)then begin Result := True; Exit; end; end; end; end;
Code:function FindColorTolerance2(var x, y: Integer; color, x1, y1, x2, y2, tolerance: Integer): Boolean; var p1, p2: TPoint; begin if(x1 < x2)then begin p1.X := x1; p2.X := x2; end else begin p1.X := x2; p2.X := x1; end; if(y1 < y2)then begin p1.Y := y1; p2.Y := y2; end else begin p1.Y := y2; p2.Y := y1; end; Result := False; for x := p1.X to p2.X do begin for y := p1.Y to p2.Y do begin if(SimilarColors(GetColor(x, y), color, tolerance))then begin Result := True; Exit; end; end; end; end;







Reply With Quote