Issue with .NET Image Processing in Windows Server 2003

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

Where does this difference come from? Different JPEG codecs or what if so how can this be updated on Win 2003 Server? Thanks!

Here is the code:

Image resizing :

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

// Create a graphic object attached to the new bitmap 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);

Image saving :

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 for this format throw new ArgumentException ("The requested image format / jpeg does not have a codec installed", "DestFormat"); }

// Create an EncoderParameters collection containing // parameters that control the format encoder dest EncoderParameters destEncParams = new EncoderParameters (1);

Encoder QualityParameterParam = 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);

+2


a source to share





All Articles