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

#region 투명 비트맵 구하기 - GetTransparentBitmap(sourceBitmap, opacity)

/// <summary>
/// 투명 비트맵 구하기
/// </summary>
/// <param name="sourceBitmap">소스 비트맵</param>
/// <param name="opacity">투명도</param>
public Bitmap GetTransparentBitmap(Bitmap sourceBitmap, float opacity)
{
    Bitmap bitmap = new Bitmap(sourceBitmap.Width, sourceBitmap.Height);

    Graphics graphics = Graphics.FromImage(bitmap);

    ColorMatrix colorMatrix = new ColorMatrix();

    colorMatrix.Matrix33 = opacity;

    ImageAttributes imageAttributes = new ImageAttributes();

    imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

    graphics.DrawImage
    (
        sourceBitmap,
        new Rectangle(0, 0, bitmap.Width, bitmap.Height),
        0,
        0,
        sourceBitmap.Width,
        sourceBitmap.Height,
        GraphicsUnit.Pixel,
        imageAttributes
    );

    graphics.Dispose();

    return bitmap;
}

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

댓글을 달아 주세요