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

#region 회색조 비트맵 구하기 - GetGrayScaleBitmap(sourceImage)

/// <summary>
/// 회색조 비트맵 구하기
/// </summary>
/// <param name="sourceImage">소스 이미지</param>
/// <returns>회색조 비트맵</returns>
public Bitmap GetGrayScaleBitmap(Image sourceImage)
{
    Bitmap targetBitmap = new Bitmap(sourceImage);
    Color  color;
    int    brightness;

    for(int y = 0; y < targetBitmap.Height; y++)
    {
        for(int x = 0; x < targetBitmap.Width; x++)
        {
            color = targetBitmap.GetPixel(x, y);

            brightness = (int)(0.299 * color.R + 0.587 * color.G + 0.114 * color.B);

            color = Color.FromArgb(brightness, brightness, brightness);

            targetBitmap.SetPixel(x, y, color);
        }
    }

    return targetBitmap; 
}

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

댓글을 달아 주세요