本文共 1598 字,大约阅读时间需要 5 分钟。
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Drawing.Drawing2D;using System.Drawing.Imaging;namespace yishuzi{ public partial class Form1 : Form { private Bitmap bu; private Graphics pen; private Font f; private LinearGradientBrush b; private Point p; public Form1() { InitializeComponent(); bu = new Bitmap(this.pbox.Width, this.pbox.Height); pen = Graphics.FromImage(bu); f = new Font("@方正舒体", 60, FontStyle.Bold | FontStyle.Italic); b = new LinearGradientBrush(new Point(0, 0), new Point(0, 100), Color.Red, Color.Yellow); } private void huatu() { string s = this.tbox.Text; if (s.Length == 0) return; int n = s.Length; for (int i = 0; i < n; i++) { p = new Point(70 * i, 0); pen.DrawString(s[i].ToString(), f, b, p); } } private void tbox_TextChanged(object sender, EventArgs e) { pen.Clear(Color.White); huatu(); pbox.Image = bu; } private void button1_Click(object sender, EventArgs e) { SaveFileDialog save = new SaveFileDialog(); save.Filter = "(*.ico)|*.ico|(*.png)|*.png"; if (save.ShowDialog() == DialogResult.OK) { bu.Save(save.FileName); } } }} 转载地址:http://eajq.baihongyu.com/