System.Drawing 封装一个 GDI+ 绘图图面。 此类不能被继承。

https://docs.microsoft.com/zh-cn/dotnet/api/system.drawing.graphics?view=netframework-4.7.2#%E6%96%B9%E6%B3%95

 using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data; public class Form1 : Form
{
public Form1()
{
this.AutoScaleBaseSize = new Size(, );
this.ClientSize = new Size(, );
this.Paint += new PaintEventHandler(this.Form1_Paint);
this.Click += new EventHandler( this.Draw );
}
static void Main()
{
Application.Run(new Form1());
} //Paint事件调用
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;//传进来的对象不需要释放 Brush brush = new SolidBrush(Color.Green);
Font font = new Font("宋体", ); g.DrawString("绘制", font, brush, , );
} //在已存在的窗体上创建Graphics对象
//窗体控件,Click事件
private void Draw(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics(); Pen pen = new Pen(Color.Red, );
Brush brush = new SolidBrush(Color.Blue);
Font font = new Font("宋体", );
Rectangle rect = new Rectangle(, , , ); g.DrawLine(pen, , , , );
g.DrawRectangle(pen, rect);
g.DrawString("GDI+图形编程", font, brush, , ); brush.Dispose(); font.Dispose(); pen.Dispose();//释放对象
g.Dispose();
}
}

Graphics类方法的使用

Graphics Class的更多相关文章

  1. DirectX Graphics Infrastructure(DXGI):最佳范例 学习笔记

    今天要学习的这篇文章写的算是比较早的了,大概在DX11时代就写好了,当时龙书11版看得很潦草,并没有注意这篇文章,现在看12,觉得是跳不过去的一篇文章,地址如下: https://msdn.micro ...

  2. Unity性能优化(4)-官方教程Optimizing graphics rendering in Unity games翻译

    本文是Unity官方教程,性能优化系列的第四篇<Optimizing graphics rendering in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...

  3. java工具类之Graphics

    利用重写paint()方法绘画出一个坐标轴: package huaxian; import java.awt.Color; import java.awt.FlowLayout; import ja ...

  4. 解决C# WinForm Graphics绘制闪烁问题

    不直接使用form的CreateGraphics创建Graphics进行绘制,可以先在Form上面放一个需要大小的PictureBox,再创建一个同大小的Bitmap,将这个Bitmap设置为Pict ...

  5. [译]Modern Core Graphics with Swift系列

    第一篇 想象一下你已经完成了你的app并且运行的很好,但是界面看上去太土,你可以在PS里面画好多不同尺寸的自定义控件,Apple并没有4x的retina屏幕. 或者你已经未雨绸缪,在代码中使用Core ...

  6. 《3D Math Primer for Graphics and Game Development》读书笔记2

    <3D Math Primer for Graphics and Game Development>读书笔记2 上一篇得到了"矩阵等价于变换后的基向量"这一结论. 本篇 ...

  7. 《3D Math Primer for Graphics and Game Development》读书笔记1

    <3D Math Primer for Graphics and Game Development>读书笔记1 本文是<3D Math Primer for Graphics and ...

  8. C#使用Graphics画圆写字

    画填充圆: Graphics gra = this.pictureBox1.CreateGraphics(); gra.SmoothingMode = System.Drawing.Drawing2D ...

  9. .net下灰度模式图像在创建Graphics时出现:无法从带有索引像素格式的图像创建graphics对象 问题的解决方案。

    在.net下,如果你加载了一副8位的灰度图像,然后想向其中绘制一些线条.或者填充一些矩形.椭圆等,都需要通过Grahpics.FromImage创建Grahphics对象,而此时会出现:无法从带有索引 ...

  10. Graphics绘图闪烁的问题

    加入获取的boardPanel.CreateGraphics()时候 用这个g去g.Clear(BackColor);时候会闪烁. 解决办法:  在绘图的时候 用 绘图的image的Graphics. ...

随机推荐

  1. ranch 源码分析(完)

    接上 ranch 源码分析(三) 在上一次,根据ranch源码把大概流程理了一遍,下面我们将一些细节解释一下. ranch只是一个服务的框架,它提供了传输层协议代码(ranch_tcp 和ranch_ ...

  2. 微信小程序-列表渲染多层嵌套循环

    微信小程序-列表渲染多层嵌套循环 入门教程之列表渲染多层嵌套循环,目前官方的文档里,主要是一维数组列表渲染的案例,还是比较简单单一,给刚入门的童鞋还是无从入手的感觉. <view wx:for= ...

  3. javascript设计模式阅读后的感悟与总结

    单例模式 用于创建唯一的一个对象. 核心在于一个判断 var index if(index){ return index; } init(); 这样只会在第一次的时候初始化创建对象,以后都不会再创建对 ...

  4. 李航《统计学习方法》CH02

    CH02 感知机 前言 章节目录 感知机模型 感知机学习策略 数据集的线性可分性 感知机学习策略 感知机学习算法 感知机学习算法 感知机学习算法的原始形式 算法的收敛性 感知机学习算法的对偶形式 导读 ...

  5. orace如何创建函数并调用

    我们来定义一个oracle的函数 create or replace function 方法名(参数名1 参数类型,参数名2 参数类型,参数名3 参数类型)return 返回类型 is num_C n ...

  6. linux-centos系统下安装python3.5.4步骤

    查看当前python版本:python -V 查看Python可执行文件位置:which python [root@localhost bin]# which python/usr/bin/pytho ...

  7. mybatis-generator 代码自动生成工具包

    怎么用mybatis-gennerator插件自动生成mybatis所需要的dao.bean.mapper xml文件.请看↓ 1.在D盘新建一个文件夹,命名:generator(或者其他盘其他名字也 ...

  8. ios和android适配问题总结

    _________________________________________________________________________________ 相关知识点 移动端. 适配(兼容). ...

  9. shell脚本实现git和svn统计log代码行

    实现的功能 git 根据传入的三个参数:起始统计日期.结束统计日期.git仓库地址. 脚本统计的是git仓库内的所有分支的log信息. 脚本统计的是指定时间段内.每一个提交人指定的git地址的所有分支 ...

  10. CString与string、char*的区别和转换

    转自:http://blog.csdn.net/luoweifu/article/details/20232379 我们在C++的开发中经常会碰到string.char*以及CString,这三种都表 ...