博客
关于我
c# GDI绘制简单的艺术字
阅读量:303 次
发布时间:2019-03-04

本文共 2154 字,大约阅读时间需要 7 分钟。

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);            //透明            //bu.MakeTransparent();            pen = Graphics.FromImage(bu);            //看看有多少种字体 哪个好看            //FontDialog a=new FontDialog();            //a.ShowDialog();            //设置字体  大小  样式加粗+倾斜            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++)            {                //设置每个字符的位置 占70   字体大小是60                p = new Point(70 * i, 0);                //字符string  字体font 刷子brush 坐标point                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/

你可能感兴趣的文章
EMLOG模板山河网站主题分享
查看>>
2019数字音乐市场年度回顾,QQ音乐全面领先
查看>>
花1亿扶持优质红人,如涵推动网红经济出圈之路有何深意?
查看>>
抢滩抖音、B站,快手港股IPO进程加速
查看>>
Linux中的虚拟内存机制和内存映射
查看>>
Android系统启动系列5 SystemServer进程下
查看>>
Android四大组件系列9 ContentProvider原理
查看>>
理解PendingIntent
查看>>
Android SurfaceFlinger4 提交Buffer
查看>>
深入理解 ClientLifecycleManager 机制
查看>>
android基础知识回顾--ContentProvider简单用法
查看>>
压缩解压
查看>>
js try{}catch(){}finally{}语句
查看>>
PAT (Basic Level) Practice (中文)——1005 继续(3n+1)猜想 (25分)
查看>>
PAT (Basic Level) Practice (中文)——1011 A+B 和 C (15分)
查看>>
i711700K和r55600x差距大不大 i7 11700K和r5 5600x对比哪个好
查看>>
R3 PRO 3200G和r7 3700u 哪个好
查看>>
入手评测 联想小新Pro14和Air14Plus哪个好?区别对比
查看>>
程序人生:没有伞的孩子要学会奔跑
查看>>
Express Animate for mac(动画特效制作软件)
查看>>