关于图象显示问题??? ( 积分: 100 )

  • 主题发起人 主题发起人 gc1848
  • 开始时间 开始时间
G

gc1848

Unregistered / Unconfirmed
GUEST, unregistred user!
while not adoquery1.Eof do
begin
p1:=TPicture.Create;
p2:=TPicture.Create;
BM := TBitmap.Create;
p1.LoadFromFile('//192.168.1.2/pic/'+trim(adoquery1.fieldbyname('款号').AsString)+'.jpg');
PStretch(img1.Width,img1.Height,p1,p2);
bm.Width:=img1.Width;
bm.Height:=img1.Height;
bm.Canvas.Draw((img1.Width-p2.Width)div 2,(img1.Height-p2.Height)div 2,p2.Graphic);
i:=Img1.Add(bm,nil);
list[0]:=listview4.Items.Add;
list[0].Caption:=adoquery1.fieldbyname('款号').AsString;
list[0].ImageIndex:=i;
i:=i+1;
adoquery1.Next;
BM.Free;
p1.Free;
p2.Free;
end;
这样运行进会出来一下子把所有记录都显示出来,如果有个5000条记录要等上20分钟,他显示却是一下子全部出来,能不能做到一条记录一条记录的显示出来,显示完也要20分钟,但人的心理就会认为速度快。
 
while not adoquery1.Eof do
begin
p1:=TPicture.Create;
p2:=TPicture.Create;
BM := TBitmap.Create;
p1.LoadFromFile('//192.168.1.2/pic/'+trim(adoquery1.fieldbyname('款号').AsString)+'.jpg');
PStretch(img1.Width,img1.Height,p1,p2);
bm.Width:=img1.Width;
bm.Height:=img1.Height;
bm.Canvas.Draw((img1.Width-p2.Width)div 2,(img1.Height-p2.Height)div 2,p2.Graphic);
i:=Img1.Add(bm,nil);
list[0]:=listview4.Items.Add;
list[0].Caption:=adoquery1.fieldbyname('款号').AsString;
list[0].ImageIndex:=i;
i:=i+1;
adoquery1.Next;
BM.Free;
p1.Free;
p2.Free;
end;
这样运行进会出来一下子把所有记录都显示出来,如果有个5000条记录要等上20分钟,他显示却是一下子全部出来,能不能做到一条记录一条记录的显示出来,显示完也要20分钟,但人的心理就会认为速度快。
 
每装载一条记录就Refresh一下。
 
刷新。
while not adoquery1.Eof do
begin
p1:=TPicture.Create;
p2:=TPicture.Create;
BM := TBitmap.Create;
p1.LoadFromFile('//192.168.1.2/pic/'+trim(adoquery1.fieldbyname('款号').AsString)+'.jpg');
PStretch(img1.Width,img1.Height,p1,p2);
bm.Width:=img1.Width;
bm.Height:=img1.Height;
bm.Canvas.Draw((img1.Width-p2.Width)div 2,(img1.Height-p2.Height)div 2,p2.Graphic);
i:=Img1.Add(bm,nil);
list[0]:=listview4.Items.Add;
list[0].Caption:=adoquery1.fieldbyname('款号').AsString;
list[0].ImageIndex:=i;
i:=i+1;
adoquery1.Next;
BM.Free;
p1.Free;
p2.Free;
list[0].Update;//加上这句
end;
 
在处理每条记录后application.ProcessMessages,
 
还有我看了你的程序没有优化,不要在每次都创建相同的对象,
p1:=TPicture.Create;
p2:=TPicture.Create;
BM := TBitmap.Create;
完全没有必要,这也会对速度产生一定影响,另外你最好把制作缩略图做成一个独立函数方便调用
 
多人接受答案了。
 
后退
顶部