5,392
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Button2Click(Sender: TObject);
var
TheBitmap:TBitmap ;
TheJpeg:TJPEGImage;
aa:tlistitem;
i:integer;
begin
for i:=1 to 4 do
begin
TheJpeg := TJPEGImage.Create;
TheJpeg.LoadFromFile('D:\我的文档\ico\pic\'+inttostr(i)+'.jpg');
TheBitmap := TBitmap.Create ;
TheBitmap.Assign(TheJpeg);
TheBitmap.Canvas.StretchDraw(RECT(0, 0, 130, 130),TheBitmap);
ImageList1.Add(TheBitmap, nil) ;
aa:=listview1.Items.Add;
aa.Caption:=inttostr(i)+'.jpg';
FreeAndNil(TheBitmap) ;
FreeAndNil(TheJpeg);
end;
end;
var
Test: TJPEGImage;
Bmp: TBitmap;
begin
Test := TJPEGImage.Create;
Test.LoadFromFile('....jpg');
Bmp := TBitmap.Create;
Bmp.Assign(Test);
Bmp.Canvas.StretchDraw(RECT(0, 0, 13, 13), Bmp);
ImageList1.Width := 13;
ImageList1.Height := 13;
ImageList1.Add(Bmp, nil);
Test.Free;
Bmp.Free;