views:

270

answers:

2

I´m generating some PNG Diagrams for my Asp.net application. With PNG I reach the quality I need on the Website, but I also need to generate a Report and there for I have to Resize my Diagrams from 897x651 to 216x161. How can I achieve this, without losing too much of quality. I have tried :

I´m not really happy with both ways. Please can someone help me? With PNGout you can convert bmp to png without losing quality. But you cannot resize

A: 

Actually, I had the same problem on resizing stuff using System.Drawing classes.

The Graphics class (this is also used in the link you posted http://www.peterprovost.org/blog/post/Resize-Image-in-C.aspx) has a property SmoothingMode and InterpolationMode. I set them to:

var graphics = Graphics.CreateFromImage( ... );
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.High;

This increased the quality quite a lot (comes with a performance penalty on large images though), but I only tried it with JPGs so far.

To be honest, I soon dumped System.Drawing in my ASP.NET app and used imagemagick (http://www.imagemagick.org/) for graphics stuff.

Max
A: 

The absolute best way to not lose quality (if you are generating the original images) is to generate the image from scratch again but with the smaller dimensions.

Otherwise built in image scaling in .NET is more than capable for PNG images. - See link in Marek's comment above.

Justin Wignall