2013-05-13 144 views
-1

我有這樣的代碼:如何調整圖像大小?

public static Bitmap ResizeImage(Bitmap imgToResize, Size size) 
     { 
      try 
      { 
       Bitmap b = new Bitmap(size.Width, size.Height); 
       using (Graphics g = Graphics.FromImage((Image)b)) 
       { 
        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; 

        g.DrawImage(imgToResize, 0, 0, size.Width, size.Height); 
       } 

       return b; 
      } 
      catch 
      { 
       throw; 
      } 
     } 

當我打電話比如函數:ResizeImage(BMP, 如何設置大小

+0

看看:http://stackoverflow.com/a/1587486/316799 – 2013-05-13 20:24:14

回答

1
例如

ResizeImage(bmp, new Size(150, 150));