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

本文共 1653 字,大约阅读时间需要 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/

你可能感兴趣的文章
Netty原理分析及实战(四)-客户端与服务端双向通信
查看>>
Netty客户端断线重连实现及问题思考
查看>>
Netty工作笔记0006---NIO的Buffer说明
查看>>
Netty工作笔记0007---NIO的三大核心组件关系
查看>>
Netty工作笔记0011---Channel应用案例2
查看>>
Netty工作笔记0013---Channel应用案例4Copy图片
查看>>
Netty工作笔记0014---Buffer类型化和只读
查看>>
Netty工作笔记0020---Selectionkey在NIO体系
查看>>
Vue踩坑笔记 - 关于vue静态资源引入的问题
查看>>
Netty工作笔记0025---SocketChannel API
查看>>
Netty工作笔记0027---NIO 网络编程应用--群聊系统2--服务器编写2
查看>>
Netty工作笔记0050---Netty核心模块1
查看>>
Netty工作笔记0057---Netty群聊系统服务端
查看>>
Netty工作笔记0060---Tcp长连接和短连接_Http长连接和短连接_UDP长连接和短连接
查看>>
Netty工作笔记0063---WebSocket长连接开发2
查看>>
Netty工作笔记0070---Protobuf使用案例Codec使用
查看>>
Netty工作笔记0077---handler链调用机制实例4
查看>>
Netty工作笔记0084---通过自定义协议解决粘包拆包问题2
查看>>
Netty工作笔记0085---TCP粘包拆包内容梳理
查看>>
Netty常用组件一
查看>>