Graphics Class
System.Drawing 封装一个 GDI+ 绘图图面。 此类不能被继承。
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的更多相关文章
- DirectX Graphics Infrastructure(DXGI):最佳范例 学习笔记
今天要学习的这篇文章写的算是比较早的了,大概在DX11时代就写好了,当时龙书11版看得很潦草,并没有注意这篇文章,现在看12,觉得是跳不过去的一篇文章,地址如下: https://msdn.micro ...
- Unity性能优化(4)-官方教程Optimizing graphics rendering in Unity games翻译
本文是Unity官方教程,性能优化系列的第四篇<Optimizing graphics rendering in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...
- java工具类之Graphics
利用重写paint()方法绘画出一个坐标轴: package huaxian; import java.awt.Color; import java.awt.FlowLayout; import ja ...
- 解决C# WinForm Graphics绘制闪烁问题
不直接使用form的CreateGraphics创建Graphics进行绘制,可以先在Form上面放一个需要大小的PictureBox,再创建一个同大小的Bitmap,将这个Bitmap设置为Pict ...
- [译]Modern Core Graphics with Swift系列
第一篇 想象一下你已经完成了你的app并且运行的很好,但是界面看上去太土,你可以在PS里面画好多不同尺寸的自定义控件,Apple并没有4x的retina屏幕. 或者你已经未雨绸缪,在代码中使用Core ...
- 《3D Math Primer for Graphics and Game Development》读书笔记2
<3D Math Primer for Graphics and Game Development>读书笔记2 上一篇得到了"矩阵等价于变换后的基向量"这一结论. 本篇 ...
- 《3D Math Primer for Graphics and Game Development》读书笔记1
<3D Math Primer for Graphics and Game Development>读书笔记1 本文是<3D Math Primer for Graphics and ...
- C#使用Graphics画圆写字
画填充圆: Graphics gra = this.pictureBox1.CreateGraphics(); gra.SmoothingMode = System.Drawing.Drawing2D ...
- .net下灰度模式图像在创建Graphics时出现:无法从带有索引像素格式的图像创建graphics对象 问题的解决方案。
在.net下,如果你加载了一副8位的灰度图像,然后想向其中绘制一些线条.或者填充一些矩形.椭圆等,都需要通过Grahpics.FromImage创建Grahphics对象,而此时会出现:无法从带有索引 ...
- Graphics绘图闪烁的问题
加入获取的boardPanel.CreateGraphics()时候 用这个g去g.Clear(BackColor);时候会闪烁. 解决办法: 在绘图的时候 用 绘图的image的Graphics. ...
随机推荐
- 复杂的xml资源
某些资源类型是由XML文件表示的多个复杂资源的组合.例子是一个animated vector drawable,它是一个封装了vector drawable和动画的drawable资源.这需要使用至少 ...
- Appium TestNg Maven Android Eclipse java自动化环境搭建
1.环境准备 1)Eclipse + maven + appium + TestNg 确保已经在Eclipse 上面安装maven TestNg的插件 2)打开Eclipse,新建一个maven项目 ...
- 移动端跨平台方案对比:React Native、weex、Flutter
跨平台一直是老生常谈的话题,cordova.ionic.react-native.weex.kotlin-native.flutter等跨平台框架百花齐放,颇有一股推倒原生开发者的势头. 为什么我们需 ...
- python 读取文件read.csv报错 OSError: Initializing from file failed
小编在用python 读取文件read.csv的时候 报了一个错误 OSError: Initializing from file failed 初始化 文件失败 检查了文件路径,没问题 那应该是我文 ...
- redis 高可用
Redis-Sentinel是Redis官方推荐的高可用性(HA)解决方案,当用Redis做Master-slave的高可用方案时,假如master宕机了,Redis本身(包括它的很多客户端)都没有实 ...
- Vue插槽:(2.6.0以后版本弃用slot和slot-scope,改用v-slot)
关于Vue插槽的概念,大家可以从vue官网的api查看,我是看到网站的对于初接触 这个要概念的人来说不是很清楚,我来贴下原码,就比较直观了 贴下原码: 具名插槽:v-slot:header Html: ...
- react component onClick 函数带参数
<div onClick={this.toggleTip(true)}></div> toggleTip = shouldShowTip => () => { th ...
- 1-TwoSum(简单)
Description: Given an array of integers, return indices of the two numbers such that they add up to ...
- STL 小白学习(8) set 二叉树
#include <iostream> using namespace std; #include <set> void printSet(set<int> s) ...
- 非root安装fastDFS及启动
引用https://www.cnblogs.com/zzw-zyba/p/10155781.html 非root安装部分 1.解包 [bdc@svr001 setup]$ tar -xvf lib ...