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
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] ListBox 클래스 : 사용자 항목 드래그하기 (0) | 2020.07.26 |
---|---|
[C#/WINFORM] ListBox 클래스 : 사용자 항목 배열하기 (0) | 2020.07.26 |
[C#/WINFORM] GraphicsPath 클래스 : 라운드 사각형 패스 구하기 (0) | 2020.07.24 |
[C#/WINFORM] 핀터레스트 스타일 대각선 그림 몽타지 사용하기 (0) | 2020.07.24 |
[C#/WINFORM] Bitmap 클래스 : 색상 영역 설정하기 (0) | 2020.07.23 |
[C#/WINFORM] DataGridView 클래스 : CellDoubleClick 이벤트를 사용해 체크 박스 컬럼 입력하기 (0) | 2020.07.23 |
[C#/WINFORM] 이미지 리스트에서 이미지 드래그하기 (0) | 2020.07.22 |
[C#/WINFORM] 이미지 리스트 편집하기 (0) | 2020.07.22 |
[C#/WINFORM] PrivateFontCollection 클래스 : 커스텀 폰트 사용하기 (0) | 2020.07.22 |
[C#/WINFORM] 싸인파를 따라 반전된 색상으로 텍스트 그리기 (0) | 2020.07.21 |
댓글을 달아 주세요