728x90
반응형
728x170
▶ MainForm.cs
using System.Drawing;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
this.pictureBox.Image = GetTransparentBitmap(this.pictureBox.Width - 10, this.pictureBox.Height - 10);
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 투명 비트맵 구하기 - GetTransparentBitmap(width, height)
/// <summary>
/// 투명 비트맵 구하기
/// </summary>
/// <param name="width">너비</param>
/// <param name="height">높이</param>
/// <returns></returns>
private Bitmap GetTransparentBitmap(int width, int height)
{
Bitmap bitmap = new Bitmap(width, height);
using(Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.Clear(Color.Transparent);
using(Pen pen = new Pen(Color.RoyalBlue, 20))
{
int ellipseWidth = width - (int)pen.Width;
int ellipseHeight = height - (int)pen.Width;
ellipseWidth = ellipseWidth < 0 ? 1 : ellipseWidth;
ellipseHeight = ellipseHeight < 0 ? 1 : ellipseHeight;
int x = (width - ellipseWidth ) / 2;
int y = (height - ellipseHeight) / 2;
graphics.DrawEllipse(pen, x, y, ellipseWidth, ellipseHeight);
}
}
return bitmap;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] Process 클래스 : BeginOutputReadLine 메소드를 사용해 도스 명령 실행 결과 구하기 (0) | 2019.10.19 |
---|---|
[C#/WINFORM] TreeView 클래스 : 드래그 & 드롭 사용하기 (0) | 2019.10.03 |
[C#/WINFORM] TreeView 클래스 : 첫번째 종말 노드 구하기 (0) | 2019.09.15 |
[C#/WINFORM] TreeView 클래스 : 특정 레벨까지 노드 확장하기 (0) | 2019.09.15 |
[C#/WINFORM] UserControl 클래스 : 환형 진행바 사용하기 (0) | 2019.08.31 |
[C#/WINFORM] Bitmap 클래스 : 투명 배경 비트맵 구하기 (0) | 2019.08.30 |
[C#/WINFORM] Form 클래스 : KeyPreview 속성을 사용해 단축키 설정하기 (0) | 2019.08.30 |
[C#/WINFORM] DesignerSerializationVisibilityAttribute 클래스 : 디자이너 모드에서 속성 코드 자동 생성 막기 (0) | 2019.08.26 |
[C#/WINFORM] 가상 리스트 박스 사용하기 (0) | 2019.08.16 |
[C#/WINFORM] Process 클래스 : GetProcessesByName 정적 메소드를 사용해 프로그램 중복 실행 여부 구하기 (0) | 2019.08.16 |
[C#/WINFORM] TextBox 클래스 : ScrollToCaret 메소드를 사용해 마지막 라인으로 스크롤하기 (0) | 2019.08.16 |
댓글을 달아 주세요