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. ...
随机推荐
- vmware虚拟机安装vmware tools
为了在主机与虚拟机之间共享文件,需要安装vmware tools.在安装vmware tools的过程中遇到了几个坑,在此记录一下. 一.虚拟机关机情况下进行设置.虚拟机->设置->CD/ ...
- es安装ik后报错无法启动 read write
https://elasticsearch.cn/question/877 elasticsearch所在路径文件夹名称中带空格,路径错误
- FPM一:简单的road map(GAF)
首先要有个简单的认识: 1.FPM支持的几种UI配置界面接口: Object Instance Floorplan (OIF) Overview Page Floorplan (OVP) Guided ...
- Spring教程笔记(2) IOC
Ioc—Inversion of Control,即“控制反转”,不是什么技术,而是一种设计思想,一个重要的面向对象编程的法则,它能指导我们如何设计出松耦合.更优良的程序. 在Java开发中,Ioc意 ...
- reactjs-swiper react轮播图组件基于swiper
react轮播图组件基于swiper demo地址:http://reactjs-ui.github.io/reactjs-swiper/simple.html 1. 下载安装 npm install ...
- Eclipse无法正常启动,弹出对话框内容为 A Java Runtime...
1.Eclipse无法正常启动,弹出对话框内容为 A Java Runtime...如下图: 原因分析:由于软件版本的更新或者安装其他开发软件无意之间修改了配置文件中的路径,众所周知,Java虚拟机( ...
- SpringBoot 下 mybatis 的缓存
背景: 说起 mybatis,作为 Java 程序员应该是无人不知,它是常用的数据库访问框架.与 Spring 和 Struts 组成了 Java Web 开发的三剑客--- SSM.当然随着 Spr ...
- windows搭建redis集群最佳实践
一.redis的下载安装: (1)下载Redis-x64-3.2.100地址:https://github.com/MicrosoftArchive/redis/releases (2)安装后文件如下 ...
- 最长公共子串和子序列的Python实现,带图示。
使用矩阵来记录两个子串之间各个字符之间的对应关系. 最长子串:矩阵中数字最大的就是最长子串的长度.若对应位置字符相同,则c[i][j] = c[i-1][j-1] + 1 def longSubStr ...
- Shell编程实战
Shell编程实战 为什么要学习Shell编程 Shell脚本语言是实现Linux/Unix系统管理及自动化运维所必须的重要工具,Linux系统的底层以及基础应用软件的核心大都涉及Shell脚本的 ...