728x90
반응형
728x170
using System.Drawing;
using System.Drawing.Imaging;
#region 투명 비트맵 그리기 - DrawTransparentBitmap(graphics, image, transparency)
/// <summary>
/// 투명 비트맵 그리기
/// </summary>
/// <param name="graphics">그래픽스</param>
/// <param name="image">이미지</param>
/// <param name="transparency">투명도</param>
public void DrawTransparentBitmap(Graphics graphics, Image image, float transparency)
{
if(transparency <= 0f)
{
return;
}
ImageAttributes imageAttributes = null;
if(transparency < 1f)
{
imageAttributes = new ImageAttributes();
float[][] colorMatrixElementArray =
{
new float[] {1, 0, 0, 0 , 0},
new float[] {0, 1, 0, 0 , 0},
new float[] {0, 0, 1, 0 , 0},
new float[] {0, 0, 0, transparency, 0},
new float[] {0, 0, 0, 0 , 1}
};
imageAttributes.SetColorMatrix(new ColorMatrix(colorMatrixElementArray));
}
Rectangle targetRectangle = new Rectangle(Point.Empty, Size);
graphics.DrawImage
(
image,
targetRectangle,
0,
0,
image.Size.Width,
image.Size.Height,
GraphicsUnit.Pixel,
imageAttributes
);
}
#endregion
728x90
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] 리소스 커서 구하기 (0) | 2015.01.25 |
---|---|
[C#/WINFORM] 리소스 스트림 구하기 (0) | 2015.01.25 |
[C#/WINFORM] SendKeys 클래스 : Send 정적 메소드를 사용해 TextBox 객체에 키 입력 보내기 (0) | 2015.01.22 |
[C#/WINFORM] 거리 구하기 (0) | 2015.01.01 |
[C#/WINFORM] 이미지를 PDF 파일로 저장하기 (0) | 2014.12.31 |
[C#/WINFORM] 리소스 스트림 구하기 (0) | 2014.12.27 |
[C#/WINFORM] ClickOnce 배포하기 (0) | 2014.12.06 |
[C#/WINFORM] Application 클래스 : ThreadException 이벤트를 사용해 예외 처리하기 (0) | 2014.12.06 |
[C#/WINFORM] Application 클래스 : ExitThread 메소드를 사용해 프로그램 종료하기 (0) | 2014.12.06 |
[C#/WINFORM] Application 클래스 : Exit 메소드를 사용해 프로그램 종료하기 (0) | 2014.12.06 |
댓글을 달아 주세요