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. ...
随机推荐
- 解决Git Revert操作后再次Merge代码被冲掉的问题
转:https://blog.csdn.net/paul_wei2008/article/details/77477932 https://blog.csdn.net/cxn945/article/d ...
- 关于window.localtion的用法几点总结
参考链接: http://blog.csdn.net/cui_angel/article/details/7957274(1)window.location.pathname设置或获取对象指定的文件名 ...
- python 报错 TabError: inconsistent use of tabs and spaces in indentation
写python的时候如果出现如题的错误 TabError: inconsistent use of tabs and spaces in indentation 意为:制表符错误:缩进中制表符和空格使 ...
- 4、static
static (静态的),用来修饰成员. 一.特点: 1.被修饰的方法或变量随着类的加载而加载 2.优先于对象存在 3.被所有的对象共享 4.除了可以被对象调用还可以被类名直接调用 二.类变量.成员变 ...
- Request中的各种地址
今天来得匆忙,先上图吧,稍后再整理!
- webapi put 404
windows server 2016 IIS webapi 404 error In IIS select your website and double-click Handler Map ...
- pytest pluggy.manager.PluginValidationError: unknown hook 'pytest_namespace'报错处理办法
一.背景说明 上周测试的同事说pytest+allure环境在别人电脑上跑没问题,在她的环境跑却报错让帮看一下.其实pytest只是听说过allure直接没听过,但不能直接表示不会,祭出百度大法. 看 ...
- Kubernetes 入门之Kubernetes 的基本概念和术语
Kubernetes是什么? 他是一个全新的基于容器技术分布式架构领先方案: 他也是一个开放的开发平台: 他也是一个完备的分布式系统支撑平台: Kubernetes的基本慨念和术 ...
- js的事件流事件机制
(1)冒泡型事件:事件按照从最特定的事件目标到最不特定的事件目标(document对象)的顺序触发. IE 5.5: div -> body -> document IE 6.0: div ...
- springboot秒杀课程学习整理1-6
1)活动模型设计 配饰秒杀的模型(promoModel)id promoName startDate(建议使用joda-time) endDate itemId promoItemPrice 数据库( ...