图片的缩放
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.Canvasdo
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;
详细看我的笔记:
http://www.delphibbs.com/keylife/iblog_show.asp?xid=2931