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

Function PictureResiz(aFilename{原图},dFileName{转换后的图片}: String): String;

2014年02月11日 ⁄ 综合 ⁄ 共 911字 ⁄ 字号 评论关闭

 Function   PictureResiz(aFilename{原图},dFileName{转换后的图片}:   String):   String;  
  var  
      Image:   TPicture;  
      bmp,   tmpbmp:   TBitmap;  
      aDesiredFileName:   String;  
  begin  
      Image     :=   TPicture.Create;  
      bmp         :=   TBitmap.Create;  
      tmpbmp   :=   TBitmap.Create;  
      try  
          Image.LoadFromFile(aFilename);  
          bmp.Assign(Image.Graphic);  
          tmpbmp.Width   :=   liWidth;         //指定图片宽度  
          tmpbmp.Height   :=   liHeight;     //指定图片高度  
          SetStretchBltMode(tmpbmp.Canvas.Handle,   STRETCH_DELETESCANS);   //平滑处理  
          StretchBlt(tmpbmp.Canvas.Handle,   0,   0,   tmpbmp.Width,   tmpbmp.Height,  
              bmp.Canvas.Handle,   0,   0,   bmp.Width,   bmp.Height,   SRCCOPY);  
          Image.Graphic.Assign(tmpbmp);  
          aDesiredFileName:=dFileName;  
          if   FileExists(aDesiredFileName)   then   DeleteFile(aDesiredFileName);  
   
          Image.SaveToFile(aDesiredFileName);  
          Result   :=   aDesiredFileName;  
      finally  
          bmp.Free;  
          tmpbmp.Free;  
          Image.Free;  
      end;      
  end;

抱歉!评论已关闭.