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

你可能感兴趣的文章
Nacos服务注册与发现的2种实现方法!
查看>>
nacos服务注册和发现原理简单实现案例
查看>>
Nacos服务注册总流程(源码分析)
查看>>
nacos服务注册流程
查看>>
Nacos服务部署安装
查看>>
nacos本地可以,上服务器报错
查看>>
Nacos注册Dubbo(2.7.x)以及namespace配置
查看>>
Nacos注册中心有几种调用方式?
查看>>
nacos注册失败,Feign调用失败,feign无法注入成我们的bean对象
查看>>
nacos源码 nacos注册中心1.4.x 源码 nacos源码如何下载 nacos 客户端源码下载地址 nacos discovery下载地址(一)
查看>>
nacos源码 nacos注册中心1.4.x 源码 spring cloud alibaba 的discovery做了什么 nacos客户端是如何启动的(二)
查看>>
nacos源码 nacos注册中心1.4.x 源码 如何注册服务 发送请求,nacos clinet客户端心跳 nacos 注册中心客户端如何发送的心跳 (三)
查看>>
Nacos源码分析:心跳机制、健康检查、服务发现、AP集群
查看>>
nacos看这一篇文章就够了
查看>>
Nacos简介、下载与配置持久化到Mysql
查看>>
Nacos简介和控制台服务安装
查看>>
Nacos管理界面详细介绍
查看>>
Nacos编译报错NacosException: endpoint is blank
查看>>
nacos自动刷新配置
查看>>
nacos运行报错问题之一
查看>>