1

Possible Duplicate:
Resizing an Image without losing any quality

I'm resizing images using the following method:

public static Bitmap Resize(Image source, int width, int height)
{
    Bitmap bitmap = new Bitmap(width, height);

    using (Graphics graphics = Graphics.FromImage(bitmap))
    {
        graphics.SmoothingMode = SmoothingMode.AntiAlias;
        graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
        graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
        graphics.DrawImage(source, new Rectangle(0, 0, width, height));
    }

    return bitmap;
}

The output image quality is terrible bad. Is there a way to resize the image without messing up the quality?

PS: the image source width and height is always bigger than the width and height parameters and the width and height ratio is being preserved.

Community
  • 1
  • 1
lolol
  • 4,287
  • 3
  • 35
  • 54

1 Answers1

1

Depends on resize and resolution of the image. If you make image bigger it's natural to get a bad result, you can get the same bad result on making image smaller, without maintaining its proportion.

In general, if you want to have scallable nice looking image, hold on Vector Graphics. In other words use: Metafile or some SVG library for images.

Tigran
  • 61,654
  • 8
  • 86
  • 123
  • the image source width and height is always bigger than the width and height parameters and the width and height ratio is being preserved. – lolol Dec 12 '12 at 20:25
  • 1
    @lolol: in this case, try to disable antialiasing, or follow suggessions in other "possibe dupplicated" question, marked like a comment. – Tigran Dec 12 '12 at 20:26