본문으로 바로가기

c# thumnail 썸네일 코드

category 닷넷관련/CSharp 2017.05.24 10:57

 

 

c# thumnaili 썸네일 코드

 

해당 소스로 밴치마킹 테스트 사이트는 아래 참고하시길...

 

http://richorama.github.io/2016/08/10/image-interpolation-benchmarks/

 

 

using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

class Program
{
    static void Main(string[] args)
    {
        Thumbnail(InterpolationMode.NearestNeighbor);
        Thumbnail(InterpolationMode.Bicubic);
        Thumbnail(InterpolationMode.Bilinear);
        Thumbnail(InterpolationMode.High);
        Thumbnail(InterpolationMode.HighQualityBicubic);
        Thumbnail(InterpolationMode.HighQualityBilinear);
        Thumbnail(InterpolationMode.Low);
    }

    private static void Thumbnail(InterpolationMode interpolationMode)
    {
        using (var source = Bitmap.FromFile(@"C:\Users\Richard\Desktop\Windows10-wallpaper-img100.jpg"))
        using (var target = new Bitmap(384, 286, PixelFormat.Format32bppPArgb))
        using (var graphics = Graphics.FromImage(target))
        {
            graphics.CompositingMode = CompositingMode.SourceCopy;
            graphics.CompositingQuality = CompositingQuality.HighSpeed;
            graphics.InterpolationMode = interpolationMode;

            graphics.DrawImage(source,
                new Rectangle(0, 0, target.Width, target.Height),
                new Rectangle(0, 0, source.Width, source.Height),
                GraphicsUnit.Pixel);

            target.Save($"{interpolationMode}.png", ImageFormat.Png);
        }
    }
}

댓글을 달아 주세요

  1. 재우니 2018.02.26 16:17 신고

    https://www.dotnetperls.com/getthumbnailimage