Image quality c#

  • Thread starter Thread starter Zahid Khan
  • Start date Start date
Z

Zahid Khan

I need little help in my situation.
I am reading a graphic file (jpg) from disk and then
resizing it and save resized image. What happens, it gets
blured, I want to retain same quality so that small image
won't be blur?

any tips or idea or technique?

Thanks in Advance.
 
When resizing the best you can do is use the HighQualityBilinear or
HighQualityBicubic interpolation modes. Making an image smaller will
inevitably result in averaging of the pixels which can make the image appear
blurred, When enlarging the image, you may see blurring due to magnification
and interpolation.

Not using the high quality interpolation modes will result in aliasing which
is much worse than blurring.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com
 
Bob,

Can you point to any example code that does image resizing using the
bilinear interpolation modes? Is the interpolation provided by the graphic
driver or is it core system functionality?

Thanks,

Eric
 
When you resize the image you'll create an in-memory image and get a
graphics object for it somenthing like this...

Bitmap bm=new Bitmap(newsize.Width, newsize.Height);
Graphics g=Graphics.FromImage(bm);

At this point you can set the interpolation mode...

g.InterpolationMode=InterpolationMode.HighQualityBilinear;

When you draw your image to the new bitmap, the interpolation mode will be
used...

g.DrawImage(oldImage,new
Rectangle(0,0,oldImage.Width,oldImage.Height),0,0,bm.Width,
bm.Height,GraphicsUnit.Pixel);
g.Dispose();

Now save the image...

oldImage.Dispose();
bm.Save(filename,ImageFormat.bmp);

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com
 
Back
Top