博客
关于我
c# GDI绘制简单的艺术字
阅读量:313 次
发布时间: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/

你可能感兴趣的文章
m个苹果放入n个盘子问题
查看>>
n = 3 , while n , continue
查看>>
n 叉树后序遍历转换为链表问题的深入探讨
查看>>
N!
查看>>
N-Gram的基本原理
查看>>
n1 c语言程序,全国青少年软件编程等级考试C语言经典程序题10道七
查看>>
Nacos Client常用配置
查看>>
nacos config
查看>>
Nacos Config--服务配置
查看>>
Nacos Derby 远程命令执行漏洞(QVD-2024-26473)
查看>>
Nacos 与 Eureka、Zookeeper 和 Consul 等其他注册中心的区别
查看>>
Nacos 单机集群搭建及常用生产环境配置 | Spring Cloud 3
查看>>
Nacos 启动报错[db-load-error]load jdbc.properties error
查看>>
Nacos 报Statement cancelled due to timeout or client request
查看>>
Nacos 注册服务源码分析
查看>>
Nacos 融合 Spring Cloud,成为注册配置中心
查看>>
Nacos-注册中心
查看>>
Nacos-配置中心
查看>>
Nacos2.X 源码分析:为订阅方推送、服务健康检查、集群数据同步、grpc客户端服务端初始化
查看>>
Nacos2.X 配置中心源码分析:客户端如何拉取配置、服务端配置发布客户端监听机制
查看>>