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

#region 크기 변경 비트맵 구하기 - GetScaledBitmap(sourceBitmap, scale)

/// <summary>
/// 크기 변경 비트맵 구하기
/// </summary>
/// <param name="sourceBitmap">소스 비트맵</param>
/// <param name="scale">척도</param>
/// <returns>크기 조정 비트맵</returns>
public Bitmap GetScaledBitmap(Bitmap sourceBitmap, float scale)
{
    int scaledWidth  = (int)(sourceBitmap.Width  * scale);
    int scaledHeight = (int)(sourceBitmap.Height * scale);

    Bitmap targetBitmap = new Bitmap(scaledWidth, scaledHeight);

    using(Graphics graphics = Graphics.FromImage(targetBitmap))
    {
        Rectangle targetRectangle = new Rectangle(0, 0, scaledWidth       , scaledHeight       );
        Rectangle sourceRectangle = new Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height);

        graphics.DrawImage(sourceBitmap, targetRectangle, sourceRectangle, GraphicsUnit.Pixel);
    }

    return targetBitmap;
}

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

댓글을 달아 주세요