在不损失任何质量的情况下调整图像大小
问题描述:
如何在不影响图像质量的情况下调整图像大小?
How can I resize an image, with the image quality unaffected?
答
As rcar 说,你不能不损失一些质量,在 c# 中你能做的最好的是:
As rcar says, you can't without losing some quality, the best you can do in c# is:
Bitmap newImage = new Bitmap(newWidth, newHeight);
using (Graphics gr = Graphics.FromImage(newImage))
{
gr.SmoothingMode = SmoothingMode.HighQuality;
gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
gr.DrawImage(srcImage, new Rectangle(0, 0, newWidth, newHeight));
}