procedure TForm1.Button1Click(Sender: TObject);
var
b: TBitmap;//原图片
nb: TBitmap;//Resize以后的图片
r: TRect;
begin
b := TBitmap.Create;
if OpenDialog1.Execute then
begin
b.LoadFromFile(OpenDialog1.FileName);
nb := TBitmap.Create;
nb.Height := b.Height div 2; //高度变为原来的一半
nb.Width := b.Width div 2; //宽度变为原来的一半
r.TopLeft := Point(0, 0);
r.BottomRight := Point(nb.Width, nb.Height);
with nb.Canvas do
begin
Pen.Style := psDash;
Brush.Style := bsClear;
Rectangle(0, 0, nb.Width, nb.Height);
StretchDraw(r, TGraphic(b));
end;
if SaveDialog1.Execute then nb.SaveToFile(SaveDialog1.FileName);
nb.Free;
end;
b.Free;
end;