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#使用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#图形区域剪切的实现方法.分享给大家供大家参考.具体如下: 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#实现在图像中绘制文字图形的方法.分享给大家供大家参考.具体实现方法如下: 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#画笔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#编写简单的图形化的可发送附件的邮件客户端程序
今天谈一下C#(WinForm)如何发送带附件的电子邮件!废话少说,先截图伺候: 首先C#发送邮件需要smtp服务的支持,我也不知道是不是C#只支持smtp协议,不过好像在MSDN里,Mail这个命名空间下只有介绍smtp的方法的,好像没看到POP的,算了,先不要说这个 我们暂时用smtp协议来做就好了!因此首先你要确保你的发件邮箱支持smtp服务,据我说知,雅虎邮箱,HotMail邮箱和GMail邮箱都不支持smtp的,不过没事,还好我们常用的QQ邮箱,163邮箱,新浪邮箱等邮箱都支持smtp
-
C#利用GDI绘制常见图形和文字
废话不多说,我们先来认识一下这个GDI+,看看它到底长什么样. GDI+:Graphics Device Interface Plus也就是图形设备接口,提供了各种丰富的图形图像处理功能;在C#.NET中,使用GDI+处理二维(2D)的图形和图像,使用DirectX处理三维(3D)的图形图像,图形图像处理用到的主要命名空间是System . Drawing:提供了对GDI+基本图形功能的访问,主要有Graphics类.Bitmap类.从Brush类继承的类.Font类.Icon类.Image类.
-
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#图片处理之图片裁剪成不规则图形
为了让大家知道下面内容是否是自己想要的,我先发效果图. 好了,那就开始贴代码了 以下为一个按钮的事件,为裁剪准备图片.裁剪路径.保存路径 复制代码 代码如下: private void button1_Click(object sender, EventArgs e) { GraphicsPath path = new GraphicsPath(); Point[] p = { new
-
C#实现判断图形文件格式的方法
本文简单讲述了C#实现判断图形文件格式的方法,非常实用.分享给大家供大家参考.具体方法如下: 1. 通过文件的扩展名来判断. 这种方法比较简单,但若是有人故意改下文件扩展名,这种方法就不起作用了. 2.通过C#自身提供的方法来进行判断(判断某种确定的图片类型). 示例如下: bool isJPG = false; System.Drawing.Image img = System.Drawing.Image.FromFile(filesName); if ( img.RawFormat.Equa
-
深入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#画笔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
随机推荐
- Erlang项目内存泄漏分析方法
- Erlang实现的百度云推送Android服务端实例
- MySQL数据表字段内容的批量修改、清空、复制等更新命令
- vue2组件之select2调用的示例代码
- python实现去除下载电影和电视剧文件名中的多余字符的方法
- Android界面设计(APP设计趋势 左侧隐藏菜单右边显示content)
- vue.js中v-on:textInput无法执行事件问题的解决过程
- python实现批量下载新浪博客的方法
- 基于jquery的textarea发布框限制文字字数输入(添加中文识别)
- DropDownList实现可输入可选择(两种版本可选)
- PHP中addslashes()和stripslashes()实现字符串转义和还原用法实例
- 多文件上载系统完整版
- 详解手把手Maven搭建SpringMVC+Spring+MyBatis框架(超级详细版)
- JavaScript生成指定范围的时间列表
- python pandas dataframe 按列或者按行合并的方法
- Vue源码解析之Template转化为AST的实现方法
- 详解如何构建Promise队列实现异步函数顺序执行
- python3.7 使用pymssql往sqlserver插入数据的方法
- Django项目主urls导入应用中views的红线问题解决
- 关于pymysql模块的使用以及代码详解
