日期:2014-05-18 浏览次数:21019 次
/// <summary> /// Resize图片 /// </summary> /// <param name="bmp">原始Bitmap</param> /// <param name="newW">新的宽度</param> /// <param name="newH">新的高度</param> /// <returns>处理以后的Bitmap</returns> public static Bitmap ResizeImage(Bitmap bmp, int newW, int newH) { try { 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; } catch { return null; } }