现在的位置: 首页 > 综合 > 正文

jpeg图片压缩

2013年08月10日 ⁄ 综合 ⁄ 共 358字 ⁄ 字号 评论关闭

一个压缩jpeg图片的过程

uses jpeg;

procedure ZipJPEG;
var
  jpg: TJpegImage;
  bmp: TBitmap;
begin
  jpg := TJpegImage.Create;
  bmp := TBitmap.Create;
  try
    jpg.LoadFromFile('c:\A.jpg');

    bmp.Width := jpg.Width;
    bmp.Height := jpg.Height;
    bmp.Canvas.StretchDraw(bmp.Canvas.ClipRect, jpg);
    jpg.Assign(bmp);

    jpg.CompressionQuality := 10;
    jpg.Compress;
    jpg.SaveToFile('C:\AA.jpg');
  finally
    bmp.free;
    jpg.free;
  end;
end;

抱歉!评论已关闭.