728x90
반응형
728x170
■ TextureBrush 클래스를 사용하는 방법을 보여준다.
▶ MainForm.cs
using System;
using System.Drawing;
using System.Drawing.Text;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
#region 이벤트를 설정한다.
Load += Form_Load;
#endregion
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
//////////////////////////////////////////////////////////////////////////////// Event
#region 폼 로드시 처리하기 - Form_Load(sender, e)
/// <summary>
/// 폼 로드시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void Form_Load(object sender, EventArgs e)
{
Bitmap bitmap = new Bitmap(ClientSize.Width, ClientSize.Height);
using(Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
graphics.Clear(BackColor);
using(TextureBrush brush = new TextureBrush(Image.FromFile("Image\\ColoradoFlowers.png")))
{
using(Font font = new Font("Times New Roman", 150, FontStyle.Bold))
{
graphics.DrawString("Flowers", font, brush, 0, 0);
}
}
using(TextureBrush brush = new TextureBrush(Image.FromFile("Image\\Smiley.png")))
{
using(Font font = new Font("Times New Roman", 150, FontStyle.Bold))
{
graphics.DrawString("Smile!", font, brush, 75, 175);
}
}
}
BackgroundImage = bitmap;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] 확대 창 사용하기 (0) | 2018.12.13 |
---|---|
[C#/WINFORM] 2D/3D 테두리 그리기 (0) | 2018.12.13 |
[C#/WINFORM] 소수 프랙탈(Prime Number Fractal) 그리기 (0) | 2018.12.11 |
[C#/WINFORM] PictureBox 클래스 : 이미지 드래그 하기 (0) | 2018.12.11 |
[C#/WINFORM] Region 클래스 : 특정 모양을 갖는 폼 만들기 (0) | 2018.12.10 |
[C#/WINFORM] 영역 채우기(Flood Fill) (0) | 2018.12.10 |
[C#/WINFORM] 유니코드 문자 조회하기 (0) | 2018.12.09 |
[C#/WINFORM] 움직이는 GIF 이미지 사용하기 (0) | 2018.12.09 |
[C#/WINFORM] 시어핀스키 가스켓(Sierpinski Gasket) 그리기 (0) | 2018.12.09 |
[C#/WINFORM] 원과 원의 교차 여부 구하기 (0) | 2018.12.09 |
댓글을 달아 주세요