2013-08-06 4 views
5

좋은 품질의 큰 이미지가 필요합니다. 작은 크기 (30x30px)로 크기를 조정해야하며 graphics.DrawImage로 크기를 조정합니다. 그러나 크기를 조정하면 흐리게되고 약간 가볍습니다. 또한 CompositingQuality 및 InterpolationMode를 시도했지만 모두 좋지 않았습니다.품질을 잃지 않고 이미지 크기를 조정하는 방법

예, 그 품질을 얻으려고합니다.

내가 나 자신을 그릴 아이콘의 이미지를 편집

내 결과, 어쩌면 더 나은 크기를 조정하지 않고 작은을 그릴 것입니다?

Edit2가

Resizeing 코드 :

   Bitmap tbmp; 
       //drawing all my features in tbmp with graphics 
       bmp = new Bitmap(width + 5, height + 5); 
       bmp.MakeTransparent(Color.Black); 
       using (var gg = Graphics.FromImage(bmp)) 
       { 
        gg.CompositingQuality = CompositingQuality.HighQuality; 
        // gg.SmoothingMode = SmoothingMode.HighQuality; 
        gg.InterpolationMode = InterpolationMode.HighQualityBicubic; 

        gg.DrawImage(tbmp, new Rectangle(0, 0, width, height), new Rectangle(GXMin, GYMin, GXMax + 20, GYMax + 20), GraphicsUnit.Pixel); 
        gg.Dispose(); 
       } 
+4

품질이 떨어지지 만 품질은 벡터 그래픽이 아닌 비트 맵입니다. –

+0

크기 조정을 위해 사용하고있는 * 실제 코드 *를 표시 할 수 있습니까? –

+0

실제 코드가 추가되었습니다. – BOBUK

답변

6

나는 (어떤 크기의) 원본에서 (모든 크기의) 썸네일 이미지를 얻을 수있는 방법으로이 방법을 사용합니다. 원래의 크기 비율과 크게 다른 크기 비율을 요구할 때 고유 한 문제가 있음에 유의하십시오. 크기가 서로 다른 크기를 물어 보는 것이 가장 좋습니다.

public static Image GetThumbnailImage(Image OriginalImage, Size ThumbSize) 
{ 
    Int32 thWidth = ThumbSize.Width; 
    Int32 thHeight = ThumbSize.Height; 
    Image i = OriginalImage; 
    Int32 w = i.Width; 
    Int32 h = i.Height; 
    Int32 th = thWidth; 
    Int32 tw = thWidth; 
    if (h > w) 
    { 
     Double ratio = (Double)w/(Double)h; 
     th = thHeight < h ? thHeight : h; 
     tw = thWidth < w ? (Int32)(ratio * thWidth) : w; 
    } 
    else 
    { 
     Double ratio = (Double)h/(Double)w; 
     th = thHeight < h ? (Int32)(ratio * thHeight) : h; 
     tw = thWidth < w ? thWidth : w; 
    } 
    Bitmap target = new Bitmap(tw, th); 
    Graphics g = Graphics.FromImage(target); 
    g.SmoothingMode = SmoothingMode.HighQuality; 
    g.CompositingQuality = CompositingQuality.HighQuality; 
    g.InterpolationMode = InterpolationMode.High; 
    Rectangle rect = new Rectangle(0, 0, tw, th); 
    g.DrawImage(i, rect, 0, 0, w, h, GraphicsUnit.Pixel); 
    return (Image)target; 
} 
+0

안녕하세요, 스케일 업도 가능합니까? –

+0

@ObiOnuorah 원본 이미지 크기를 초과하여 위쪽으로 확장하는 데는 아무런 효과가 없습니다. 사용 가능한 이미지 정보가 없습니다. – DonBoitnott

관련 문제