应该是这个吧?在离线包里找到的!
我觉得你只能得到最后一幅的缩略图,因为每次image2.Canvas.StretchDraw,image2都整个
重画了一遍。
用TImage不是一个好主意,不妨用ListView和ImageList好些。
下面这段是我以前的一个程序中拷下来的,要做一些改动,但大概意思是这样。
procedure TListVThread.Execute;
var i,tw,th:integer; bitmap,map:tbitmap;arect,brect:trect;
begin
with mybook do
begin
listview1.show;
gauge1.Show;
//label4.caption:='共'+inttostr(it);
if not brdone then
begin
filelistbox1.mask:='*.bmp;*.jpg;*.jpeg;*.emf;*.wmf;*.psd;*.pdd;*.tif; *.tiff;*.fax;*.bw;*.rgb;*.rgba;*.sgi;*.cel; *.pic;*.tga; *.vst;*.icb; *.vda; *.win;*.pcx;*.pcc;*.scr;*.pcd;*.ppm;*.pgm;*.pbm;*.cut;*.pal;*.rla;*.rpf;*.rle;*.dib;*.psp;*.png';
filelistbox1.Update;
it:=filelistbox1.Items.Count;
gauge1.MaxValue := it;
listview1.Items.Clear;
imagelist1.Clear;
w:=imagelist1.Width;
h:=imagelist1.height;
arect.Left :=0;
arect.Top :=0;
arect.Right :=w;
arect.Bottom :=h;
brect:=arect;
map := TBitmap.Create;
for i:=1 to it do
begin
s:=filelistbox1.Items[i-1];
image1.picture.LoadFromFile(s);
tw:=image1.Picture.Width;
th:=image1.Picture.height;
Bitmap := TBitmap.Create;
Clipboard.Assign(Image1.Picture);
map.LoadFromClipBoardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0);
bitmap.Width :=w;
bitmap.height:=h;
bitmap.Canvas.Rectangle(brect);
if(tw<w)and(th<h) then
bitmap.canvas.Draw(w div 2-tw div 2,h div 2-th div 2,map)
else
begin
if tw>th then
begin
arect.left:=0;
arect.Right:=w;
tem:=round(w*(th/tw));
arect.top:=(h-tem) div 2;
arect.bottom:=arect.top+tem;
end
else
begin
arect.top:=0;
tem:=round(h*(tw/th));
arect.Left :=w div 2- tem div 2;
arect.Right:=arect.left+tem;
arect.bottom:=h;
end;
bitmap.Canvas.StretchDraw(arect,map)
end;
imagelist1.Add(bitmap,bitmap);
listview1.Items.Add;
pi:=i;
synchronize(prog);
//caption:='Isee '+inttostr(round(i/it*100))+'%';
listview1.Items[i-1].imageindex:=i-1;
listview1.Items[i-1].Caption:=s;
end;
caption:='Isee';
//listview1.Cursor:=crdefault;
gauge1.Hide;
gauge1.Progress := 0;
SpeedButton42.Enabled := false;
SpeedButton43.Enabled := false;
SpeedButton26.Enabled := true;
brdone:=true;
statusbar1.panels.items[1].text:='共打开'+inttostr(it)+'个文件 ';
end;
end;
end;