첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
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
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요