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
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] 회색조 비트맵 설정하기 (0) | 2015.06.15 |
---|---|
[C#/WINFORM] 회색조 비트맵 배열 구하기 (0) | 2015.06.15 |
[C#/WINFORM] 비트맵 경계선 설정하기 (0) | 2015.06.13 |
[C#/WINFORM] 회색조 비트맵 명도 조정하기 (0) | 2015.06.13 |
[C#/WINFORM] 비트맵 명도 조정하기 (0) | 2015.06.13 |
[C#/WINFORM] RichTextBox 클래스 : 텍스트 라인 추가하기 (0) | 2015.05.15 |
[C#/WINFORM] RichTextBox 클래스 : 텍스트 추가하기 (0) | 2015.05.15 |
[C#/WINFORM] 컨트롤 포커스 이동하기 (0) | 2015.04.28 |
[C#/WINFORM] DataGridView 클래스 : CellFormatting 이벤트를 사용해 셀 포맷하기 (0) | 2015.04.26 |
[C#/WINFORM] DataGridView 클래스 : CurrentCell 속성을 사용해 현재 셀 NULL 설정하기 (0) | 2015.04.26 |
댓글을 달아 주세요