Bitmap b = new Bitmap(newW, newH);
                Graphics g = Graphics.FromImage(b);
                // 插值算法的质量
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;                g.DrawImage(bmp, new Rectangle(0, 0, newW, newH), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
                g.Dispose();                return b;
我在代码中,指定矩形区域的左上角坐标也不好使。不知为什么,请大侠们指教!

解决方案 »

  1.   

    使用这人重载方法 
    指定左上角X Y坐标
    Graphics.DrawImage 方法 (Image, Rectangle, Int32, Int32, Int32, Int32, GraphicsUnit)
    http://msdn.microsoft.com/zh-cn/library/ms142045.aspx
      

  2.   

    可以从指定的坐标开始:
     System.Drawing.Image orgImage = System.Drawing.Image.FromFile(Path.Combine(Server.MapPath("图片路径"), strFileName));            
                x = 100;
                y = 50;
                w = 150;
                h = 80;            
    System.Drawing.Image currentImage = new Bitmap(240, 120, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
                Graphics g = Graphics.FromImage(currentImage);
                Rectangle destRect = new Rectangle(0, 0, 240, 120);
                Rectangle srcRect = new Rectangle(x, y, w, h);
                g.DrawImage(orgImage, destRect, srcRect, GraphicsUnit.Pixel);
                g.Dispose();
                orgImage.Dispose();
    像上面这样就可以了!
      

  3.   

    在把  currentImage.Save(.....);保存到你指定的路径下就可以了。