procedure TForm1.Button1Click(Sender: TObject);
var
jpg: TJPEGImage; // 要use Jpeg单元
begin
// 显示jpg大图片的方式
jpg := TJPEGImage.Create;
jpg.LoadFromFile(getcurrentdir() + '\pic.jpg');
Image1.Picture.Bitmap.Assign(jpg); // 因为 img 控件是基于bmp的
jpg.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
// 加载24位高清BMP图片(小、大都能成立)
Image1.Picture.Bitmap.LoadFromFile(getcurrentdir() + '\pic24位-大.bmp');
end;
procedure TForm1.Button3Click(Sender: TObject);
var
png: tpngimage;
begin
png := tpngimage.Create;
png.LoadFromFile(getcurrentdir() + '\pic.png');
Image1.Picture.Bitmap.Assign(png);
png.Free;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
gif: tgifimage;
begin
gif := tgifimage.Create;
gif.LoadFromFile(getcurrentdir() + '\pic.png');
Image1.Picture.Bitmap.Assign(gif);
gif.Free;
end;