C#实现图形区域组合操作的方法
本文实例讲述了C#实现图形区域组合操作的方法。分享给大家供大家参考。具体实现方法如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace advanced_drawing
{
public partial class Form17 : Form
{
public Form17()
{
InitializeComponent();
}
private void Form17_Paint(object sender, PaintEventArgs e)
{
Rectangle regionRect = new Rectangle(20, 20, 100, 100);
e.Graphics.DrawRectangle(Pens.Black, regionRect);
RectangleF unionRect = new RectangleF(90, 30, 100, 100);
e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(unionRect));
Region myRegion = new Region(regionRect);
//myRegion.Union(unionRect);
//myRegion.Intersect(unionRect);
//myRegion.Exclude(unionRect);
//myRegion.Complement(unionRect);
myRegion.Xor(unionRect);
SolidBrush myBrush = new SolidBrush(Color.Blue);
e.Graphics.FillRegion(myBrush, myRegion);
}
}
}
希望本文所述对大家的C#程序设计有所帮助。
相关推荐
-
深入C# winform清除由GDI绘制出来的所有线条或图形的解决方法
在C#winform应用程序中,可以用GDI绘制出线条或图形.1.在主窗体上绘制线条或图形 复制代码 代码如下: using (Graphics g = this.CreateGraphics()) { g.DrawLine(Pens.Blue, new Point(10, 10), new Point(100, 100)); } 2.在指定的容器上绘制线条或图形,如在panel1上绘制 复制代码 代码如下: using (Graphics g = th
-
c#图片处理之图片裁剪成不规则图形
为了让大家知道下面内容是否是自己想要的,我先发效果图. 好了,那就开始贴代码了 以下为一个按钮的事件,为裁剪准备图片.裁剪路径.保存路径 复制代码 代码如下: private void button1_Click(object sender, EventArgs e) { GraphicsPath path = new GraphicsPath(); Point[] p = { new
-
C#实现在图像中绘制文字图形的方法
本文实例讲述了C#实现在图像中绘制文字图形的方法.分享给大家供大家参考.具体实现方法如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; using S
-
C#使用Region对图形区域构造和填充的方法
本文实例讲述了C#使用Region对图形区域构造和填充的方法.分享给大家供大家参考.具体如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; names
-
使用C#编写简单的图形化的可发送附件的邮件客户端程序
今天谈一下C#(WinForm)如何发送带附件的电子邮件!废话少说,先截图伺候: 首先C#发送邮件需要smtp服务的支持,我也不知道是不是C#只支持smtp协议,不过好像在MSDN里,Mail这个命名空间下只有介绍smtp的方法的,好像没看到POP的,算了,先不要说这个 我们暂时用smtp协议来做就好了!因此首先你要确保你的发件邮箱支持smtp服务,据我说知,雅虎邮箱,HotMail邮箱和GMail邮箱都不支持smtp的,不过没事,还好我们常用的QQ邮箱,163邮箱,新浪邮箱等邮箱都支持smtp
-
C#编程调用Cards.dll实现图形化发牌功能示例
本文实例讲述了C#编程调用Cards.dll实现图形化发牌功能.分享给大家供大家参考,具体如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices
-
C#画笔Pen保存和恢复图形对象的设置方法
本文实例讲述了C#画笔Pen保存和恢复图形对象的设置方法.分享给大家供大家参考.具体如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespa
-
C#利用GDI绘制常见图形和文字
废话不多说,我们先来认识一下这个GDI+,看看它到底长什么样. GDI+:Graphics Device Interface Plus也就是图形设备接口,提供了各种丰富的图形图像处理功能;在C#.NET中,使用GDI+处理二维(2D)的图形和图像,使用DirectX处理三维(3D)的图形图像,图形图像处理用到的主要命名空间是System . Drawing:提供了对GDI+基本图形功能的访问,主要有Graphics类.Bitmap类.从Brush类继承的类.Font类.Icon类.Image类.
-
C#图形区域剪切的实现方法
本文实例讲述了C#图形区域剪切的实现方法.分享给大家供大家参考.具体如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace advan
-
C#实现判断图形文件格式的方法
本文简单讲述了C#实现判断图形文件格式的方法,非常实用.分享给大家供大家参考.具体方法如下: 1. 通过文件的扩展名来判断. 这种方法比较简单,但若是有人故意改下文件扩展名,这种方法就不起作用了. 2.通过C#自身提供的方法来进行判断(判断某种确定的图片类型). 示例如下: bool isJPG = false; System.Drawing.Image img = System.Drawing.Image.FromFile(filesName); if ( img.RawFormat.Equa
-
C#画笔Pen使用路径绘制图形的方法
本文实例讲述了C#画笔Pen使用路径绘制图形的方法.分享给大家供大家参考.具体实现方法如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namesp
随机推荐
- Windows下Postgresql数据库的下载与配置方法
- jQuery实现悬浮在右上角的网页客服效果代码
- 基于jQuery的为attr添加id title等效果的实现代码
- js/jquery判断浏览器类型的方法小结
- WWW 网页视觉传达设计的原则
- apache无法启动的可能原因分析及对策
- php将字符串转化成date存入数据库的两种方式
- PHP轻量级数据库操作类Medoo增加、删除、修改、查询例子
- node.js中的events.emitter.removeListener方法使用说明
- DirectoryEntry配置IIS7出现ADSI Error:未知错误(0x80005000)
- Web前端框架bootstrap实战【第一次接触使用】
- Python简单生成8位随机密码的方法
- Oracle 查询死锁并解锁的终极处理方法
- 多个checkbox被选中时如何判断是否有自己想要的
- JavaScript实现刷新不重记的倒计时
- Mybatis中的resultType和resultMap查询操作实例详解
- C++ 数据结构链表的实现代码
- JavaScrpt判断一个数是否是质数的实例代码
- 提权函数之RtlAdjustPrivilege()使用说明
- 网吧Windows XP母盘制作详解
