博客
关于我
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/

你可能感兴趣的文章
Node-RED通过npm安装的方式对应卸载
查看>>
node-request模块
查看>>
node-static 任意文件读取漏洞复现(CVE-2023-26111)
查看>>
Node.js 8 中的 util.promisify的详解
查看>>
node.js debug在webstrom工具
查看>>
Node.js Event emitter 详解( 示例代码 )
查看>>
Node.js GET、POST 请求是怎样的?
查看>>
Node.js HTTP模块详解:创建服务器、响应请求与客户端请求
查看>>
Node.js RESTful API如何使用?
查看>>
node.js url模块
查看>>
Node.js Web 模块的各种用法和常见场景
查看>>
Node.js 之 log4js 完全讲解
查看>>
Node.js 函数是什么样的?
查看>>
Node.js 函数计算如何突破启动瓶颈,优化启动速度
查看>>
Node.js 切近实战(七) 之Excel在线(文件&文件组)
查看>>
node.js 初体验
查看>>
Node.js 历史
查看>>
Node.js 回调函数的原理、使用方法
查看>>
Node.js 在个推的微服务实践:基于容器的一站式命令行工具链
查看>>
Node.js 实现类似于.php,.jsp的服务器页面技术,自动路由
查看>>