procedure TForm1.FormCreate(Sender: TObject);
begin
image1.SetBounds(image1.Left,image1.Top,250,64);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
bmp:Tbitmap;
tmp:single;
w,h:integer;
begin
bmp:=Tbitmap.Create;
bmp.Width:=1024;
bmp.Height:=768;
bmp.LoadFromFile('d:/28.bmp');//加载1024*768的图象
tmp:=image1.Width / bmp.Width;
if tmp * bmp.Height>image1.Height then
begin
w:=bmp.Width * image1.Height div bmp.Height;
h:=image1.Height;
end
else
begin
w:=image1.Width;
h:=bmp.Height * image1.width div bmp.width;
end;
bmp.Canvas.StretchDraw(rect(0,0,w,h),bmp);
image1.Picture.Assign(bmp);
bmp.Free;
end;