SCAR Code:
{*******************************************************************************
function GetNewRoadColor(xs, ys, xe, ye, tol: Integer): Boolean;
By: Wizzup? / WT-Fakawi and modified by Ron,Activate Fix by NaumanAkhlaQ
Description: Copies and compares a Bitmap of 20* 20 around Flag with known RoadColor.
Results the new global RoadColor.
*******************************************************************************}
function GetNewRoadColor(xs, ys, xe, ye, tol: Integer): Boolean;
var
DebugCanvas, ClientCanvas, MMCanvas: TCanvas;
fpx, fpy, bmp, w, h: Integer;
TC: TColor;
bmp1: Integer;
begin
if (DebugRadialRoad) then
begin
if (XS > XE) then
WriteLn('Error with RadialRoadWalk XS : ' + IntToStr(XS) + ' XE : ' +
IntToStr(XE));
if (YS > YE) then
WriteLn('Error with RadialRoadWalk YS : ' + IntToStr(YS) + ' YE : ' +
IntToStr(YE));
end;
w := xe - xs;
h := ye - ys;
if (not (LoggedIn)) then Exit;
if (DebugRadialRoad) then
begin
DisplayDebugImgWindow(w, h);
DebugCanvas := GetDebugCanvas;
ClientCanvas := GetClientCanvas;
SafeCopyCanvas(ClientCanvas, DebugCanvas, xs, ys, xe, ye, 0, 0, w, h);
end;
bmp1 := BitmapFromString(w, h, '');
Wait(1);
MMCanvas := GetBitmapCanvas(bmp1);
Wait(1);
try
bmp := BitmapFromString(w, h, '');
Wait(1);
SafeCopyCanvas(getclientcanvas, GetBitmapCanvas(bmp), xs, ys, xe, ye, 0, 0,
w, h)
except
WriteLn('Error with RadialRoadWalk');
WriteLn('Should be fixed though, so lets debug.');
WriteLn('xs = ' + IntToStr(xs) + ' ys = ' + IntToStr(ys) + ' xe = ' +
IntToStr(xe) + ' ye = ' + IntToStr(ye));
GetClientDimensions(w, h);
WriteLn('and client area is 0, 0, ' + IntToStr(w) + ', ' + IntToStr(h));
SaveBitmap(bmp, 'RoadWalkBMP');
SaveBitmap(bmp1, 'RoadWalkBMP1');
repeat
Wait(1000);
until (not (LoggedIn));
FreeBitmap(bmp);
FreeBitmap(bmp1);
Exit;
end;
Wait(1);
for fpy := 1 to h do
for fpx := 1 to w do
begin
TC := FastGetPixel(bmp, fpx, fpy);
if SimilarColors(TC, RoadColor, tol) then
begin
RoadColor := TC;
StoreToRoadColorArray;
Result := True;
Exit;
end
end;
FreeBitmap(bmp1);
end;