views:

25

answers:

0

Hello,

In asp.net 2.0 application I am trying to create thumbnails from uploaded images. However when I test the application on my PC under Windows7 it works fine, but on the real Windows 2003 Server the resized image has worse quality.

Where this difference could come from? Different JPEG codec or what, if Yes how it can be updated on Win 2003 Server? Thanks!

Here is the code:

Resize of the Image:

Bitmap newBmp = new Bitmap(imgWidth, imgHeight, PixelFormat.Format24bppRgb); newBmp.SetResolution(inputBmp.HorizontalResolution, inputBmp.VerticalResolution);

//Create a graphics object attached to the new bitmap Graphics newBmpGraphics = Graphics.FromImage(newBmp);

newBmpGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

newBmpGraphics.SmoothingMode = SmoothingMode.HighQuality;

newBmpGraphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

newBmpGraphics.DrawImage(inputBmp, new Rectangle(0, 0, imgWidth, imgHeight), new Rectangle(0, 0, inputBmp.Width, inputBmp.Height), GraphicsUnit.Pixel);

Save of the Image:

System.IO.Stream imgStream = new System.IO.MemoryStream();

//Get the ImageCodecInfo for the desired target format ImageCodecInfo destCodec = FindCodecForType(ImageMimeTypes.JPEG);

if (destCodec == null) { //No codec available for that format throw new ArgumentException("The requested format image/jpeg does not have an available codec installed", "destFormat"); }

//Create an EncoderParameters collection to contain the //parameters that control the dest format's encoder EncoderParameters destEncParams = new EncoderParameters(1);

EncoderParameter qualityParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality,(long)quality);

destEncParams.Param[0] = qualityParam;

//Save w/ the selected codec and encoder parameters inputBmp.Save(imgStream, destCodec, destEncParams);

Bitmap destBitmap = new Bitmap(imgStream);