随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253


问题来源: http://www.cnblogs.com/del/archive/2010/01/07/1641084.html#1742127

程序使用了 GDI+ 的新接口: http://www.cnblogs.com/del/archive/2009/12/11/1621790.html

uses GdiPlus;

procedure TForm1.Button1Click(Sender: TObject);
const
  Path1 = 'C:\Temp\Test.png';
  Path2 = 'C:\Temp\Test2.png';
var
  Img1,Img2: IGPImage;
  Graphics: IGPGraphics;
begin
  { 打开原图片 }
  Img1 := TGPImage.Create(Path1);

  { 建一个新图片, 假如是缩小一倍 }
  Img2 := TGPBitmap.Create(Img1.Width div 2, Img1.Height div 2, PixelFormat32bppARGB);

  { 获取新图片的绘图表面 }
  Graphics := TGPGraphics.Create(Img2);

  { 设置缩放质量为最高质量 }
  Graphics.InterpolationMode := InterpolationModeHighQualityBicubic;

  { 画过来 }
  Graphics.DrawImage(Img1, 0, 0, Img2.Width, Img2.Height, 0, 0, Img1.Width, Img1.Height, UnitPixel);

  { 保存 }
  Img2.Save(Path2, TGPImageFormat.Png);
end;

posted on 2010-01-07 17:53  万一  阅读(...)  评论(...编辑  收藏