2012-06-22 3 views
0

이미지 크기를 조정하기 위해 C# 메서드를 사용했습니다. 다음 링크에서 여러 가지 방법을 사용했습니다.C# 이미지 크기 조정 품질 저하

C# Simple Image Resize : File Size Not Shrinking

Resize an Image C#

감소하지만, 문제를 해결하기 위해 도와주세요 이미지

을 다시 크기를 조정할 때 품질이 없습니다.

+0

가능한 복제본 중 하나를 본이 http://stackoverflow.com/questions/87753/resizing-an-image-without-losing-any-quality – Tamkeen

답변

0

WIC (Windows 이미징 구성 요소) 대신 GDI + 사용할 수 있습니다. 예를 들어 nice blog post입니다.

0

먼저 나는이 도움이 되었으면 좋겠

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; 
    } 
} 

의 크기를 조정하려면이 방법으로 이미지를 전달하여 BitmapImage

Bitmap b = new Bitmap("asdf.jpg"); 
Image i = (Image)b; 

을 변환합니다.