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;
namespace WindowsApplication2
{
  public partial class Form11 : Form
  {
    public Form11()
    {
      InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
      LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle, Color.Empty, Color.Empty, 100);
      ColorBlend blend = new ColorBlend();
      blend.Colors = new Color[] { Color.Red, Color.Green, Color.Blue };
      blend.Positions = new float[] { 0, .5f, 1 };
      brush.InterpolationColors = blend;
      Pen pen5 = new Pen(brush);
      Graphics g5 = this.CreateGraphics();
      Point[] p = new Point[] { new Point(0, 0), new Point(100, 100), new Point(50, 100), new Point(200, 100) };
      GraphicsState old = g5.Save();
      g5.SmoothingMode = SmoothingMode.AntiAlias;
      g5.Restore(old);
      g5.DrawCurve(pen5,p);
    }
  }
}

希望本文所述对大家的C#程序设计有所帮助。

(0)

相关推荐

  • 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#图片处理之图片裁剪成不规则图形

    为了让大家知道下面内容是否是自己想要的,我先发效果图. 好了,那就开始贴代码了 以下为一个按钮的事件,为裁剪准备图片.裁剪路径.保存路径 复制代码 代码如下: private void button1_Click(object sender, EventArgs e)        {            GraphicsPath path = new GraphicsPath();            Point[] p = {                            new

  • 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# 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#(WinForm)如何发送带附件的电子邮件!废话少说,先截图伺候: 首先C#发送邮件需要smtp服务的支持,我也不知道是不是C#只支持smtp协议,不过好像在MSDN里,Mail这个命名空间下只有介绍smtp的方法的,好像没看到POP的,算了,先不要说这个 我们暂时用smtp协议来做就好了!因此首先你要确保你的发件邮箱支持smtp服务,据我说知,雅虎邮箱,HotMail邮箱和GMail邮箱都不支持smtp的,不过没事,还好我们常用的QQ邮箱,163邮箱,新浪邮箱等邮箱都支持smtp

  • 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#实现判断图形文件格式的方法,非常实用.分享给大家供大家参考.具体方法如下: 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

  • 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#实现图形区域组合操作的方法

    本文实例讲述了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 parti

随机推荐