今天处理将图片写入Excel时,需要将Excel调整大小,在下面语句总报了这个错误:
Bitmap b = new Bitmap(destWidth, destHeight);
Graphics g=Graphics.FromImage((System.Drawing.Image)b);
g.InterpolationMode=InterpolationMode.HighQualityBicubic;
//绘制图像
g.DrawImage(imgToResize, 0, 0, destWidth,destHeight);
g.Dispose();
解决办法:
需要使用全称,将上面语句改写为:g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
就可以了。
图片改变分辨率的方法: