0

I have used a C# method to resize the image size.I have used several methods from the following links.

C# Simple Image Resize : File Size Not Shrinking shrinking

Resize an Image C#

but quality is missing when re-sizing the image

Please help me to resolve the issue.

Community
  • 1
  • 1
Joseph
  • 1
  • one of possible duplicate seen this http://stackoverflow.com/questions/87753/resizing-an-image-without-losing-any-quality – Tamkeen Jun 22 '12 at 07:41

2 Answers2

0

You could use WIC (Windows Imaging Component) instead of GDI+. Here's a nice blog post with an example.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
0

First convert your Bitmap to an Image

Bitmap b = new Bitmap("asdf.jpg");
Image i = (Image)b;

then pass the image to this method to resize

public static Image ResizeImage(Image image, int width, int height, bool onlyResizeIfWider)
{
    using (image)
    {
        // Prevent using images internal thumbnail.
        image.RotateFlip(RotateFlipType.Rotate180FlipNone);
        image.RotateFlip(RotateFlipType.Rotate180FlipNone);

        if (onlyResizeIfWider == true)
            if (image.Width <= width)
                width = image.Width;

        // Resize with height instead?
        int newHeight = image.Height * width / image.Width;
        if (newHeight > height)
        {
            width = image.Width * height / image.Height;
            newHeight = height;
        }
        Image NewImage = image.GetThumbnailImage(width, newHeight, null, IntPtr.Zero);
        return NewImage;
    }
}

I hope this helps.

MoonKnight
  • 23,214
  • 40
  • 145
  • 277