Resizing an Image without losing any quality

public static picture public static · Sep 17, 2008 · Viewed 180.6k times · Source

How can I resize an image, with the image quality unaffected?

Answer

Kris Erickson picture Kris Erickson · Sep 17, 2008

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));
}