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

■ Size 구조체를 사용해 축소/확대하는 방법을 보여준다.

 

▶ Size 구조체 : 축소/확대하기 예제 (C#)

using System;
using System.Drawing;

Console.WriteLine(Scale(new Size(100, 100), 80).ToString()); // 80% 크기

 

▶ Size 구조체 : 축소/확대하기 (C#)

using System;
using System.Drawing;

#region 축소/확대하기 - Scale(source, scale)

/// <summary>
/// 축소/확대하기
/// </summary>
/// <param name="source">소스 크기</param>
/// <param name="scale">축적</param>
/// <returns>크기</returns>
public Size Scale(Size source, float scale)
{
    if(Math.Abs(scale - 1) < float.Epsilon)
    {
        return source;
    }

    int height = (int)(source.Height * (scale / 100));
    int width  = (int)(source.Width  * (scale / 100));

    return new Size(width, height);
}

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

댓글을 달아 주세요