该文章紧接http://topic.csdn.net/u/20101105/15/8e582e7f-79ff-4f05-8041-f81443e0c58d.html
以下代码由gomoku用户提供,不过出现了顶部和左边少了,以下参数中scale为30,正确结果应该左和顶部(最边缘)应该也和其他地方一样有30像素!但实际只有15像素,少了一半,帮忙解决!没分了先给20static Bitmap Mosaic(Bitmap original, int scale)
{
    Bitmap result = new Bitmap(original.Width * scale, original.Height * scale);
    using (Graphics g = Graphics.FromImage(result))
    {
        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;  //<---
        g.DrawImage(original, 0, 0, result.Width, result.Height);
    }
    return result;
}

解决方案 »

  1.   

    抱歉,我自己解决了!
    static Bitmap Mosaic(Bitmap original, int scale)
    {
      Bitmap result = new Bitmap(original.Width * scale, original.Height * scale);
      using (Graphics g = Graphics.FromImage(result))
      {
      g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; //<---
    g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; //新增加的浮点处理
      g.DrawImage(original, 0, 0, result.Width, result.Height);
      }
      return result;
    }