0
我已經使用C#方法來調整圖像大小。我使用了以下鏈接中的幾種方法。C#圖像大小調整 - 質量丟失
C# Simple Image Resize : File Size Not Shrinking 萎縮
但是當調整大小的圖像
請幫我解決這個問題的質量缺失。
我已經使用C#方法來調整圖像大小。我使用了以下鏈接中的幾種方法。C#圖像大小調整 - 質量丟失
C# Simple Image Resize : File Size Not Shrinking 萎縮
但是當調整大小的圖像
請幫我解決這個問題的質量缺失。
您可以使用WIC(Windows Imaging Component)而不是GDI +。下面是一個例子nice blog post。
首先轉換您Bitmap
到Image
Bitmap b = new Bitmap("asdf.jpg");
Image i = (Image)b;
然後將圖像傳遞給此方法來調整
public static Image ResizeImage(Image image, int width, int height, bool onlyResizeIfWider)
{
using (image)
{
// Prevent using images internal thumbnail.
image.RotateFlip(RotateFlipType.Rotate180FlipNone);
image.RotateFlip(RotateFlipType.Rotate180FlipNone);
if (onlyResizeIfWider == true)
if (image.Width <= width)
width = image.Width;
// Resize with height instead?
int newHeight = image.Height * width/image.Width;
if (newHeight > height)
{
width = image.Width * height/image.Height;
newHeight = height;
}
Image NewImage = image.GetThumbnailImage(width, newHeight, null, IntPtr.Zero);
return NewImage;
}
}
我希望這有助於。
其中一個可能的重複看到這個http://stackoverflow.com/questions/87753/resizing-an-image-without-losing-anyquality – Tamkeen