日期:2014-05-19  浏览次数:21989 次

C#怎么修改图片的大小和分辨率?
保持比例不变

------解决方案--------------------
改图片画面大小:

/// <summary>
/// Resize图片
/// </summary>
/// <param name= "bmp "> 原始Bitmap </param>
/// <param name= "newW "> 新的宽度 </param>
/// <param name= "newH "> 新的高度 </param>
/// <returns> 处理以后的Bitmap </returns>
public static Bitmap KiResizeImage(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;
}
}