A
anndy1999
Unregistered / Unconfirmed
GUEST, unregistred user!
我用双缓冲画图,但没画出来,不知下面的代码哪儿搞错了,还望指教!
var
BackMap : TBitMap;
procedure TAFXTest.DrawMap();
var
mx, my : Double;
i : Integer;
x, y : Int64;
moveFlag : Boolean;
begin
moveFlag := TRUE;
PaintBox.Canvas.Pen.Mode :=pmCopy;
BackMap := TBitMap.Create;
BackMap.Width := PaintBox.Width;
BackMap.Height := PaintBox.Height;
BackMap.Canvas.CopyRect(Rect(0,0,PaintBox.Width,PaintBox.Height),PaintBox.Canvas,
Rect(0,0,PaintBox.Width,PaintBox.Height));
for i:=0 to POINTNUM-1 do
begin
Global.LgLtToXY(MAP[0].Lon,MAP[0].Lat,MAP[i+1].Lon,MAP[i+1].Lat,mx,my);
x := Round(Screen.Width/2+(mx/2) * ZOOM );
y := Round(Screen.Height/2-(my/2) * ZOOM );
if moveFlag=TRUE then
begin
BackMap.Canvas.MoveTo(x,y);
moveFlag := FALSE;
end
else
BackMap.Canvas.LineTo(x,y);
end;
MAP := nil;
PaintBox.Canvas.CopyRect(Rect(0,0,PaintBox.Width,PaintBox.Height),BackMap.Canvas,
Rect(0,0,BackMap.Width,BackMap.Height));
BackMap.Free;
end;
var
BackMap : TBitMap;
procedure TAFXTest.DrawMap();
var
mx, my : Double;
i : Integer;
x, y : Int64;
moveFlag : Boolean;
begin
moveFlag := TRUE;
PaintBox.Canvas.Pen.Mode :=pmCopy;
BackMap := TBitMap.Create;
BackMap.Width := PaintBox.Width;
BackMap.Height := PaintBox.Height;
BackMap.Canvas.CopyRect(Rect(0,0,PaintBox.Width,PaintBox.Height),PaintBox.Canvas,
Rect(0,0,PaintBox.Width,PaintBox.Height));
for i:=0 to POINTNUM-1 do
begin
Global.LgLtToXY(MAP[0].Lon,MAP[0].Lat,MAP[i+1].Lon,MAP[i+1].Lat,mx,my);
x := Round(Screen.Width/2+(mx/2) * ZOOM );
y := Round(Screen.Height/2-(my/2) * ZOOM );
if moveFlag=TRUE then
begin
BackMap.Canvas.MoveTo(x,y);
moveFlag := FALSE;
end
else
BackMap.Canvas.LineTo(x,y);
end;
MAP := nil;
PaintBox.Canvas.CopyRect(Rect(0,0,PaintBox.Width,PaintBox.Height),BackMap.Canvas,
Rect(0,0,BackMap.Width,BackMap.Height));
BackMap.Free;
end;