2010-11-07 84 views
4

當我用這個方法來調整位圖:調整,如MS畫圖位圖 - 無抗鋸齒

private Bitmap ResizeBitmap(Bitmap b, int nWidth, int nHeight) 
    { 
     Bitmap result = new Bitmap(nWidth, nHeight); 
     using (Graphics g = Graphics.FromImage((Image)result)) 
     { 
      g.SmoothingMode = SmoothingMode.None; 
      g.DrawImage(b, 0, 0, nWidth, nHeight); 
     } 
     return result; 
    } 

它仍然使用,即使我指定的抗鋸齒:

g.SmoothingMode = SmoothingMode.None; 

我想只是一個基本的調整大小沒有任何平滑。

回答

10

而不是做

g.SmoothingMode = SmoothingMode.None; 

你應該做

g.InterpolationMode = InterpolationMode.NearestNeighbor; 
+0

不足以讓,改變PixelOffsetMode以及使用一半。 – 2015-08-09 09:00:07