用Delphi 制作缩略图

procedure SavePic(SourceFileName,DescFileName: String);
const
    MaxWidth = 80 ;
    MaxHigth = 80 ;
var
   jpg: TJPEGImage;
   bmp: TBitmap;
   SourceJpg: TJPEGImage;
   Width, Height,tmpInt: Integer;
begin
   try
     bmp := TBitmap.Create;
     SourceJpg := TJPEGImage.Create;
     Jpg:= TJPEGImage.Create;
     //读取源文件
     SourceJpg.LoadFromFile(SourceFileName);
     //计算缩小比例
     if SourceJpg.Width >= SourceJpg.Height then
        tmpInt := Round(SourceJpg.Width div MaxWidth)
     else
        tmpInt := Round(SourceJpg.Height div MaxHigth) ;
     Width  := SourceJpg.Width  div tmpInt ;
     Height := SourceJpg.Height div tmpInt ;
     //缩小
     bmp.Width := Width;
     bmp.Height := Height;
     bmp.PixelFormat := pf24bit;
     bmp.Canvas.StretchDraw(Rect(0,0,Width,Height), SourceJpg);
     //保存
     jpg.Assign(bmp);
     jpg.SaveToFile(DescFileName);
   finally
     bmp.Free;
     jpg.Free;
     SourceJpg.Free;
   end;
end;