반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace App2StringImage { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void textBox1_TextChanged(object sender, EventArgs e) { Bitmap bitmap = new Bitmap(this.pictureBox1.Width , this.pictureBox1.Height); using(Graphics gr = Graphics.FromImage(bitmap)) { gr.Clear(this.pictureBox1.BackColor); if(textBox1.Text.Trim().Length > 0) { using(Brush brush = new SolidBrush(this.textBox1.ForeColor)) { SizeF size = gr.MeasureString(this.textBox1.Text , this.textBox1.Font); for (float y = 0; y < bitmap.Height; y += size.Height * 1.5f) { float x = y; while(x > 0) x -= size.Width; while (x <= bitmap.Width) { gr.DrawString(this.textBox1.Text , this.textBox1.Font , brush, x, y); x += size.Width; } } } } pictureBox1.Image = bitmap; } } } } | cs |
실행
'프로그래밍 > C#' 카테고리의 다른 글
[C#]동그란 이미지 만들기 (0) | 2018.07.01 |
---|---|
[C#] 유닉스시간 <> 윈도우시간 변환 함수 (0) | 2018.06.27 |
[C#]투명한 버튼 (0) | 2018.06.16 |
[C#]AnimateWindow (0) | 2018.06.13 |
[C#]폼을 투명하게 (0) | 2018.04.14 |