开发者

Problem with .Net Image processing on Windows Server 2003

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.MemoryStrea开发者_Go百科m();

//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);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜