첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
using System.Drawing;
using System.Drawing.Imaging;

#region 모노크롬 비트맵 구하기 - GetMonochromeBitmap(image)

/// <summary>
/// 모노크롬 비트맵 구하기
/// </summary>
/// <param name="image">이미지</param>
/// <returns>모노크롬 미트맵</returns>
public Bitmap GetMonochromeBitmap(Image image)
{
    ColorMatrix colorMatrix = new ColorMatrix
    (
        new float[][]
        {
            new float[] { 0.299f, 0.299f, 0.299f, 0, 0 },
            new float[] { 0.587f, 0.587f, 0.587f, 0, 0 },
            new float[] { 0.114f, 0.114f, 0.114f, 0, 0 },
            new float[] { 0     , 0     , 0     , 1, 0 },
            new float[] { 0     , 0     , 0     , 0, 1 }
        }
    );

    ImageAttributes imageAttributes = new ImageAttributes();

    imageAttributes.SetColorMatrix(colorMatrix);

    Point[] pointArray =
    {
        new Point(0          , 0           ),
        new Point(image.Width, 0           ),
        new Point(0          , image.Height)
    };

    Rectangle rectangle = new Rectangle(0, 0, image.Width, image.Height);

    Bitmap bitmap = new Bitmap(image.Width, image.Height);

    using(Graphics graphics = Graphics.FromImage(bitmap))
    {
        graphics.DrawImage
        (
            image,
            pointArray,
            rectangle,
            GraphicsUnit.Pixel,
            imageAttributes
        );
    }

    return bitmap;
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요