C#程序设计(三十一)----绘制文字

本文介绍了一个使用C#绘制文字的基本示例。通过Form1类,在窗体加载时设置绘图事件,利用Graphics对象绘制带纹理填充的文字,字体为加粗并下划线的宋体。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

* 程序的版权和版本声明部分
* Copyright (c) 2012, 烟台大学计算机学院学生
* All rights reserved.

* 作 者: 刘镇
* 完成日期: 2012 年 11 月 25 日
* 版 本 号: 3.031

* 对任务及求解方法的描述部分

* 问题描述:实现绘制文字

*代码部分:

Form1.cs:

 

 

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;

namespace Win11_3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            TextureBrush brush = new TextureBrush(Image.FromFile("001.jpg"));
            Font font = new Font("宋体", 60, FontStyle.Underline ^ FontStyle.Bold);
            g.DrawString("呵呵!C#", font, brush, new Point(80, 10));
        }

    }
}


测试结果:

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值