日期:2014-05-18 浏览次数:20512 次
Image ReducedImage; using( System.IO.Stream stream = System.IO.File.OpenRead(resourceFile)) { ReducedImage = Image.FromStream(stream); Image.GetThumbnailImageAbort callb = new Image.GetThumbnailImageAbort(ThumbnailCallback); if ((ResourceImage.Width / ResourceImage.Height) >= 1) { ImageWidth = maxSize; ImageHeight = (ResourceImage.Height) * ImageWidth / ResourceImage.Width;//等比例缩放 } else { ImageHeight = maxSize; ImageWidth = (ResourceImage.Width) * ImageHeight / ResourceImage.Height;//等比例缩放 } ReducedImage = ResourceImage.GetThumbnailImage(ImageWidth, ImageHeight, callb, IntPtr.Zero); ReducedImage.Save(targetFilePath, ImageFormat.Jpeg); ReducedImage.Dispose(); } return true;