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#实现在图像中绘制文字图形的方法
本文实例讲述了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#利用GDI绘制常见图形和文字
废话不多说,我们先来认识一下这个GDI+,看看它到底长什么样. GDI+:Graphics Device Interface Plus也就是图形设备接口,提供了各种丰富的图形图像处理功能;在C#.NET中,使用GDI+处理二维(2D)的图形和图像,使用DirectX处理三维(3D)的图形图像,图形图像处理用到的主要命名空间是System . Drawing:提供了对GDI+基本图形功能的访问,主要有Graphics类.Bitmap类.从Brush类继承的类.Font类.Icon类.Image类.
-
使用C#编写简单的图形化的可发送附件的邮件客户端程序
今天谈一下C#(WinForm)如何发送带附件的电子邮件!废话少说,先截图伺候: 首先C#发送邮件需要smtp服务的支持,我也不知道是不是C#只支持smtp协议,不过好像在MSDN里,Mail这个命名空间下只有介绍smtp的方法的,好像没看到POP的,算了,先不要说这个 我们暂时用smtp协议来做就好了!因此首先你要确保你的发件邮箱支持smtp服务,据我说知,雅虎邮箱,HotMail邮箱和GMail邮箱都不支持smtp的,不过没事,还好我们常用的QQ邮箱,163邮箱,新浪邮箱等邮箱都支持smtp
-
C#实现判断图形文件格式的方法
本文简单讲述了C#实现判断图形文件格式的方法,非常实用.分享给大家供大家参考.具体方法如下: 1. 通过文件的扩展名来判断. 这种方法比较简单,但若是有人故意改下文件扩展名,这种方法就不起作用了. 2.通过C#自身提供的方法来进行判断(判断某种确定的图片类型). 示例如下: bool isJPG = false; System.Drawing.Image img = System.Drawing.Image.FromFile(filesName); if ( img.RawFormat.Equa
-
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#编程调用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#图形区域剪切的实现方法
本文实例讲述了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#画笔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
-
c#图片处理之图片裁剪成不规则图形
为了让大家知道下面内容是否是自己想要的,我先发效果图. 好了,那就开始贴代码了 以下为一个按钮的事件,为裁剪准备图片.裁剪路径.保存路径 复制代码 代码如下: private void button1_Click(object sender, EventArgs e) { GraphicsPath path = new GraphicsPath(); Point[] p = { new
随机推荐
- Erlang中的socket编程简单例子
- 收集的10个免费的jQuery相册
- vue中component组件的props使用详解
- Android M(6.x)使用OkHttp包解析和发送JSON请求的教程
- IOS 播放系统提示音使用总结(AudioToolbox)
- VMware搭建虚拟机服务器
- 手机图片预览插件photoswipe.js使用总结
- Repeater里switch的使用方法
- PHP 验证身份证是否合法的函数
- 解析阿里云ubuntu12.04环境下配置Apache+PHP+PHPmyadmin+MYsql
- C#设计模式之Facade外观模式解决天河城购物问题示例
- 美化你的代码 vb(VBS)代码格式化的实现代码
- asp伪静态情况下实现的utf-8文件缓存实现代码
- 基于堆的基本操作的介绍
- 教你快速搭建Node.Js服务器的方法教程
- javascript实现table表格隔行变色的方法
- XP中如何完成一次全面的碎片整理
- Linux 自动分区、格式化、挂载脚本详解
- Android中闪屏实现方法小结(普通闪屏、倒计时闪屏、倒计时+动画闪屏)
- Zend Framework教程之请求对象的封装Zend_Controller_Request实例详解
