在一幅图上画等距离网格,当图像放大或者缩小时结果就不对了,怎么搞啊?(50分)

  • 主题发起人 主题发起人 suckey
  • 开始时间 开始时间
S

suckey

Unregistered / Unconfirmed
GUEST, unregistred user!
一幅图,要实现图像缩放,同时又在上面画等距离网格。
编好了,但是当图像缩放时网格就不对了,图像原始大小
时是可以的,怎么办啊?高手给个原程序吧。
谢谢。
 
是一些线条消失了吗 ? 可以 作一下反锯齿处理
 
并不是一些线条消失了,而是完全不对了。
我单步执行过了,看到每一点moveto和lineto的都对,但是画出来
的就是错,好诡异的呀。
哎不知道怎么搞了。
我的函数如下,当我先选择图像缩小后在执行下面函数操作时就
画图就不对了,如果图像没有缩放时是可以的
procedure ShowLonLat1(var mLonLat : boolean;Viewimage1:TImage);
var
i,j,x_s,y_s:integer;
begin
ViewImage1.Stretch :=true;

if mLonLat then
with ViewImage1 do begin
begin
begin
Canvas.Pen.Color:= clYellow;
for i:=1 to 7 do
begin
x_s:=round((i*ViewImage1.Width)/8);
Canvas.MoveTo(x_s,0);
y_s:= round(ViewImage1.Height);
Canvas.lineTo(x_s,y_s);

end;

for j:=1 to 5 do
begin
y_s:=round((j*ViewImage1.height)/6);
Canvas.MoveTo(0 ,y_s);
x_s:= round(ViewImage1.width);
Canvas.lineTo(x_s,y_s);
end;

end;
end;
end
else
exit;
end;
 
ViewImage1.Width 改为 ViewImage1.picture.Width 试试
Height也是
 
试过的,也是的。

还有什么叫反锯齿处理啊?有源程序否?谢谢。
 
反锯齿将斜线出现的锯齿平滑化,算法也有多种,不过好像在这里用处不大

可以不用ViewImage1.Stretch :=true; 在Image Resize的时候重新画,我刚试过,没有问题了
 
嗯 你把相关的程序贴给我瞅瞅吧,我试了还是不行呢,谢谢。
 
procedure ShowLonLat1(var mLonLat : boolean;Viewimage1:TImage);
var
i,j,x_s,y_s:integer;
begin
if mLonLat then
with ViewImage1 do begin
Canvas.Pen.Color:= clYellow;
for i:=1 to 7 do
begin
x_s:=round((i*ViewImage1.Width)/8);
Canvas.MoveTo(x_s,0);
y_s:= round(ViewImage1.Height);
Canvas.lineTo(x_s,y_s);
end;
for j:=1 to 5 do
begin
y_s:=round((j*ViewImage1.Height)/6);
Canvas.MoveTo(0 ,y_s);
x_s:= round(ViewImage1.Width);
Canvas.lineTo(x_s,y_s);
end;
end
else
exit;
end;

procedure TForm1.FormResize(Sender: TObject);
var
b: Boolean;
begin
b := True;
with Image1 do begin
Picture.Bitmap.Width := Width;
Picture.Bitmap.Height := Height;
Canvas.FillRect(Canvas.ClipRect);
end;
ShowLonLat1(b, Image1);
end;

如果觉得太闪,就加上
procedure TForm1.FormCreate(Sender: TObject);
begin
DoubleBuffered := True;
end;
 
谢谢 虽然你说的方法还是不适合于我这边的程序。也不是我想要的效果
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部