这个包含所有GDI+小例子,我积分不够,只能代码!

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Threading;
using System.IO;
using System.Reflection;

using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace GDIPlusDemo
{
 /// 
 /// Form1 的摘要说明。
 /// 
 public class Form1 : System.Windows.Forms.Form
 {
  private System.Windows.Forms.MainMenu mainMenu1;
  private System.Windows.Forms.MenuItem menuItem1;
  private System.Windows.Forms.MenuItem FadeInOut;
  private System.Windows.Forms.MenuItem GrayScale;
  private System.Windows.Forms.MenuItem Inverse;
  private System.Windows.Forms.MenuItem Emboss;
  private System.Windows.Forms.MenuItem CreatePenFromBrush;
  private System.Windows.Forms.MenuItem menuItem2;
  private System.Windows.Forms.MenuItem DashStyle_Custom;
  private System.Windows.Forms.MenuItem Pen_Align;
  private System.Windows.Forms.MenuItem Pen_Tranform;
  private System.Windows.Forms.MenuItem Pen_LineCap;
  private System.Windows.Forms.MenuItem Pen_TransColor;
  private System.Windows.Forms.MenuItem menuItem3;
  private System.Windows.Forms.MenuItem Brush_SolidBrush;
  private System.Windows.Forms.MenuItem Brush_FillVurve;
  private System.Windows.Forms.MenuItem Brush_HatchBrush;
  private System.Windows.Forms.MenuItem Brush_EnumAllStyle;
  private System.Windows.Forms.MenuItem Brush_SetRenderingOrigin;
  private System.Windows.Forms.MenuItem Brush_Texture;
  private System.Windows.Forms.MenuItem Brush_Texture_WrapMode;
  private System.Windows.Forms.MenuItem Brush_TextureTransform;
  private System.Windows.Forms.MenuItem Brush_GetTextureMatrix;
  private System.Windows.Forms.MenuItem Brush_LinearGradientBrush;
  private System.Windows.Forms.MenuItem Brush_LinearArrange;
  private System.Windows.Forms.MenuItem Brush_LinearGradientMode;
  private System.Windows.Forms.MenuItem Brush_LinearAngle;
  private System.Windows.Forms.MenuItem Brush_LinearInterpolation;
  private System.Windows.Forms.MenuItem Brush_LinearCustomize;
  private System.Windows.Forms.MenuItem menuItem7;
  private System.Windows.Forms.MenuItem menuItem6;
  private System.Windows.Forms.MenuItem menuItem5;
  private System.Windows.Forms.MenuItem menuItem10;
  private System.Windows.Forms.MenuItem Brush_LinearGradientBrush_BellShape;
  private System.Windows.Forms.MenuItem menuItem4;
  private System.Windows.Forms.MenuItem Brush_PathGradientBrush_Star;
  private System.Windows.Forms.MenuItem Brush_PathGradientBrush_Star2;
  private System.Windows.Forms.MenuItem Brush_Using_MorePathGradientBrush;
  private System.Windows.Forms.MenuItem Brush_PathGradientBrush_WrapMode;
  private System.Windows.Forms.MenuItem Brush_PathGradientBrush_CenterPoint;
  private System.Windows.Forms.MenuItem Brush_PathGradientBrush_InterpolationColors;
  private System.Windows.Forms.MenuItem Brsuh_PathGradietBrush_Focus;
  private System.Windows.Forms.MenuItem Brush_PathGradientBrush_Transform;
  private System.Windows.Forms.MenuItem Brsuh_LinearGradientBrush_UsingGamma;
  private System.Windows.Forms.MenuItem menuItem8;
  private System.Windows.Forms.MenuItem Font_UsingFontInGDIPlus;
  private System.Windows.Forms.MenuItem Font_EnumAllFonts;
  private System.Windows.Forms.MenuItem menuItem9;
  private System.Windows.Forms.MenuItem Font_EnhanceFontDialog;
  private System.Windows.Forms.MenuItem Font_UsingTextRenderHint;
  private System.Windows.Forms.MenuItem Font_Privatefontcollection;
  private System.Windows.Forms.MenuItem Font_Privatefontcollection2;
  private System.Windows.Forms.MenuItem Font_IsStyleAvailable;
  private System.Windows.Forms.MenuItem Font_Size;
  private System.Windows.Forms.MenuItem Font_BaseLine;
  private System.Windows.Forms.MenuItem Font_DrawString;
  private System.Windows.Forms.MenuItem Font_MeasureString;
  private System.Windows.Forms.MenuItem Font_MeasureString2;
  private System.Windows.Forms.MenuItem Font_ColumnTextOut;
  private System.Windows.Forms.MenuItem Font_StirngTrimming;
  private System.Windows.Forms.MenuItem Font_TextOutClip;
  private System.Windows.Forms.MenuItem Font_MeasureCharacterRanges;
  private System.Windows.Forms.MenuItem Font_TextoutDirection;
  private System.Windows.Forms.MenuItem Font_TextAlignment;
  private System.Windows.Forms.MenuItem Font_TextAlignment2;
  private System.Windows.Forms.MenuItem Font_TextoutUsingTabs;
  private System.Windows.Forms.MenuItem Font_UsingTabs;
  private System.Windows.Forms.MenuItem Font_TextoutHotkeyPrefix;
  private System.Windows.Forms.MenuItem Font_TextoutShadow;
  private System.Windows.Forms.MenuItem Font_TextoutHashline;
  private System.Windows.Forms.MenuItem Font_TextoutTexture;
  private System.Windows.Forms.MenuItem Font_TextoutGradient;
  private System.Windows.Forms.MenuItem Path_Construct;
  private System.Windows.Forms.MenuItem Path_AddLines;
  private System.Windows.Forms.MenuItem Path_CloseFigure;
  private System.Windows.Forms.MenuItem Path_FillPath;
  private System.Windows.Forms.MenuItem Path_AddSubPath;
  private System.Windows.Forms.MenuItem Path_GetSubPath;
  private System.Windows.Forms.MenuItem Path_GetPoints;
  private System.Windows.Forms.MenuItem Path_PathData;
  private System.Windows.Forms.MenuItem Path_ViewPointFLAG;
  private System.Windows.Forms.MenuItem Path_SubPathRange;
  private System.Windows.Forms.MenuItem Path_Flatten;
  private System.Windows.Forms.MenuItem Path_Warp;
  private System.Windows.Forms.MenuItem Path_Transform;
  private System.Windows.Forms.MenuItem Path_Widen;
  private System.Windows.Forms.MenuItem Path_WidenDemo;
  private System.Windows.Forms.MenuItem Region_FromPath;
  private System.Windows.Forms.MenuItem Region_Calculate;
  private System.Windows.Forms.MenuItem Region_GetRects;
  private System.Windows.Forms.MenuItem menuItem11;
  private System.Windows.Forms.MenuItem Transform;
  private System.Windows.Forms.MenuItem TranslateTransform;
  private System.Windows.Forms.MenuItem RotateTransform;
  private System.Windows.Forms.MenuItem DrawWatch;
  private System.Windows.Forms.MenuItem ScaleTransform;
  private System.Windows.Forms.MenuItem RectScale;
  private System.Windows.Forms.MenuItem FontRotate;
  private System.Windows.Forms.MenuItem Matrix_ListElements;
  private System.Windows.Forms.MenuItem MatrixPos;
  private System.Windows.Forms.MenuItem Martrix_Invert;
  private System.Windows.Forms.MenuItem Matrix_Multiply;
  private System.Windows.Forms.MenuItem Matrix_TransformPoints;
  private System.Windows.Forms.MenuItem Matrix_TransformPoints2;
  private System.Windows.Forms.MenuItem Matrix_TransformVectors;
  private System.Windows.Forms.MenuItem Matrix_RotateAt;
  private System.Windows.Forms.MenuItem Matrix_Shear;
  private System.Windows.Forms.MenuItem Matrix_TextoutShear;
  private System.Windows.Forms.MenuItem Matrix_ChangeFontHeight;
  private System.Windows.Forms.MenuItem menuItem12;
  private System.Windows.Forms.MenuItem ColorMatrix_Start;
  private System.Windows.Forms.MenuItem TranslateColor;
  private System.Windows.Forms.MenuItem ScaleColor;
  private System.Windows.Forms.MenuItem RotateColor;
  private System.Windows.Forms.MenuItem ColorShear;
  private System.Windows.Forms.MenuItem ColorRemap;
  private System.Windows.Forms.MenuItem SetRGBOutputChannel;
  private System.Windows.Forms.MenuItem menuItem13;
  private System.Windows.Forms.MenuItem Metafile;
  private System.Windows.Forms.MenuItem CroppingAndScaling;
  private System.Windows.Forms.MenuItem UsingInterpolationMode;
  private System.Windows.Forms.MenuItem RotateFlip;
  private System.Windows.Forms.MenuItem ImageSkewing;
  private System.Windows.Forms.MenuItem Cubeimage;
  private System.Windows.Forms.MenuItem ThumbnailImage;
  private System.Windows.Forms.MenuItem Clone;
  private System.Windows.Forms.MenuItem Picturescale;
  private System.Windows.Forms.MenuItem menuItem15;
  private System.Windows.Forms.MenuItem ImageAttributesSetNoOp;
  private System.Windows.Forms.MenuItem SetColorMatrices;
  private System.Windows.Forms.MenuItem SetOutputChannelColorProfile;
  private System.Windows.Forms.MenuItem Gammaadjust;
  private System.Windows.Forms.MenuItem SetOutputChannel;
  private System.Windows.Forms.MenuItem Colorkey;
  private System.Windows.Forms.MenuItem Setthreshold;
  private System.Windows.Forms.MenuItem AdjustedPalette;
  private System.Windows.Forms.MenuItem SetWrapMode;
  private System.Windows.Forms.MenuItem menuItem16;
  private System.Windows.Forms.MenuItem ListAllImageEncoders;
  private System.Windows.Forms.MenuItem ListImageEncoder_Detail;
  private System.Windows.Forms.MenuItem ListImageDecoder;
  private System.Windows.Forms.MenuItem GetEncoderParameter;
  private System.Windows.Forms.MenuItem GetAllEncoderParameter;
  private System.Windows.Forms.MenuItem menuItem17;
  private System.Windows.Forms.MenuItem MultipleFrameImage;
  private System.Windows.Forms.MenuItem SaveBmp2tif;
  private System.Windows.Forms.MenuItem SaveBMP2JPG;
  private System.Windows.Forms.MenuItem TransformingJPEG;
  private System.Windows.Forms.MenuItem GetImageFromMultyFrame;
  private System.Windows.Forms.MenuItem QueryImage;
  private System.Windows.Forms.MenuItem SetProp;
  private System.Windows.Forms.MenuItem menuItem18;
  private System.Windows.Forms.MenuItem OnCanvas;
  private System.Windows.Forms.MenuItem OnWood;
  private System.Windows.Forms.MenuItem Flashligt;
  private System.Windows.Forms.MenuItem BlurAndSharpen;
        private Label label1;
        private System.Windows.Forms.Timer timer1;
        private IContainer components;
  
  
  //private AxThreed.AxSSRibbon axSSRibbon1;
        // private AxThreed.AxSSFrame axSSFrame1;

  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();
   

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// 
  /// 清理所有正在使用的资源。
  /// 
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null) 
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows Form Designer generated code
  /// 
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// 
  private void InitializeComponent()
  {
            this.components = new System.ComponentModel.Container();
            this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
            this.menuItem1 = new System.Windows.Forms.MenuItem();
            this.menuItem2 = new System.Windows.Forms.MenuItem();
            this.CreatePenFromBrush = new System.Windows.Forms.MenuItem();
            this.DashStyle_Custom = new System.Windows.Forms.MenuItem();
            this.Pen_Align = new System.Windows.Forms.MenuItem();
            this.Pen_Tranform = new System.Windows.Forms.MenuItem();
            this.Pen_LineCap = new System.Windows.Forms.MenuItem();
            this.Pen_TransColor = new System.Windows.Forms.MenuItem();
            this.menuItem3 = new System.Windows.Forms.MenuItem();
            this.menuItem5 = new System.Windows.Forms.MenuItem();
            this.Brush_SolidBrush = new System.Windows.Forms.MenuItem();
            this.Brush_FillVurve = new System.Windows.Forms.MenuItem();
            this.menuItem10 = new System.Windows.Forms.MenuItem();
            this.Brush_HatchBrush = new System.Windows.Forms.MenuItem();
            this.Brush_EnumAllStyle = new System.Windows.Forms.MenuItem();
            this.Brush_SetRenderingOrigin = new System.Windows.Forms.MenuItem();
            this.menuItem7 = new System.Windows.Forms.MenuItem();
            this.Brush_Texture = new System.Windows.Forms.MenuItem();
            this.Brush_Texture_WrapMode = new System.Windows.Forms.MenuItem();
            this.Brush_TextureTransform = new System.Windows.Forms.MenuItem();
            this.Brush_GetTextureMatrix = new System.Windows.Forms.MenuItem();
            this.menuItem6 = new System.Windows.Forms.MenuItem();
            this.Brush_LinearGradientBrush = new System.Windows.Forms.MenuItem();
            this.Brush_LinearArrange = new System.Windows.Forms.MenuItem();
            this.Brush_LinearInterpolation = new System.Windows.Forms.MenuItem();
            this.Brush_LinearGradientMode = new System.Windows.Forms.MenuItem();
            this.Brush_LinearAngle = new System.Windows.Forms.MenuItem();
            this.Brush_LinearCustomize = new System.Windows.Forms.MenuItem();
            this.Brush_LinearGradientBrush_BellShape = new System.Windows.Forms.MenuItem();
            this.Brsuh_LinearGradientBrush_UsingGamma = new System.Windows.Forms.MenuItem();
            this.menuItem4 = new System.Windows.Forms.MenuItem();
            this.Brush_PathGradientBrush_Star = new System.Windows.Forms.MenuItem();
            this.Brush_PathGradientBrush_Star2 = new System.Windows.Forms.MenuItem();
            this.Brush_Using_MorePathGradientBrush = new System.Windows.Forms.MenuItem();
            this.Brush_PathGradientBrush_WrapMode = new System.Windows.Forms.MenuItem();
            this.Brush_PathGradientBrush_CenterPoint = new System.Windows.Forms.MenuItem();
            this.Brush_PathGradientBrush_InterpolationColors = new System.Windows.Forms.MenuItem();
            this.Brsuh_PathGradietBrush_Focus = new System.Windows.Forms.MenuItem();
            this.Brush_PathGradientBrush_Transform = new System.Windows.Forms.MenuItem();
            this.menuItem8 = new System.Windows.Forms.MenuItem();
            this.Font_UsingFontInGDIPlus = new System.Windows.Forms.MenuItem();
            this.Font_EnumAllFonts = new System.Windows.Forms.MenuItem();
            this.Font_EnhanceFontDialog = new System.Windows.Forms.MenuItem();
            this.Font_UsingTextRenderHint = new System.Windows.Forms.MenuItem();
            this.Font_Privatefontcollection = new System.Windows.Forms.MenuItem();
            this.Font_Privatefontcollection2 = new System.Windows.Forms.MenuItem();
            this.Font_IsStyleAvailable = new System.Windows.Forms.MenuItem();
            this.Font_Size = new System.Windows.Forms.MenuItem();
            this.Font_BaseLine = new System.Windows.Forms.MenuItem();
            this.Font_DrawString = new System.Windows.Forms.MenuItem();
            this.Font_MeasureString = new System.Windows.Forms.MenuItem();
            this.Font_MeasureString2 = new System.Windows.Forms.MenuItem();
            this.Font_ColumnTextOut = new System.Windows.Forms.MenuItem();
            this.Font_StirngTrimming = new System.Windows.Forms.MenuItem();
            this.Font_TextOutClip = new System.Windows.Forms.MenuItem();
            this.Font_MeasureCharacterRanges = new System.Windows.Forms.MenuItem();
            this.Font_TextoutDirection = new System.Windows.Forms.MenuItem();
            this.Font_TextAlignment = new System.Windows.Forms.MenuItem();
            this.Font_TextAlignment2 = new System.Windows.Forms.MenuItem();
            this.Font_TextoutUsingTabs = new System.Windows.Forms.MenuItem();
            this.Font_UsingTabs = new System.Windows.Forms.MenuItem();
            this.Font_TextoutHotkeyPrefix = new System.Windows.Forms.MenuItem();
            this.Font_TextoutShadow = new System.Windows.Forms.MenuItem();
            this.Font_TextoutHashline = new System.Windows.Forms.MenuItem();
            this.Font_TextoutTexture = new System.Windows.Forms.MenuItem();
            this.Font_TextoutGradient = new System.Windows.Forms.MenuItem();
            this.menuItem9 = new System.Windows.Forms.MenuItem();
            this.Path_Construct = new System.Windows.Forms.MenuItem();
            this.Path_AddLines = new System.Windows.Forms.MenuItem();
            this.Path_CloseFigure = new System.Windows.Forms.MenuItem();
            this.Path_FillPath = new System.Windows.Forms.MenuItem();
            this.Path_AddSubPath = new System.Windows.Forms.MenuItem();
            this.Path_GetSubPath = new System.Windows.Forms.MenuItem();
            this.Path_GetPoints = new System.Windows.Forms.MenuItem();
            this.Path_PathData = new System.Windows.Forms.MenuItem();
            this.Path_ViewPointFLAG = new System.Windows.Forms.MenuItem();
            this.Path_SubPathRange = new System.Windows.Forms.MenuItem();
            this.Path_Flatten = new System.Windows.Forms.MenuItem();
            this.Path_Warp = new System.Windows.Forms.MenuItem();
            this.Path_Transform = new System.Windows.Forms.MenuItem();
            this.Path_Widen = new System.Windows.Forms.MenuItem();
            this.Path_WidenDemo = new System.Windows.Forms.MenuItem();
            this.Region_FromPath = new System.Windows.Forms.MenuItem();
            this.Region_Calculate = new System.Windows.Forms.MenuItem();
            this.Region_GetRects = new System.Windows.Forms.MenuItem();
            this.menuItem11 = new System.Windows.Forms.MenuItem();
            this.Transform = new System.Windows.Forms.MenuItem();
            this.TranslateTransform = new System.Windows.Forms.MenuItem();
            this.RotateTransform = new System.Windows.Forms.MenuItem();
            this.DrawWatch = new System.Windows.Forms.MenuItem();
            this.ScaleTransform = new System.Windows.Forms.MenuItem();
            this.RectScale = new System.Windows.Forms.MenuItem();
            this.FontRotate = new System.Windows.Forms.MenuItem();
            this.Matrix_ListElements = new System.Windows.Forms.MenuItem();
            this.MatrixPos = new System.Windows.Forms.MenuItem();
            this.Martrix_Invert = new System.Windows.Forms.MenuItem();
            this.Matrix_Multiply = new System.Windows.Forms.MenuItem();
            this.Matrix_TransformPoints = new System.Windows.Forms.MenuItem();
            this.Matrix_TransformPoints2 = new System.Windows.Forms.MenuItem();
            this.Matrix_TransformVectors = new System.Windows.Forms.MenuItem();
            this.Matrix_RotateAt = new System.Windows.Forms.MenuItem();
            this.Matrix_Shear = new System.Windows.Forms.MenuItem();
            this.Matrix_TextoutShear = new System.Windows.Forms.MenuItem();
            this.Matrix_ChangeFontHeight = new System.Windows.Forms.MenuItem();
            this.menuItem12 = new System.Windows.Forms.MenuItem();
            this.ColorMatrix_Start = new System.Windows.Forms.MenuItem();
            this.TranslateColor = new System.Windows.Forms.MenuItem();
            this.ScaleColor = new System.Windows.Forms.MenuItem();
            this.RotateColor = new System.Windows.Forms.MenuItem();
            this.ColorShear = new System.Windows.Forms.MenuItem();
            this.ColorRemap = new System.Windows.Forms.MenuItem();
            this.SetRGBOutputChannel = new System.Windows.Forms.MenuItem();
            this.menuItem13 = new System.Windows.Forms.MenuItem();
            this.Metafile = new System.Windows.Forms.MenuItem();
            this.CroppingAndScaling = new System.Windows.Forms.MenuItem();
            this.UsingInterpolationMode = new System.Windows.Forms.MenuItem();
            this.RotateFlip = new System.Windows.Forms.MenuItem();
            this.ImageSkewing = new System.Windows.Forms.MenuItem();
            this.Cubeimage = new System.Windows.Forms.MenuItem();
            this.ThumbnailImage = new System.Windows.Forms.MenuItem();
            this.Clone = new System.Windows.Forms.MenuItem();
            this.Picturescale = new System.Windows.Forms.MenuItem();
            this.menuItem15 = new System.Windows.Forms.MenuItem();
            this.ImageAttributesSetNoOp = new System.Windows.Forms.MenuItem();
            this.SetColorMatrices = new System.Windows.Forms.MenuItem();
            this.SetOutputChannelColorProfile = new System.Windows.Forms.MenuItem();
            this.Gammaadjust = new System.Windows.Forms.MenuItem();
            this.SetOutputChannel = new System.Windows.Forms.MenuItem();
            this.Colorkey = new System.Windows.Forms.MenuItem();
            this.Setthreshold = new System.Windows.Forms.MenuItem();
            this.AdjustedPalette = new System.Windows.Forms.MenuItem();
            this.SetWrapMode = new System.Windows.Forms.MenuItem();
            this.menuItem16 = new System.Windows.Forms.MenuItem();
            this.ListAllImageEncoders = new System.Windows.Forms.MenuItem();
            this.ListImageEncoder_Detail = new System.Windows.Forms.MenuItem();
            this.ListImageDecoder = new System.Windows.Forms.MenuItem();
            this.GetEncoderParameter = new System.Windows.Forms.MenuItem();
            this.GetAllEncoderParameter = new System.Windows.Forms.MenuItem();
            this.menuItem17 = new System.Windows.Forms.MenuItem();
            this.SaveBmp2tif = new System.Windows.Forms.MenuItem();
            this.SaveBMP2JPG = new System.Windows.Forms.MenuItem();
            this.TransformingJPEG = new System.Windows.Forms.MenuItem();
            this.MultipleFrameImage = new System.Windows.Forms.MenuItem();
            this.GetImageFromMultyFrame = new System.Windows.Forms.MenuItem();
            this.QueryImage = new System.Windows.Forms.MenuItem();
            this.SetProp = new System.Windows.Forms.MenuItem();
            this.menuItem18 = new System.Windows.Forms.MenuItem();
            this.FadeInOut = new System.Windows.Forms.MenuItem();
            this.GrayScale = new System.Windows.Forms.MenuItem();
            this.Inverse = new System.Windows.Forms.MenuItem();
            this.Emboss = new System.Windows.Forms.MenuItem();
            this.OnCanvas = new System.Windows.Forms.MenuItem();
            this.OnWood = new System.Windows.Forms.MenuItem();
            this.Flashligt = new System.Windows.Forms.MenuItem();
            this.BlurAndSharpen = new System.Windows.Forms.MenuItem();
            this.label1 = new System.Windows.Forms.Label();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.SuspendLayout();
            // 
            // mainMenu1
            // 
            this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuItem1});
            // 
            // menuItem1
            // 
            this.menuItem1.Index = 0;
            this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuItem2,
            this.menuItem3,
            this.menuItem8,
            this.menuItem9,
            this.menuItem11,
            this.menuItem12,
            this.menuItem13,
            this.menuItem15,
            this.menuItem16,
            this.menuItem18});
            this.menuItem1.Text = "GDI+编程";
            // 
            // menuItem2
            // 
            this.menuItem2.Index = 0;
            this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.CreatePenFromBrush,
            this.DashStyle_Custom,
            this.Pen_Align,
            this.Pen_Tranform,
            this.Pen_LineCap,
            this.Pen_TransColor});
            this.menuItem2.Text = "画笔";
            // 
            // CreatePenFromBrush
            // 
            this.CreatePenFromBrush.Index = 0;
            this.CreatePenFromBrush.Text = "从画刷中构造画笔";
            this.CreatePenFromBrush.Click += new System.EventHandler(this.CreatePenFromBrush_Click);
            // 
            // DashStyle_Custom
            // 
            this.DashStyle_Custom.Index = 1;
            this.DashStyle_Custom.Text = "自定义线型";
            this.DashStyle_Custom.Click += new System.EventHandler(this.DashStyle_Custom_Click);
            // 
            // Pen_Align
            // 
            this.Pen_Align.Index = 2;
            this.Pen_Align.Text = "画笔的对齐方式";
            this.Pen_Align.Click += new System.EventHandler(this.Pen_Align_Click);
            // 
            // Pen_Tranform
            // 
            this.Pen_Tranform.Index = 3;
            this.Pen_Tranform.Text = "画笔的缩放与旋转";
            this.Pen_Tranform.Click += new System.EventHandler(this.Pen_Tranform_Click);
            // 
            // Pen_LineCap
            // 
            this.Pen_LineCap.Index = 4;
            this.Pen_LineCap.Text = "画笔的线帽属性";
            this.Pen_LineCap.Click += new System.EventHandler(this.Pen_LineCap_Click);
            // 
            // Pen_TransColor
            // 
            this.Pen_TransColor.Index = 5;
            this.Pen_TransColor.Text = "画笔的透明度支持";
            this.Pen_TransColor.Click += new System.EventHandler(this.Pen_TransColor_Click);
            // 
            // menuItem3
            // 
            this.menuItem3.Index = 1;
            this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuItem5,
            this.menuItem10,
            this.menuItem7,
            this.menuItem6,
            this.menuItem4});
            this.menuItem3.Text = "画刷";
            // 
            // menuItem5
            // 
            this.menuItem5.Index = 0;
            this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.Brush_SolidBrush,
            this.Brush_FillVurve});
            this.menuItem5.Text = "单色画刷的使用";
            // 
            // Brush_SolidBrush
            // 
            this.Brush_SolidBrush.Index = 0;
            this.Brush_SolidBrush.Text = "简单的单色画刷";
            this.Brush_SolidBrush.Click += new System.EventHandler(this.Brush_SolidBrush_Click);
            // 
            // Brush_FillVurve
            // 
            this.Brush_FillVurve.Index = 1;
            this.Brush_FillVurve.Text = "填充正叶曲线";
            this.Brush_FillVurve.Click += new System.EventHandler(this.Brush_FillVurve_Click);
            // 
            // menuItem10
            // 
            this.menuItem10.Index = 1;
            this.menuItem10.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.Brush_HatchBrush,
            this.Brush_EnumAllStyle,
            this.Brush_SetRenderingOrigin});
            this.menuItem10.Text = "影线画刷的使用";
            // 
            // Brush_HatchBrush
            // 
            this.Brush_HatchBrush.Index = 0;
            this.Brush_HatchBrush.Text = "影线画刷";
            this.Brush_HatchBrush.Click += new System.EventHandler(this.Brush_HatchBrush_Click);
            // 
            // Brush_EnumAllStyle
            // 
            this.Brush_EnumAllStyle.Index = 1;
            this.Brush_EnumAllStyle.Text = "枚举所有影线画刷风格";
            this.Brush_EnumAllStyle.Click += new System.EventHandler(this.Brush_EnumAllStyle_Click);
            // 
            // Brush_SetRenderingOrigin
            // 
            this.Brush_SetRenderingOrigin.Index = 2;
            this.Brush_SetRenderingOrigin.Text = "设置绘制原点";
            this.Brush_SetRenderingOrigin.Click += new System.EventHandler(this.Brush_SetRenderingOrigin_Click);
            // 
            // menuItem7
            // 
            this.menuItem7.Index = 2;
            this.menuItem7.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.Brush_Texture,
            this.Brush_Texture_WrapMode,
            this.Brush_TextureTransform,
            this.Brush_GetTextureMatrix});
            this.menuItem7.Text = "纹理画刷";
            // 
            // Brush_Texture
            // 
            this.Brush_Texture.Index = 0;
            this.Brush_Texture.Text = "纹理画刷的基本使用";
            this.Brush_Texture.Click += new System.EventHandler(this.Brush_Texture_Click);
            // 
            // Brush_Texture_WrapMode
            // 
            this.Brush_Texture_WrapMode.Index = 1;
            this.Brush_Texture_WrapMode.Text = "纹理画刷的排列方式";
            this.Brush_Texture_WrapMode.Click += new System.EventHandler(this.Brush_Texture_WrapMode_Click);
            // 
            // Brush_TextureTransform
            // 
            this.Brush_TextureTransform.Index = 2;
            this.Brush_TextureTransform.Text = "纹理画刷的变换";
            this.Brush_TextureTransform.Click += new System.EventHandler(this.Brush_TextureTransform_Click);
            // 
            // Brush_GetTextureMatrix
            // 
            this.Brush_GetTextureMatrix.Index = 3;
            this.Brush_GetTextureMatrix.Text = "查询画刷的变换信息";
            this.Brush_GetTextureMatrix.Click += new System.EventHandler(this.Brush_GetTextureMatrix_Click);
            // 
            // menuItem6
            // 
            this.menuItem6.Index = 3;
            this.menuItem6.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.Brush_LinearGradientBrush,
            this.Brush_LinearArrange,
            this.Brush_LinearInterpolation,
            this.Brush_LinearGradientMode,
            this.Brush_LinearAngle,
            this.Brush_LinearCustomize,
            this.Brush_LinearGradientBrush_BellShape,
            this.Brsuh_LinearGradientBrush_UsingGamma});
            this.menuItem6.Text = "线性渐变画刷的使用";
            // 
            // Brush_LinearGradientBrush
            // 
            this.Brush_LinearGradientBrush.Index = 0;
            this.Brush_LinearGradientBrush.Text = "线性渐变画刷";
            this.Brush_LinearGradientBrush.Click += new System.EventHandler(this.Brush_LinearGradientBrush_Click);
            // 
            // Brush_LinearArrange
            // 
            this.Brush_LinearArrange.Index = 1;
            this.Brush_LinearArrange.Text = "渐变画刷的不同填充方式";
            this.Brush_LinearArrange.Click += new System.EventHandler(this.Brush_LinearArrange_Click);
            // 
            // Brush_LinearInterpolation
            // 
            this.Brush_LinearInterpolation.Index = 2;
            this.Brush_LinearInterpolation.Text = "多色渐变画刷";
            this.Brush_LinearInterpolation.Click += new System.EventHandler(this.Brush_LinearInterpolation_Click);
            // 
            // Brush_LinearGradientMode
            // 
            this.Brush_LinearGradientMode.Index = 3;
            this.Brush_LinearGradientMode.Text = "使用渐变画刷的渐变模式";
            this.Brush_LinearGradientMode.Click += new System.EventHandler(this.Brush_LinearGradientMode_Click);
            // 
            // Brush_LinearAngle
            // 
            this.Brush_LinearAngle.Index = 4;
            this.Brush_LinearAngle.Text = "调整渐变线偏转角度";
            this.Brush_LinearAngle.Click += new System.EventHandler(this.Brush_LinearAngle_Click);
            // 
            // Brush_LinearCustomize
            // 
            this.Brush_LinearCustomize.Index = 5;
            this.Brush_LinearCustomize.Text = "自定义线性渐变画刷的渐变过程";
            this.Brush_LinearCustomize.Click += new System.EventHandler(this.Brush_LinearCustomize_Click);
            // 
            // Brush_LinearGradientBrush_BellShape
            // 
            this.Brush_LinearGradientBrush_BellShape.Index = 6;
            this.Brush_LinearGradientBrush_BellShape.Text = "钟形曲线渐变";
            this.Brush_LinearGradientBrush_BellShape.Click += new System.EventHandler(this.Brush_LinearGradientBrush_BellShape_Click);
            // 
            // Brsuh_LinearGradientBrush_UsingGamma
            // 
            this.Brsuh_LinearGradientBrush_UsingGamma.Index = 7;
            this.Brsuh_LinearGradientBrush_UsingGamma.Text = "启用Gamma校正";
            this.Brsuh_LinearGradientBrush_UsingGamma.Click += new System.EventHandler(this.Brsuh_LinearGradientBrush_UsingGamma_Click);
            // 
            // menuItem4
            // 
            this.menuItem4.Index = 4;
            this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.Brush_PathGradientBrush_Star,
            this.Brush_PathGradientBrush_Star2,
            this.Brush_Using_MorePathGradientBrush,
            this.Brush_PathGradientBrush_WrapMode,
            this.Brush_PathGradientBrush_CenterPoint,
            this.Brush_PathGradientBrush_InterpolationColors,
            this.Brsuh_PathGradietBrush_Focus,
            this.Brush_PathGradientBrush_Transform});
            this.menuItem4.Text = "路径渐变画刷";
            // 
            // Brush_PathGradientBrush_Star
            // 
            this.Brush_PathGradientBrush_Star.Index = 0;
            this.Brush_PathGradientBrush_Star.Text = "构造五星";
            this.Brush_PathGradientBrush_Star.Click += new System.EventHandler(this.Brush_PathGradientBrush_Star_Click);
            // 
            // Brush_PathGradientBrush_Star2
            // 
            this.Brush_PathGradientBrush_Star2.Index = 1;
            this.Brush_PathGradientBrush_Star2.Text = "构造五星(2)";
            this.Brush_PathGradientBrush_Star2.Click += new System.EventHandler(this.Brush_PathGradientBrush_Star2_Click);
            // 
            // Brush_Using_MorePathGradientBrush
            // 
            this.Brush_Using_MorePathGradientBrush.Index = 2;
            this.Brush_Using_MorePathGradientBrush.Text = "使用不同的路径渐变画刷";
            this.Brush_Using_MorePathGradientBrush.Click += new System.EventHandler(this.Brush_Using_MorePathGradientBrush_Click);
            // 
            // Brush_PathGradientBrush_WrapMode
            // 
            this.Brush_PathGradientBrush_WrapMode.Index = 3;
            this.Brush_PathGradientBrush_WrapMode.Text = "路径渐变画刷的排列方式";
            this.Brush_PathGradientBrush_WrapMode.Click += new System.EventHandler(this.Brush_PathGradientBrush_WrapMode_Click);
            // 
            // Brush_PathGradientBrush_CenterPoint
            // 
            this.Brush_PathGradientBrush_CenterPoint.Index = 4;
            this.Brush_PathGradientBrush_CenterPoint.Text = "更改路径渐变画刷的中心点";
            this.Brush_PathGradientBrush_CenterPoint.Click += new System.EventHandler(this.Brush_PathGradientBrush_CenterPoint_Click);
            // 
            // Brush_PathGradientBrush_InterpolationColors
            // 
            this.Brush_PathGradientBrush_InterpolationColors.Index = 5;
            this.Brush_PathGradientBrush_InterpolationColors.Text = "使用多色渐变";
            this.Brush_PathGradientBrush_InterpolationColors.Click += new System.EventHandler(this.Brush_PathGradientBrush_InterpolationColors_Click);
            // 
            // Brsuh_PathGradietBrush_Focus
            // 
            this.Brsuh_PathGradietBrush_Focus.Index = 6;
            this.Brsuh_PathGradietBrush_Focus.Text = "更改画刷的焦点缩放比例";
            this.Brsuh_PathGradietBrush_Focus.Click += new System.EventHandler(this.Brsuh_PathGradietBrush_Focus_Click);
            // 
            // Brush_PathGradientBrush_Transform
            // 
            this.Brush_PathGradientBrush_Transform.Index = 7;
            this.Brush_PathGradientBrush_Transform.Text = "路径渐变画刷的变换";
            this.Brush_PathGradientBrush_Transform.Click += new System.EventHandler(this.Brush_PathGradientBrush_Transform_Click);
            // 
            // menuItem8
            // 
            this.menuItem8.Index = 2;
            this.menuItem8.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.Font_UsingFontInGDIPlus,
            this.Font_EnumAllFonts,
            this.Font_EnhanceFontDialog,
            this.Font_UsingTextRenderHint,
            this.Font_Privatefontcollection,
            this.Font_Privatefontcollection2,
            this.Font_IsStyleAvailable,
            this.Font_Size,
            this.Font_BaseLine,
            this.Font_DrawString,
            this.Font_MeasureString,
            this.Font_MeasureString2,
            this.Font_ColumnTextOut,
            this.Font_StirngTrimming,
            this.Font_TextOutClip,
            this.Font_MeasureCharacterRanges,
            this.Font_TextoutDirection,
            this.Font_TextAlignment,
            this.Font_TextAlignment2,
            this.Font_TextoutUsingTabs,
            this.Font_UsingTabs,
            this.Font_TextoutHotkeyPrefix,
            this.Font_TextoutShadow,
            this.Font_TextoutHashline,
            this.Font_TextoutTexture,
            this.Font_TextoutGradient});
            this.menuItem8.Text = "文本与字体";
            // 
            // Font_UsingFontInGDIPlus
            // 
            this.Font_UsingFontInGDIPlus.Index = 0;
            this.Font_UsingFontInGDIPlus.Text = "在GDI+中使用字体(&A)";
            this.Font_UsingFontInGDIPlus.Click += new System.EventHandler(this.Font_UsingFontInGDIPlus_Click);
            // 
            // Font_EnumAllFonts
            // 
            this.Font_EnumAllFonts.Index = 1;
            this.Font_EnumAllFonts.Text = "获取已安装的字体";
            this.Font_EnumAllFonts.Click += new System.EventHandler(this.Font_EnumAllFonts_Click);
            // 
            // Font_EnhanceFontDialog
            // 
            this.Font_EnhanceFontDialog.Index = 2;
            this.Font_EnhanceFontDialog.Text = "增强型字体选择对话框";
            this.Font_EnhanceFontDialog.Click += new System.EventHandler(this.Font_EnhanceFontDialog_Click);
            // 
            // Font_UsingTextRenderHint
            // 
            this.Font_UsingTextRenderHint.Index = 3;
            this.Font_UsingTextRenderHint.Text = "设置字体的边缘处理方式";
            this.Font_UsingTextRenderHint.Click += new System.EventHandler(this.Font_UsingTextRenderHint_Click);
            // 
            // Font_Privatefontcollection
            // 
            this.Font_Privatefontcollection.Index = 4;
            this.Font_Privatefontcollection.Text = "使用私有字体集合";
            this.Font_Privatefontcollection.Click += new System.EventHandler(this.Font_Privatefontcollection_Click);
            // 
            // Font_Privatefontcollection2
            // 
            this.Font_Privatefontcollection2.Index = 5;
            this.Font_Privatefontcollection2.Text = "在私有字体集合中使用多个字体";
            this.Font_Privatefontcollection2.Click += new System.EventHandler(this.Font_Privatefontcollection2_Click);
            // 
            // Font_IsStyleAvailable
            // 
            this.Font_IsStyleAvailable.Index = 6;
            this.Font_IsStyleAvailable.Text = "在私有字体集合中检查字体信息的可用性";
            this.Font_IsStyleAvailable.Click += new System.EventHandler(this.Font_IsStyleAvailable_Click);
            // 
            // Font_Size
            // 
            this.Font_Size.Index = 7;
            this.Font_Size.Text = "在程序中访问字体(系列)的大小信息";
            this.Font_Size.Click += new System.EventHandler(this.Font_Size_Click);
            // 
            // Font_BaseLine
            // 
            this.Font_BaseLine.Index = 8;
            this.Font_BaseLine.Text = "设置文本输出的基线";
            this.Font_BaseLine.Click += new System.EventHandler(this.Font_BaseLine_Click);
            // 
            // Font_DrawString
            // 
            this.Font_DrawString.Index = 9;
            this.Font_DrawString.Text = "使用GDI+绘制文本";
            this.Font_DrawString.Click += new System.EventHandler(this.Font_DrawString_Click);
            // 
            // Font_MeasureString
            // 
            this.Font_MeasureString.Index = 10;
            this.Font_MeasureString.Text = "测量文本";
            this.Font_MeasureString.Click += new System.EventHandler(this.Font_MeasureString_Click);
            // 
            // Font_MeasureString2
            // 
            this.Font_MeasureString2.Index = 11;
            this.Font_MeasureString2.Text = "计算指定区域中能够显示的字符总数及行数";
            this.Font_MeasureString2.Click += new System.EventHandler(this.Font_MeasureString2_Click);
            // 
            // Font_ColumnTextOut
            // 
            this.Font_ColumnTextOut.Index = 12;
            this.Font_ColumnTextOut.Text = "实现文件的分栏显示";
            this.Font_ColumnTextOut.Click += new System.EventHandler(this.Font_ColumnTextOut_Click);
            // 
            // Font_StirngTrimming
            // 
            this.Font_StirngTrimming.Index = 13;
            this.Font_StirngTrimming.Text = "字符串的去尾";
            this.Font_StirngTrimming.Click += new System.EventHandler(this.Font_StirngTrimming_Click);
            // 
            // Font_TextOutClip
            // 
            this.Font_TextOutClip.Index = 14;
            this.Font_TextOutClip.Text = "文本输出的剪裁修正";
            this.Font_TextOutClip.Click += new System.EventHandler(this.Font_TextOutClip_Click);
            // 
            // Font_MeasureCharacterRanges
            // 
            this.Font_MeasureCharacterRanges.Index = 15;
            this.Font_MeasureCharacterRanges.Text = "测量文本的局部输出区域";
            this.Font_MeasureCharacterRanges.Click += new System.EventHandler(this.Font_MeasureCharacterRanges_Click);
            // 
            // Font_TextoutDirection
            // 
            this.Font_TextoutDirection.Index = 16;
            this.Font_TextoutDirection.Text = "控制文本输出方向";
            this.Font_TextoutDirection.Click += new System.EventHandler(this.Font_TextoutDirection_Click);
            // 
            // Font_TextAlignment
            // 
            this.Font_TextAlignment.Index = 17;
            this.Font_TextAlignment.Text = "设置文本对齐方式";
            this.Font_TextAlignment.Click += new System.EventHandler(this.Font_TextAlignment_Click);
            // 
            // Font_TextAlignment2
            // 
            this.Font_TextAlignment2.Index = 18;
            this.Font_TextAlignment2.Text = "设置文本对齐方式(2)";
            this.Font_TextAlignment2.Click += new System.EventHandler(this.Font_TextAlignment2_Click);
            // 
            // Font_TextoutUsingTabs
            // 
            this.Font_TextoutUsingTabs.Index = 19;
            this.Font_TextoutUsingTabs.Text = "设置和获取制表符信息";
            this.Font_TextoutUsingTabs.Click += new System.EventHandler(this.Font_TextoutUsingTabs_Click);
            // 
            // Font_UsingTabs
            // 
            this.Font_UsingTabs.Index = 20;
            this.Font_UsingTabs.Text = "使用制表位进行表格输出";
            this.Font_UsingTabs.Click += new System.EventHandler(this.Font_UsingTabs_Click);
            // 
            // Font_TextoutHotkeyPrefix
            // 
            this.Font_TextoutHotkeyPrefix.Index = 21;
            this.Font_TextoutHotkeyPrefix.Text = "快捷键前导字符显示";
            this.Font_TextoutHotkeyPrefix.Click += new System.EventHandler(this.Font_TextoutHotkeyPrefix_Click);
            // 
            // Font_TextoutShadow
            // 
            this.Font_TextoutShadow.Index = 22;
            this.Font_TextoutShadow.Text = "阴影字特效";
            this.Font_TextoutShadow.Click += new System.EventHandler(this.Font_TextoutShadow_Click);
            // 
            // Font_TextoutHashline
            // 
            this.Font_TextoutHashline.Index = 23;
            this.Font_TextoutHashline.Text = "使用影线画刷绘制文本";
            this.Font_TextoutHashline.Click += new System.EventHandler(this.Font_TextoutHashline_Click);
            // 
            // Font_TextoutTexture
            // 
            this.Font_TextoutTexture.Index = 24;
            this.Font_TextoutTexture.Text = "绘制纹理字";
            this.Font_TextoutTexture.Click += new System.EventHandler(this.Font_TextoutTexture_Click);
            // 
            // Font_TextoutGradient
            // 
            this.Font_TextoutGradient.Index = 25;
            this.Font_TextoutGradient.Text = "使用渐变画刷绘制文本";
            this.Font_TextoutGradient.Click += new System.EventHandler(this.Font_TextoutGradient_Click);
            // 
            // menuItem9
            // 
            this.menuItem9.Index = 3;
            this.menuItem9.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.Path_Construct,
            this.Path_AddLines,
            this.Path_CloseFigure,
            this.Path_FillPath,
            this.Path_AddSubPath,
            this.Path_GetSubPath,
            this.Path_GetPoints,
            this.Path_PathData,
            this.Path_ViewPointFLAG,
            this.Path_SubPathRange,
            this.Path_Flatten,
            this.Path_Warp,
            this.Path_Transform,
            this.Path_Widen,
            this.Path_WidenDemo,
            this.Region_FromPath,
            this.Region_Calculate,
            this.Region_GetRects});
            this.menuItem9.Text = "路径和区域";
            this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
            // 
            // Path_Construct
            // 
            this.Path_Construct.Index = 0;
            this.Path_Construct.Text = "构造路径";
            this.Path_Construct.Click += new System.EventHandler(this.Path_Construct_Click);
            // 
            // Path_AddLines
            // 
            this.Path_AddLines.Index = 1;
            this.Path_AddLines.Text = "在路径中添加多条线段";
            this.Path_AddLines.Click += new System.EventHandler(this.Path_AddLines_Click);
            // 
            // Path_CloseFigure
            // 
            this.Path_CloseFigure.Index = 2;
            this.Path_CloseFigure.Text = "封闭图形";
            this.Path_CloseFigure.Click += new System.EventHandler(this.Path_CloseFigure_Click);
            // 
            // Path_FillPath
            // 
            this.Path_FillPath.Index = 3;
            this.Path_FillPath.Text = "路径的填充";
            this.Path_FillPath.Click += new System.EventHandler(this.Path_FillPath_Click);
            // 
            // Path_AddSubPath
            // 
            this.Path_AddSubPath.Index = 4;
            this.Path_AddSubPath.Text = "添加子路径";
            this.Path_AddSubPath.Click += new System.EventHandler(this.Path_AddSubPath_Click);
            // 
            // Path_GetSubPath
            // 
            this.Path_GetSubPath.Index = 5;
            this.Path_GetSubPath.Text = "GraphicsPathIterator的基本使用";
            this.Path_GetSubPath.Click += new System.EventHandler(this.Path_GetSubPath_Click);
            // 
            // Path_GetPoints
            // 
            this.Path_GetPoints.Index = 6;
            this.Path_GetPoints.Text = "访问路径的点信息";
            this.Path_GetPoints.Click += new System.EventHandler(this.Path_GetPoints_Click);
            // 
            // Path_PathData
            // 
            this.Path_PathData.Index = 7;
            this.Path_PathData.Text = "同时获取端点坐标及类型信息";
            this.Path_PathData.Click += new System.EventHandler(this.Path_PathData_Click);
            // 
            // Path_ViewPointFLAG
            // 
            this.Path_ViewPointFLAG.Index = 8;
            this.Path_ViewPointFLAG.Text = "查看路径端点的标记信息";
            this.Path_ViewPointFLAG.Click += new System.EventHandler(this.Path_ViewPointFLAG_Click);
            // 
            // Path_SubPathRange
            // 
            this.Path_SubPathRange.Index = 9;
            this.Path_SubPathRange.Text = "标记路径区间";
            this.Path_SubPathRange.Click += new System.EventHandler(this.Path_SubPathRange_Click);
            // 
            // Path_Flatten
            // 
            this.Path_Flatten.Index = 10;
            this.Path_Flatten.Text = "路径的展平";
            this.Path_Flatten.Click += new System.EventHandler(this.Path_Flatten_Click);
            // 
            // Path_Warp
            // 
            this.Path_Warp.Index = 11;
            this.Path_Warp.Text = "路径的扭曲";
            this.Path_Warp.Click += new System.EventHandler(this.Path_Warp_Click);
            // 
            // Path_Transform
            // 
            this.Path_Transform.Index = 12;
            this.Path_Transform.Text = "路径的线性变换";
            this.Path_Transform.Click += new System.EventHandler(this.Path_Transform_Click);
            // 
            // Path_Widen
            // 
            this.Path_Widen.Index = 13;
            this.Path_Widen.Text = "路径的拓宽";
            this.Path_Widen.Click += new System.EventHandler(this.Path_Widen_Click);
            // 
            // Path_WidenDemo
            // 
            this.Path_WidenDemo.Index = 14;
            this.Path_WidenDemo.Text = "路径的拓宽处理原理演示";
            this.Path_WidenDemo.Click += new System.EventHandler(this.Path_WidenDemo_Click);
            // 
            // Region_FromPath
            // 
            this.Region_FromPath.Index = 15;
            this.Region_FromPath.Text = "从路径中创建文本区域";
            this.Region_FromPath.Click += new System.EventHandler(this.Region_FromPath_Click);
            // 
            // Region_Calculate
            // 
            this.Region_Calculate.Index = 16;
            this.Region_Calculate.Text = "区域的运算";
            this.Region_Calculate.Click += new System.EventHandler(this.Region_Calculate_Click);
            // 
            // Region_GetRects
            // 
            this.Region_GetRects.Index = 17;
            this.Region_GetRects.Text = "获取区域的组成矩形集";
            this.Region_GetRects.Click += new System.EventHandler(this.Region_GetRects_Click);
            // 
            // menuItem11
            // 
            this.menuItem11.Index = 4;
            this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.Transform,
            this.TranslateTransform,
            this.RotateTransform,
            this.DrawWatch,
            this.ScaleTransform,
            this.RectScale,
            this.FontRotate,
            this.Matrix_ListElements,
            this.MatrixPos,
            this.Martrix_Invert,
            this.Matrix_Multiply,
            this.Matrix_TransformPoints,
            this.Matrix_TransformPoints2,
            this.Matrix_TransformVectors,
            this.Matrix_RotateAt,
            this.Matrix_Shear,
            this.Matrix_TextoutShear,
            this.Matrix_ChangeFontHeight});
            this.menuItem11.Text = "GDI+的坐标变换";
            // 
            // Transform
            // 
            this.Transform.Index = 0;
            this.Transform.Text = "在GDI+使用坐标变换";
            this.Transform.Click += new System.EventHandler(this.Transform_Click);
            // 
            // TranslateTransform
            // 
            this.TranslateTransform.Index = 1;
            this.TranslateTransform.Text = "平移变换的实现";
            this.TranslateTransform.Click += new System.EventHandler(this.TranslateTransform_Click);
            // 
            // RotateTransform
            // 
            this.RotateTransform.Index = 2;
            this.RotateTransform.Text = "旋转图片";
            this.RotateTransform.Click += new System.EventHandler(this.RotateTransform_Click);
            // 
            // DrawWatch
            // 
            this.DrawWatch.Index = 3;
            this.DrawWatch.Text = "汽车里程表的绘制";
            this.DrawWatch.Click += new System.EventHandler(this.DrawWatch_Click);
            // 
            // ScaleTransform
            // 
            this.ScaleTransform.Index = 4;
            this.ScaleTransform.Text = "缩放变换的使用";
            this.ScaleTransform.Click += new System.EventHandler(this.ScaleTransform_Click);
            // 
            // RectScale
            // 
            this.RectScale.Index = 5;
            this.RectScale.Text = "矩形对象的缩放";
            this.RectScale.Click += new System.EventHandler(this.RectScale_Click);
            // 
            // FontRotate
            // 
            this.FontRotate.Index = 6;
            this.FontRotate.Text = "在GDI+中旋转输出文本";
            this.FontRotate.Click += new System.EventHandler(this.FontRotate_Click);
            // 
            // Matrix_ListElements
            // 
            this.Matrix_ListElements.Index = 7;
            this.Matrix_ListElements.Text = "查看矩阵的组成元素";
            this.Matrix_ListElements.Click += new System.EventHandler(this.Matrix_ListElements_Click_1);
            // 
            // MatrixPos
            // 
            this.MatrixPos.Index = 8;
            this.MatrixPos.Text = "使用矩阵的前置与后缀";
            this.MatrixPos.Click += new System.EventHandler(this.MatrixPos_Click);
            // 
            // Martrix_Invert
            // 
            this.Martrix_Invert.Index = 9;
            this.Martrix_Invert.Text = "逆矩阵在变换中的运用";
            this.Martrix_Invert.Click += new System.EventHandler(this.Martrix_Invert_Click);
            // 
            // Matrix_Multiply
            // 
            this.Matrix_Multiply.Index = 10;
            this.Matrix_Multiply.Text = "使用复合变换";
            this.Matrix_Multiply.Click += new System.EventHandler(this.Matrix_Multiply_Click);
            // 
            // Matrix_TransformPoints
            // 
            this.Matrix_TransformPoints.Index = 11;
            this.Matrix_TransformPoints.Text = "使用矩阵批量修改点信息/r/n /r/n";
            this.Matrix_TransformPoints.Click += new System.EventHandler(this.Matrix_TransformPoints_Click);
            // 
            // Matrix_TransformPoints2
            // 
            this.Matrix_TransformPoints2.Index = 12;
            this.Matrix_TransformPoints2.Text = "使用TransformPoints函数实现路径的变换/r/n /r/n";
            this.Matrix_TransformPoints2.Click += new System.EventHandler(this.Matrix_TransformPoints2_Click);
            // 
            // Matrix_TransformVectors
            // 
            this.Matrix_TransformVectors.Index = 13;
            this.Matrix_TransformVectors.Text = "普通矩阵运算与二维向量的矩阵运算";
            this.Matrix_TransformVectors.Click += new System.EventHandler(this.Matrix_TransformVectors_Click);
            // 
            // Matrix_RotateAt
            // 
            this.Matrix_RotateAt.Index = 14;
            this.Matrix_RotateAt.Text = "使用RotateAt函数";
            this.Matrix_RotateAt.Click += new System.EventHandler(this.Matrix_RotateAt_Click);
            // 
            // Matrix_Shear
            // 
            this.Matrix_Shear.Index = 15;
            this.Matrix_Shear.Text = "使用不同的投射变换显示图片";
            this.Matrix_Shear.Click += new System.EventHandler(this.Matrix_Shear_Click);
            // 
            // Matrix_TextoutShear
            // 
            this.Matrix_TextoutShear.Index = 16;
            this.Matrix_TextoutShear.Text = "投影字的特效输出";
            this.Matrix_TextoutShear.Click += new System.EventHandler(this.Matrix_TextoutShear_Click);
            // 
            // Matrix_ChangeFontHeight
            // 
            this.Matrix_ChangeFontHeight.Index = 17;
            this.Matrix_ChangeFontHeight.Text = "文字大小渐变输出特效";
            this.Matrix_ChangeFontHeight.Click += new System.EventHandler(this.Matrix_ChangeFontHeight_Click);
            // 
            // menuItem12
            // 
            this.menuItem12.Index = 5;
            this.menuItem12.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.ColorMatrix_Start,
            this.TranslateColor,
            this.ScaleColor,
            this.RotateColor,
            this.ColorShear,
            this.ColorRemap,
            this.SetRGBOutputChannel});
            this.menuItem12.Text = "GDI+的色彩变换";
            // 
            // ColorMatrix_Start
            // 
            this.ColorMatrix_Start.Index = 0;
            this.ColorMatrix_Start.Text = "启用色彩变换矩阵";
            this.ColorMatrix_Start.Click += new System.EventHandler(this.ColorMatrix_Start_Click);
            // 
            // TranslateColor
            // 
            this.TranslateColor.Index = 1;
            this.TranslateColor.Text = "色彩平移运算";
            this.TranslateColor.Click += new System.EventHandler(this.TranslateColor_Click);
            // 
            // ScaleColor
            // 
            this.ScaleColor.Index = 2;
            this.ScaleColor.Text = "色彩的缩放运算";
            this.ScaleColor.Click += new System.EventHandler(this.ScaleColor_Click);
            // 
            // RotateColor
            // 
            this.RotateColor.Index = 3;
            this.RotateColor.Text = "色彩的三种旋转方式";
            this.RotateColor.Click += new System.EventHandler(this.RotateColor_Click);
            // 
            // ColorShear
            // 
            this.ColorShear.Index = 4;
            this.ColorShear.Text = "色彩的投射变换";
            this.ColorShear.Click += new System.EventHandler(this.ColorShear_Click);
            // 
            // ColorRemap
            // 
            this.ColorRemap.Index = 5;
            this.ColorRemap.Text = "色彩映射的程序实现";
            this.ColorRemap.Click += new System.EventHandler(this.ColorRemap_Click);
            // 
            // SetRGBOutputChannel
            // 
            this.SetRGBOutputChannel.Index = 6;
            this.SetRGBOutputChannel.Text = "使用色彩变换矩阵实现色彩输出通道";
            this.SetRGBOutputChannel.Click += new System.EventHandler(this.SetRGBOutputChannel_Click);
            // 
            // menuItem13
            // 
            this.menuItem13.Index = 6;
            this.menuItem13.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.Metafile,
            this.CroppingAndScaling,
            this.UsingInterpolationMode,
            this.RotateFlip,
            this.ImageSkewing,
            this.Cubeimage,
            this.ThumbnailImage,
            this.Clone,
            this.Picturescale});
            this.menuItem13.Text = "图像的基本处理";
            // 
            // Metafile
            // 
            this.Metafile.Index = 0;
            this.Metafile.Text = "图元文件中的记录与回放";
            this.Metafile.Click += new System.EventHandler(this.Metafile_Click);
            // 
            // CroppingAndScaling
            // 
            this.CroppingAndScaling.Index = 1;
            this.CroppingAndScaling.Text = "图形的剪裁与缩放";
            this.CroppingAndScaling.Click += new System.EventHandler(this.CroppingAndScaling_Click);
            // 
            // UsingInterpolationMode
            // 
            this.UsingInterpolationMode.Index = 2;
            this.UsingInterpolationMode.Text = "使用不同的插值模式控制图形缩放质量";
            this.UsingInterpolationMode.Click += new System.EventHandler(this.UsingInterpolationMode_Click);
            // 
            // RotateFlip
            // 
            this.RotateFlip.Index = 3;
            this.RotateFlip.Text = "绘制镜像图片示例";
            this.RotateFlip.Click += new System.EventHandler(this.RotateFlip_Click);
            // 
            // ImageSkewing
            // 
            this.ImageSkewing.Index = 4;
            this.ImageSkewing.Text = "绘制映射图片";
            this.ImageSkewing.Click += new System.EventHandler(this.ImageSkewing_Click);
            // 
            // Cubeimage
            // 
            this.Cubeimage.Index = 5;
            this.Cubeimage.Text = "立方体贴图";
            this.Cubeimage.Click += new System.EventHandler(this.Cubeimage_Click);
            // 
            // ThumbnailImage
            // 
            this.ThumbnailImage.Index = 6;
            this.ThumbnailImage.Text = "GDI+中处理缩略图";
            this.ThumbnailImage.Click += new System.EventHandler(this.ThumbnailImage_Click);
            // 
            // Clone
            // 
            this.Clone.Index = 7;
            this.Clone.Text = "分块显示图片";
            this.Clone.Click += new System.EventHandler(this.Clone_Click);
            // 
            // Picturescale
            // 
            this.Picturescale.Index = 8;
            this.Picturescale.Text = "图片局部放大(缩小)显示";
            this.Picturescale.Click += new System.EventHandler(this.Picturescale_Click);
            // 
            // menuItem15
            // 
            this.menuItem15.Index = 7;
            this.menuItem15.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.ImageAttributesSetNoOp,
            this.SetColorMatrices,
            this.SetOutputChannelColorProfile,
            this.Gammaadjust,
            this.SetOutputChannel,
            this.Colorkey,
            this.Setthreshold,
            this.AdjustedPalette,
            this.SetWrapMode});
            this.menuItem15.Text = "图像色彩信息的调整";
            // 
            // ImageAttributesSetNoOp
            // 
            this.ImageAttributesSetNoOp.Index = 0;
            this.ImageAttributesSetNoOp.Text = "色彩校正的启用与禁用";
            this.ImageAttributesSetNoOp.Click += new System.EventHandler(this.ImageAttributesSetNoOp_Click);
            // 
            // SetColorMatrices
            // 
            this.SetColorMatrices.Index = 1;
            this.SetColorMatrices.Text = "设置不同的色彩调整对象";
            this.SetColorMatrices.Click += new System.EventHandler(this.SetColorMatrices_Click);
            // 
            // SetOutputChannelColorProfile
            // 
            this.SetOutputChannelColorProfile.Index = 2;
            this.SetOutputChannelColorProfile.Text = "使用色彩配置文件进行色彩校正";
            this.SetOutputChannelColorProfile.Click += new System.EventHandler(this.SetOutputChannelColorProfile_Click);
            // 
            // Gammaadjust
            // 
            this.Gammaadjust.Index = 3;
            this.Gammaadjust.Text = "修改Gamma值进行图片输出";
            this.Gammaadjust.Click += new System.EventHandler(this.Gammaadjust_Click);
            // 
            // SetOutputChannel
            // 
            this.SetOutputChannel.Index = 4;
            this.SetOutputChannel.Text = "设置色彩输出通道";
            this.SetOutputChannel.Click += new System.EventHandler(this.SetOutputChannel_Click);
            // 
            // Colorkey
            // 
            this.Colorkey.Index = 5;
            this.Colorkey.Text = "使用关键色";
            this.Colorkey.Click += new System.EventHandler(this.Colorkey_Click);
            // 
            // Setthreshold
            // 
            this.Setthreshold.Index = 6;
            this.Setthreshold.Text = "阈值运用演示程序";
            this.Setthreshold.Click += new System.EventHandler(this.Setthreshold_Click);
            // 
            // AdjustedPalette
            // 
            this.AdjustedPalette.Index = 7;
            this.AdjustedPalette.Text = "获取色彩校正调色板";
            this.AdjustedPalette.Click += new System.EventHandler(this.AdjustedPalette_Click);
            // 
            // SetWrapMode
            // 
            this.SetWrapMode.Index = 8;
            this.SetWrapMode.Text = "设置色彩校正的环绕模式和颜色";
            this.SetWrapMode.Click += new System.EventHandler(this.SetWrapMode_Click);
            // 
            // menuItem16
            // 
            this.menuItem16.Index = 8;
            this.menuItem16.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.ListAllImageEncoders,
            this.ListImageEncoder_Detail,
            this.ListImageDecoder,
            this.GetEncoderParameter,
            this.GetAllEncoderParameter,
            this.menuItem17,
            this.SaveBmp2tif,
            this.SaveBMP2JPG,
            this.TransformingJPEG,
            this.MultipleFrameImage,
            this.GetImageFromMultyFrame,
            this.QueryImage,
            this.SetProp});
            this.menuItem16.Text = "图形的编码与解码";
            // 
            // ListAllImageEncoders
            // 
            this.ListAllImageEncoders.Index = 0;
            this.ListAllImageEncoders.Text = "输出编码器信息";
            this.ListAllImageEncoders.Click += new System.EventHandler(this.ListAllImageEncoders_Click);
            // 
            // ListImageEncoder_Detail
            // 
            this.ListImageEncoder_Detail.Index = 1;
            this.ListImageEncoder_Detail.Text = "输出编码器信息";
            this.ListImageEncoder_Detail.Click += new System.EventHandler(this.ListImageEncoder_Detail_Click);
            // 
            // ListImageDecoder
            // 
            this.ListImageDecoder.Index = 2;
            this.ListImageDecoder.Text = "列出系统可用的解码器信息";
            this.ListImageDecoder.Click += new System.EventHandler(this.ListImageDecoder_Click);
            // 
            // GetEncoderParameter
            // 
            this.GetEncoderParameter.Index = 3;
            this.GetEncoderParameter.Text = "查看将位图保存为JPEG时需要设置的参数信息";
            this.GetEncoderParameter.Click += new System.EventHandler(this.GetEncoderParameter_Click);
            // 
            // GetAllEncoderParameter
            // 
            this.GetAllEncoderParameter.Index = 4;
            this.GetAllEncoderParameter.Text = "查看所有的编码信息所需的参数列表";
            this.GetAllEncoderParameter.Click += new System.EventHandler(this.GetAllEncoderParameter_Click);
            // 
            // menuItem17
            // 
            this.menuItem17.Index = 5;
            this.menuItem17.Text = "将BMP文件另存为PNG格式的文件";
            this.menuItem17.Click += new System.EventHandler(this.menuItem17_Click);
            // 
            // SaveBmp2tif
            // 
            this.SaveBmp2tif.Index = 6;
            this.SaveBmp2tif.Text = "将BMP文件保存为TIF文件";
            this.SaveBmp2tif.Click += new System.EventHandler(this.SaveBmp2tif_Click);
            // 
            // SaveBMP2JPG
            // 
            this.SaveBMP2JPG.Index = 7;
            this.SaveBMP2JPG.Text = "使用不同的压缩质量保存JPEG文件";
            this.SaveBMP2JPG.Click += new System.EventHandler(this.SaveBMP2JPG_Click);
            // 
            // TransformingJPEG
            // 
            this.TransformingJPEG.Index = 8;
            this.TransformingJPEG.Text = "JPEG文件的保存与变换";
            this.TransformingJPEG.Click += new System.EventHandler(this.TransformingJPEG_Click);
            // 
            // MultipleFrameImage
            // 
            this.MultipleFrameImage.Index = 9;
            this.MultipleFrameImage.Text = "保存多帧图片";
            this.MultipleFrameImage.Click += new System.EventHandler(this.MultipleFrameImage_Click);
            // 
            // GetImageFromMultyFrame
            // 
            this.GetImageFromMultyFrame.Index = 10;
            this.GetImageFromMultyFrame.Text = "读取多帧图片的子图片";
            this.GetImageFromMultyFrame.Click += new System.EventHandler(this.GetImageFromMultyFrame_Click);
            // 
            // QueryImage
            // 
            this.QueryImage.Index = 11;
            this.QueryImage.Text = "获取图像属性列表";
            this.QueryImage.Click += new System.EventHandler(this.QueryImage_Click);
            // 
            // SetProp
            // 
            this.SetProp.Index = 12;
            this.SetProp.Text = "修改图片属性";
            this.SetProp.Click += new System.EventHandler(this.SetProp_Click);
            // 
            // menuItem18
            // 
            this.menuItem18.Index = 9;
            this.menuItem18.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.FadeInOut,
            this.GrayScale,
            this.Inverse,
            this.Emboss,
            this.OnCanvas,
            this.OnWood,
            this.Flashligt,
            this.BlurAndSharpen});
            this.menuItem18.Text = "图形特技处理";
            // 
            // FadeInOut
            // 
            this.FadeInOut.Index = 0;
            this.FadeInOut.Text = "淡入浅出";
            this.FadeInOut.Click += new System.EventHandler(this.menuItem2_Click);
            // 
            // GrayScale
            // 
            this.GrayScale.Index = 1;
            this.GrayScale.Text = "灰度处理与还原";
            this.GrayScale.Click += new System.EventHandler(this.GrayScale_Click);
            // 
            // Inverse
            // 
            this.Inverse.Index = 2;
            this.Inverse.Text = "底片(负片)滤镜";
            this.Inverse.Click += new System.EventHandler(this.Inverse_Click);
            // 
            // Emboss
            // 
            this.Emboss.Index = 3;
            this.Emboss.Text = "浮雕及雕刻";
            this.Emboss.Click += new System.EventHandler(this.Emboss_Click);
            // 
            // OnCanvas
            // 
            this.OnCanvas.Index = 4;
            this.OnCanvas.Text = "油画效果的制作";
            this.OnCanvas.Click += new System.EventHandler(this.OnCanvas_Click);
            // 
            // OnWood
            // 
            this.OnWood.Index = 5;
            this.OnWood.Text = "木刻滤镜";
            this.OnWood.Click += new System.EventHandler(this.OnWood_Click);
            // 
            // Flashligt
            // 
            this.Flashligt.Index = 6;
            this.Flashligt.Text = "强光照射滤镜";
            this.Flashligt.Click += new System.EventHandler(this.Flashligt_Click);
            // 
            // BlurAndSharpen
            // 
            this.BlurAndSharpen.Index = 7;
            this.BlurAndSharpen.Text = "柔化与锐化滤镜";
            this.BlurAndSharpen.Click += new System.EventHandler(this.BlurAndSharpen_Click);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(507, 292);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(41, 12);
            this.label1.TabIndex = 0;
            this.label1.Text = "label1";
            // 
            // timer1
            // 
            this.timer1.Interval = 1000;
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.BackColor = System.Drawing.SystemColors.HighlightText;
            this.ClientSize = new System.Drawing.Size(560, 313);
            this.Controls.Add(this.label1);
            this.Menu = this.mainMenu1;
            this.Name = "Form1";
            this.Text = "GDIPlusDemo";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.Load += new System.EventHandler(this.Form1_Load);
            this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
            this.Resize += new System.EventHandler(this.Form1_Resize);
            this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
            this.ResumeLayout(false);
            this.PerformLayout();

  }
  #endregion

  /// 
  /// 应用程序的主入口点。
  /// 
  [STAThread]
  static void Main() 
  {
   Application.Run(new Form1());
   
  }

private void menuItem2_Click(object sender, System.EventArgs e)
{
 Graphics g=this.CreateGraphics();
 g.Clear(Color.Black);
 Bitmap bitmap=new Bitmap("demo.bmp");
 int iWidth = bitmap.Width;
 int iHeight = bitmap.Height;

 //初始化色彩变换矩阵
 float[][] tem=
  {
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 1.0f}
  };
   
 ColorMatrix colorMatrix=new ColorMatrix(tem);
 ImageAttributes imageAtt=new ImageAttributes();

 //从0到1进行修改色彩变换矩阵主对角线上的数值
 //使三种基准色的饱和度渐增
 for(float i=0.0f;i<=1.0f;i+=0.02f)
 { 
  colorMatrix.Matrix00=i;
  colorMatrix.Matrix11=i;
  colorMatrix.Matrix22=i;
  colorMatrix.Matrix33=i;
  //设置色彩校正矩阵
  imageAtt.SetColorMatrix(colorMatrix,
   ColorMatrixFlag.Default,ColorAdjustType.Bitmap);
  //绘制图片
  g.DrawImage(
   bitmap, new Rectangle(0, 0, iWidth, iHeight), 
   0,0,        
   iWidth,iHeight,
   GraphicsUnit.Pixel, 
   imageAtt);
 }

 MessageBox.Show("下面演示淡出效果");
 
 //从1到0进行修改色彩变换矩阵主对角线上的数值
 //依次减少每种色彩分量
 for(float i=1.0f;i>=0.0f;i-=0.02f)
 { 
  colorMatrix.Matrix00=i;
  colorMatrix.Matrix11=i;
  colorMatrix.Matrix22=i;
  colorMatrix.Matrix33=i;
  //设置色彩校正矩阵
  imageAtt.SetColorMatrix(colorMatrix,
   ColorMatrixFlag.Default,ColorAdjustType.Bitmap);
  //绘制图片
  g.DrawImage(
   bitmap, new Rectangle(0, 0, iWidth, iHeight), 
   0,0,        
   iWidth,iHeight,
   GraphicsUnit.Pixel, 
   imageAtt);
 }
}

  
private void GrayScale_Click(object sender, System.EventArgs e)
{
 Graphics g=this.CreateGraphics();
 g.Clear(Color.White);
 Bitmap image=new Bitmap("head.bmp");   
 int Width =image.Width-1;
 int Height =image.Height-1;

 //绘制原图
 g.DrawImage(image,0, 0);
 g.TranslateTransform(image.Width,0);

 /*image2、image3分别用来保存最大值法
 和加权平均法处理的灰度图像*/
 Bitmap image2=image.Clone(new Rectangle(0,0,image.Width,
  image.Height),PixelFormat.DontCare);
 Bitmap image3=image.Clone(new Rectangle(0,0,image.Width,
  image.Height),PixelFormat.DontCare);

 Color color;
 //使用平均值进行灰度处理
 for(int i=Width; i>=0;i--)
  for( int j=Height; j>=0;j--)
  {
   color=image.GetPixel(i,j); 
   //求出平均三个色彩分量的平均值
   int middle=(color.R+
    color.G+color.B)/3;
   Color colorResult=Color.FromArgb(255,middle,middle,middle);
   image.SetPixel(i, j, colorResult);
  } 
 //重新绘制灰度化图
 g.DrawImage(
  image, new Rectangle(0, 0, Width, Height));

 //在新位置显示最大值法进行灰度处理的结果
 g.TranslateTransform(image.Width,0);
 //使用最大值法进行灰度处理
 for(int i=Width; i>=0;i--)
 {
  for(int j=Height; j>=0;j--)
  {
   color=image2.GetPixel(i,j); 
   int tmp=Math.Max(color.R,color.G);
   int maxcolor=Math.Max(tmp,color.B);
   Color colorResult=Color.FromArgb(255,maxcolor,maxcolor,maxcolor);
   //设置处理后的灰度信息
   image2.SetPixel(i, j, colorResult);
  } 
 }

 //重新绘制灰度化图
 g.DrawImage(
  image2, new Rectangle(0, 0, Width, Height));
 //在第二行绘制图片
 g.ResetTransform();
 g.TranslateTransform(0,image.Height);

 //使用加权平均法进行灰度处理 
 for(int i=Width; i>=0;i--)
 {
  for(int j=Height; j>=0;j--)
  {
   color=image3.GetPixel(i, j); 
   int R=(int)(0.3f*color.R);
   int G=(int)(0.59f*color.G);
   int B=(int)(0.11f*color.B);
   
   Color colorResult=Color.FromArgb(255,R,G,B);
   //设置处理后的灰度信息
   image3.SetPixel(i, j, colorResult);
  } 
 }
 //重新绘制灰度化图
 g.DrawImage(
  image3, new Rectangle(0, 0, Width, Height));
 
 g.TranslateTransform(image.Width,0);
 //灰度的还原演示,还原使用最大值法处理的灰度图像image2
 for(int i=Width; i>0;i--)
 {
  for(int j=Height; j>0;j--)
  {
   color=image2.GetPixel(i,j); 
   int R=color.R;
   int G=color.G;
   int B=color.B;
   //分别对RGB三种色彩分量进行伪彩色还原

   //进行红色分量的还原
   if(R<127)
    R=0;
   if(R>=192)
    R=255;
   if(R<=191&&R>=128)
    R=4*R-510;

   /*进行绿色分量的还原,为了还原后的绿色分量再次参加比较,
   这里设置一个变量YES表示G是否已经参加了比较*/

   bool yes;
   yes=false;
   if(G<=191&&G>=128&&(!yes))
   {
    G=255;
    yes=true;
   }
   if(G>=192&&(!yes))
   {
    G=1022-4*G;
    yes=true;
   }
   if(G<=63&&(!yes))
   {
    G=254-4*G;
    yes=true;
   }
   if(G<=127&&G>=67&&(!yes))
    G=4*G-257;
   
   //进行蓝色分量的还原
   if(B<=63)
    B=255;
   if(B>=128)
    B=0;
   if(B>=67&&B<=127)
    B=510-4*B;
   
   //还原后的伪彩色
   Color colorResult=Color.FromArgb(255,R,G,B);
   //将还原后的RGB信息重新写入位图
   image2.SetPixel(i, j, colorResult);
     
  } 
 }
 //重新绘制还原后的伪彩色位图
 //重新绘制灰度化图
 g.DrawImage(
  image2, new Rectangle(0, 0, Width, Height));
}

private void Inverse_Click(object sender, System.EventArgs e)
{
 Graphics graphics=this.CreateGraphics();
 graphics.Clear(Color.White);
 graphics.ScaleTransform(0.7f,0.7f);
 
 Bitmap image=new Bitmap("head.bmp");    
 int Width =image.Width;
 int Height =image.Height;

 Color colorTemp,color2;
 Color color;
 //绘制原图
 graphics.DrawImage(
  image, new Rectangle(0, 0, Width, Height));
 
 for(int  i=0;i
 
 
  
  0;i--)
 {
  for( int j=Height-1; j>0;j--)
  {
   //获取相邻两个像素的R、G、B值
   color =image.GetPixel(i, j); 
   colorLeft=image.GetPixel(i-1, j-1); 
   //计算与左上角像素的RGB分量之差
   //67:控制图片的最低灰度,128:常量,更改这两个值会得到不同的效果
   int r=Math.Max(67,Math.Min(255,
    Math.Abs(color.R-colorLeft.R+128)));
   int g=Math.Max(67,Math.Min(255,
    Math.Abs(color.G-colorLeft.G+128)));
   int b=Math.Max(67,Math.Min(255,
    Math.Abs(color.B-colorLeft.B+128)));
   Color colorResult=Color.FromArgb(255,r,g,b);
   //将计算后的RGB值回写到位图
   image.SetPixel(i, j,colorResult);
  }

  //绘制浮雕图
  graphics.DrawImage(
   image, new Rectangle(Width+10, 0, Width, Height));
 }

 //进行图片的雕刻处理
 for(int i=0; i
  
  
   
   column_count-1)
    {
     column+=2;
     rol=0;
    }
    //创建临时画刷
    HatchBrush brush_tmp=new HatchBrush(style, black, white);
    //填充矩形:设置宽度为WIDTH-20的目的是让矩形之间留出间隔
    graphics.FillRectangle(brush_tmp, rol*WIDTH, column*HEIGHT, WIDTH-20, HEIGHT);
    //绘制矩形边框
    graphics.DrawRectangle(pen, rol*WIDTH, column*HEIGHT, WIDTH-20, HEIGHT);

    //显示每种画刷风格的枚举名称
    //计算文本输出区域
    RectangleF layoutRect=new RectangleF(rol*WIDTH, (column+1)*HEIGHT, WIDTH, HEIGHT);
    StringFormat format=new StringFormat();
    //设置文本输出格式:水平、垂直居中
    format.Alignment=StringAlignment.Near;
    format.LineAlignment=StringAlignment.Center;
    //在矩形框中央输出枚举值
    graphics.DrawString(brush_tmp.HatchStyle.ToString(),myFont,redBrush, layoutRect, format);
    rol+=1;
   }
  }
  //设置绘制原点
  private void Brush_SetRenderingOrigin_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //设定画刷的前景色为黑色,背景色为白色
   Color black=Color.Black;
   Color white=Color.White;
   HatchBrush hatchBrush=new HatchBrush(HatchStyle.DarkDownwardDiagonal,black,white);
 
   //在竖直方向填充8个矩形,使用默认的画刷原点
   for(int i=0;i<8;i++)
   {
    graphics.FillRectangle(hatchBrush, 0, i*50, 100, 50);  
   }

   //使用不同的绘制原点进行区域填充
   for(int i=0;i<8;i++)
   {
    //设置画刷原点(水平方向递增)
    graphics.RenderingOrigin=new Point(i, 0);
    graphics.FillRectangle(hatchBrush, 100, i*50, 100, 50);
   }
  }
  //纹理画刷的不同加载方式
  private void Brush_Texture_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Pen pen=new Pen(Color.Blue, 2);
   SolidBrush brush=new SolidBrush(Color.Black);
   Font myFont=new Font("宋体",12);

   //定义纹理画刷的不同填充区域
   RectangleF rect1=new RectangleF(10, 10, 200,200);
   RectangleF rect2=new RectangleF(210, 10, 200, 200);
   RectangleF rect3=new RectangleF(410, 10, 200, 200);

   //装入纹理图片
   Bitmap image=new Bitmap("nemo.bmp");
   //构造纹理画刷1:使用默认的方式
   TextureBrush tBrush=new TextureBrush(image);
   //使用纹理画刷填充圆形区域
   graphics.FillEllipse(tBrush,rect1);
   //绘制圆周
   graphics.DrawEllipse(pen,rect1);
   graphics.DrawString("图片原始大小",myFont,brush,new PointF(40,220));

   //构造纹理画刷2:只使用给定图片的部分区域
   TextureBrush tBrush2=new TextureBrush(image,new Rectangle(55,35,55,35));
   graphics.FillEllipse(tBrush2,rect2);
   graphics.DrawEllipse(pen,rect2);
   graphics.DrawString("使用部分截图",myFont,brush,new PointF(240,220)); 

   //构造纹理画刷3:将使用图片的画刷进行缩放
   TextureBrush tBrush3=new TextureBrush(image);
   //对画刷进行50%的缩放
   Matrix mtr=new Matrix(0.5f, 0.0f, 0.0f,0.5f, 0.0f, 0.0f);
   tBrush3.Transform=mtr;
   graphics.FillEllipse(tBrush3,rect3);
   graphics.DrawEllipse(pen,rect3);
   graphics.DrawString("比例缩小图片",myFont,brush,new PointF(440,220));
  }

  //使用图片排列方式
  private void Brush_Texture_WrapMode_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Pen pen=new Pen(Color.Blue, 2);
   SolidBrush brush=new SolidBrush(Color.Black);
   Font myFont=new Font("Arial", 13);

   //装入纹理图片
   Bitmap image=new Bitmap("nemo.bmp");
   //构造纹理画刷
   TextureBrush tBrush=new TextureBrush(image);
   //将画刷进行缩放
   Matrix mtr=new Matrix(0.5f, 0.0f, 0.0f,0.5f, 0.0f, 0.0f);
   tBrush.Transform=mtr;

   int i=0;
   //对图片不使用排列方式
   tBrush.WrapMode=WrapMode.Clamp;
   graphics.FillRectangle(tBrush,new Rectangle(i*150,0,150,150));
   graphics.DrawRectangle(pen,new Rectangle(i*150,0,150,150));
   graphics.DrawString("Clamp", myFont,brush,new PointF(0,155)); 

   i+=1;
   //对图片使用平铺排列方式 
   tBrush.WrapMode=WrapMode.Tile;
   graphics.FillRectangle(tBrush,new Rectangle(i*150+10,0,150,150));
   graphics.DrawRectangle(pen,new Rectangle(i*150+10,0,150,150));
   graphics.DrawString("Tile",myFont,brush, new PointF(170,155) ); 

   //对图片使用水平翻转排列方式
   i+=1;
   tBrush.WrapMode=WrapMode.TileFlipX;
   graphics.FillRectangle(tBrush,new Rectangle(i*150+20,0,150,150));
   graphics.DrawRectangle(pen,new Rectangle(i*150+20,0,150,150));

   graphics.DrawString("TileFlipX",myFont,brush, new PointF(320,155)); 

   //对图片使用垂直翻转排列方式
   tBrush.WrapMode=WrapMode.TileFlipY;
   graphics.FillRectangle(tBrush,new Rectangle(0,180,150,150));
   graphics.DrawRectangle(pen,new Rectangle(0,180,150,150));
   graphics.DrawString("TileFlipY",myFont,brush, new  PointF(0,335)); 

   //对图片使用水平、垂直同时翻转排列方式
   tBrush.WrapMode=WrapMode.TileFlipXY;
   graphics.FillRectangle(tBrush,new Rectangle(160,180,150,150));
   graphics.DrawRectangle(pen,new Rectangle(160,180,150,150));
   graphics.DrawString("TileFlipXY",myFont,brush, new PointF(170,335)); 
  }
  //纹理画刷的变换
  private void Brush_TextureTransform_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //为三种不同的变换方式的画刷定义填充区域
   RectangleF rect1=new RectangleF (10, 10, 200,200);
   RectangleF rect2=new RectangleF (210, 10, 200, 200);
   RectangleF rect3=new RectangleF (410, 10, 200, 200);

   Pen pen=new Pen(Color.Blue, 2);
   SolidBrush brush=new SolidBrush(Color.Black);
   Font myFont=new Font("宋体", 12);

   //装入纹理图片
   Bitmap image=new Bitmap("nemo.bmp");
   //构造纹理画刷
   TextureBrush tBrush=new TextureBrush(image);

   //将画刷旋转30度
   tBrush.RotateTransform(30);                     
   graphics.FillEllipse(tBrush,rect1);
   graphics.DrawEllipse(pen,rect1);
   graphics.DrawString("旋转30度",myFont,brush,new PointF(40,220)); 

   //重置变换矩阵:恢复到变化前的状态
   tBrush.ResetTransform();
   //将画刷在水平方向上扩大三倍
   tBrush.ScaleTransform(3, 1);
   graphics.FillEllipse(tBrush, rect2);
   graphics.DrawEllipse(pen,rect2);
   graphics.DrawString("横向扩充三倍",myFont,brush,new  PointF(240,220)); 

   //平移变换
   tBrush.ResetTransform();
   //将画刷在水平方向上平移30个像素
   tBrush.TranslateTransform(30, 0, MatrixOrder.Append);
   graphics.FillEllipse(tBrush, rect3);
   graphics.DrawEllipse(pen,rect3);
   graphics.DrawString("横向平移30个像素",myFont,brush,new PointF(440,220)); 
  }
  //查询画刷的变换信息
  private void Brush_GetTextureMatrix_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Matrix matrix=new Matrix();
   float[] elements=new float[6];
   RectangleF rect1=new RectangleF(10, 10, 200,200);
   Pen pen=new Pen(Color.Black, 2);
   SolidBrush brush=new SolidBrush(Color.Black);

   Bitmap image=new Bitmap("nemo.bmp");
   TextureBrush tBrush=new TextureBrush(image);
   //进行三种任意变换
   tBrush.RotateTransform(30);
   tBrush.TranslateTransform(5,3);
   tBrush.ScaleTransform(0.5f,2.0f);

   //获取目前已经进行的画刷变换
   matrix=tBrush.Transform;
   //从矩形到数组
   elements=matrix.Elements; 
   graphics.FillEllipse(tBrush,rect1);
   graphics.DrawEllipse(pen,rect1);

   //输出矩阵的元素
   for(int j = 0; j <6; ++j)
   {
    MessageBox.Show(elements[j].ToString(),"矩阵元素值");
   }
  }
  //线性渐变画刷程序
  private void Brush_LinearGradientBrush_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //定义一个由红色到蓝色渐变的画刷:水平变换区域的宽度为40
   //竖直方向不进行色彩渐变
   LinearGradientBrush linGrBrush=new LinearGradientBrush(
    new Point(0, 0),
    new Point(40, 0),
    Color.Red,  //起点色彩 
    Color.Blue);  //止点色彩

   //定义一个色彩呈对角线变换的区域,区域大小为40*40
   LinearGradientBrush linGrBrush2=new LinearGradientBrush(
    new Point(0, 0),
    new Point(40, 40),
    Color.Red,  //起点色彩 
    Color.Blue); //止点色彩 

   //分别演示不同的线性渐变画刷对目标区域的不同填充效果
   graphics.FillRectangle(linGrBrush, 
    0, 0, 200, 200);
   graphics.FillRectangle(linGrBrush2, 
    240, 0, 200, 200);

   Pen pen=new Pen(Color.Gray,1);
   //在对角线方向上绘制单个画刷的填充区域
   for(int i=0;i<5;i++)
   {
    graphics.DrawRectangle(pen,
     240+i*40,i*40,40,40);
   }
 
  }
  //控制线性渐变画刷的填充方式
  private void Brush_LinearArrange_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Pen pen=new Pen(Color.Blue, 2);
   SolidBrush brush=new SolidBrush(Color.Black);
   Font myFont=new Font("Arial", 13);

   //定义一个色彩呈对角线变换的区域,区域大小为40*40
   LinearGradientBrush linGrBrush=new LinearGradientBrush(
    new Point(0, 0),
    new Point(40, 40),
    Color.Red, //起点色彩 
    Color.Blue); //止点色彩 
 
   int i=0;
   //对渐变画刷使用平铺排列方式(默认方式)
   linGrBrush.WrapMode=WrapMode.Tile;
   //填充一个大小为160的正方形
   graphics.FillRectangle(linGrBrush,new Rectangle(i*160,0,160,160));
   graphics.DrawRectangle(pen,new Rectangle(i*160,0,160,160));
   graphics.DrawString("Tile",myFont,brush,new Point(20,165)); 

   //对渐变画刷使用水平翻转排列方式
   i+=1;
   linGrBrush.WrapMode=WrapMode.TileFlipX;
   //重置绘图平面原点
   graphics.RenderingOrigin=new Point(160,0);
   graphics.FillRectangle(linGrBrush,new Rectangle(i*160,0,160,160));
   graphics.DrawRectangle(pen,new Rectangle(i*160,160,0,160));
   graphics.DrawString("TileFlipX",myFont,brush,new Point(170,165)); 

   //对渐变画刷使用垂直翻转排列方式
   linGrBrush.WrapMode=WrapMode.TileFlipY;
   //重置绘图平面原点
   graphics.RenderingOrigin=new Point(0,200);
   graphics.FillRectangle(linGrBrush,new Rectangle(0,200,160,160));
   graphics.DrawRectangle(pen,new Rectangle(0,200,200,160));
   graphics.DrawString("TileFlipY",myFont,brush,new Point(0,375)); 

   //对渐变画刷使用水平、垂直同时翻转排列方式
   linGrBrush.WrapMode=WrapMode.TileFlipXY;
   graphics.RenderingOrigin=new Point(160,200);
   graphics.FillRectangle(linGrBrush,new Rectangle(160,200,160,160));
   graphics.DrawRectangle(pen,new Rectangle(160,200,160,160));
   graphics.DrawString("TileFlipXY",myFont,brush,new Point(170,375)); 

   //标注渐变画刷渐变区域的大小:画格子
   Pen pen2=new Pen(Color.Gray, 1);
   for(i=0;i<8;i++)
    graphics.DrawLine(pen2,0,i*40,320,i*40);
   for(i=0;i<9;i++)
    graphics.DrawLine(pen2,i*40,0,i*40,360);
  }
  //定义线性渐变画刷的渐变模式
  private void Brush_LinearGradientMode_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Pen pen=new Pen(Color.Blue, 2);
   SolidBrush brush=new SolidBrush(Color.Black);
   Font myFont=new Font("Arial", 12);

   //定义一个水平渐变画刷,大小40*20
   LinearGradientBrush linGrBrush1=new LinearGradientBrush(
    new Rectangle(0, 0, 40, 20),
    Color.Red,  
    Color.Blue,LinearGradientMode.Horizontal);  

   //定义一个垂直渐变画刷
   LinearGradientBrush linGrBrush2=new LinearGradientBrush(
    new Rectangle(0, 0, 40, 20),
    Color.Red,  
    Color.Blue,LinearGradientMode.Vertical); 

   //从右上到左下的渐变画刷
   LinearGradientBrush linGrBrush3=new LinearGradientBrush(
    new Rectangle(0, 0, 40, 20),
    Color.Red,  
    Color.Blue,LinearGradientMode.ForwardDiagonal);  
 
   //从左上到左下的渐变画刷
   LinearGradientBrush linGrBrush4=new LinearGradientBrush(
    new Rectangle(0, 0, 40, 20),
    Color.Red,  
    Color.Blue,LinearGradientMode.BackwardDiagonal);  

   int i=0;
   //使用水平渐变的画刷填充区域
   graphics.FillRectangle(linGrBrush1,new Rectangle(i*160,0,160,160));
   graphics.DrawRectangle(pen,new Rectangle(i*160,0,160,160));
   graphics.DrawString("水平渐变",myFont,brush,new PointF(20,165));

   i+=1;
   //重置绘图平面原点
   graphics.RenderingOrigin=new Point(160,0);
   //使用垂直渐变的画刷填充区域
   graphics.FillRectangle(linGrBrush2,new Rectangle(i*160,0,160,160));
   graphics.DrawRectangle(pen,new Rectangle(i*160,160,0,160));
   graphics.DrawString("垂直渐变",myFont,brush,new PointF(170,165)); 

   //重置绘图平面原点
   graphics.RenderingOrigin=new Point(0,200);
   //使用从右上到左下渐变的画刷填充区域
   graphics.FillRectangle(linGrBrush3,new Rectangle(0,200,160,160));
   graphics.DrawRectangle(pen,new Rectangle(0,200,200,160));
   graphics.DrawString("左上->右下",myFont,brush,new PointF(0,375)); 

   graphics.RenderingOrigin=new Point(160,200);
   graphics.FillRectangle(linGrBrush4,new Rectangle(160,200,160,160));
   //使用从左上到右下渐变的画刷填充区域
   graphics.DrawRectangle(pen,new Rectangle(160,200,160,160));
   graphics.DrawString("右上->左下",myFont,brush,new PointF(170,375)); 

   //在不同的区域中标注定义渐变方向的矩形
   Pen pen2=new Pen(Color.Gray, 1);
   for(i=0;i<18;i++)
    graphics.DrawLine(pen2,0,i*20,320,i*20);
   for(i=0;i<9;i++)
    graphics.DrawLine(pen2,i* 40,0,i*40,360);
  }
  //渐变线偏转角度
  private void Brush_LinearAngle_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Pen pen=new Pen(Color.Blue, 2);
   SolidBrush brush=new SolidBrush(Color.Black);
   Font myFont=new Font("Arial", 12);

   //定义一个渐变线偏转角度为30度的渐变画刷,大小40*20
   LinearGradientBrush linGrBrush1=new LinearGradientBrush(
    new Rectangle(0, 0, 40, 20),
    Color.Red,  
    Color.Blue,30.0f);  
   //定义一个渐变线偏转角度为45度的渐变画刷
   LinearGradientBrush linGrBrush2=new LinearGradientBrush(
    new Rectangle(0, 0, 40, 20),
    Color.Red,  
    Color.Blue,45.0f); 
   //定义一个渐变线偏转角度为90度的渐变画刷
   LinearGradientBrush linGrBrush3=new LinearGradientBrush(
    new Rectangle(0, 0, 40, 20),
    Color.Red,  
    Color.Blue,90.0f);  
   //定义一个渐变线偏转角度为180度的渐变画刷
   LinearGradientBrush linGrBrush4=new LinearGradientBrush(
    new Rectangle(0, 0, 40, 20),
    Color.Red,  
    Color.Blue,180.0f);  

   int i=0;
   //使用偏转角度为30度的渐变画刷填充区域
   graphics.FillRectangle(linGrBrush1,new Rectangle(i*160,0,160,160));
   graphics.DrawRectangle(pen,new Rectangle(i*160,0,160,160));
   graphics.DrawString("30度偏转",myFont,brush, new PointF(20,165)); 

   i+=1;
   //重置绘图平面原点
   graphics.RenderingOrigin=new Point(160,0);
   //使用偏转角度为45度的渐变画刷填充区域
   graphics.FillRectangle(linGrBrush2,new Rectangle(i*160,0,160,160));
   graphics.DrawRectangle(pen,new Rectangle(i*160,160,0,160));
   graphics.DrawString("45度偏转",myFont,brush, new PointF(170,165));

   //重置绘图平面原点
   graphics.RenderingOrigin=new Point(0,200);
   //使用偏转角度为90度的渐变画刷填充区域
   graphics.FillRectangle(linGrBrush3,new Rectangle(0,200,160,160));
   graphics.DrawRectangle(pen,new Rectangle(0,200,200,160));
   graphics.DrawString("90度偏转",myFont,brush,new PointF(0,375));

   graphics.RenderingOrigin=new Point(160,200);
   graphics.FillRectangle(linGrBrush4,new Rectangle(160,200,160,160));
   //使用偏转角度为180度的渐变画刷填充区域
   graphics.DrawRectangle(pen,new Rectangle(160,200,160,160));
   graphics.DrawString("180度偏转",myFont,brush, new PointF(170,375));

   //在不同的区域中标注定义渐变方向的矩形
   Pen pen2=new Pen(Color.Gray, 1);
   for(i=0;i<18;i++)
    graphics.DrawLine(pen2,0,i*20,320,i*20);
   for(i=0;i<9;i++)
    graphics.DrawLine(pen2,i* 40,0,i*40,360);
  }
  //多色渐变画刷
  private void Brush_LinearInterpolation_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //定义三种参与渐变的色彩
   Color[] colors = 
 {
  Color.Red,   // 红色
  Color.Green,//过渡色为绿色
  Color.Blue // 蓝色
 };  
 
   float[] positions = 
 {
  0.0f,   // 由红色起
  0.3f,   // 绿色始于画刷长度的三分之一
  1.0f   // 到蓝色止
 };  
 
   //定义ColorBlend对象
   ColorBlend clrBlend=new ColorBlend(3);
   clrBlend.Colors=colors;
   clrBlend.Positions=positions;

   //构造一条从黑色到白色的渐变画刷
   LinearGradientBrush linGrBrush=new LinearGradientBrush(
    new Point(0, 0), 
    new Point(180, 0), 
    Color.Black,Color.White);
 
   //设置渐变画刷的多色渐变信息
   linGrBrush.InterpolationColors=clrBlend;
   //使用多色渐变画刷填充目标区域
   graphics.FillRectangle(linGrBrush, 0, 0, 180, 100);

   //使用普通的方法实现多色渐变
   //由红到绿,长度60
   LinearGradientBrush linGrBrush1=new LinearGradientBrush(
    new Point(0, 0), 
    new Point(60, 0),
    Color.Red,         
    Color.Green);  
   //由绿到蓝,长度120
   LinearGradientBrush linGrBrush2=new LinearGradientBrush(
    new Point(60, 0), 
    new Point(181, 0),
    Color.Green,        
    Color.Blue);  
   //分别使用两个画刷填充两个相邻区域,形成多色渐变
   graphics.FillRectangle(linGrBrush1, 0, 120, 60, 100);
   graphics.FillRectangle(linGrBrush2, 60, 120, 120, 100);
  }
  //自定义渐变过程:三角形
  private void Brush_LinearCustomize_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   SolidBrush brush=new SolidBrush(Color.Black);
   Font myFont=new Font("宋体", 12);
   //定义一个双色渐变画刷
   LinearGradientBrush linGrBrush=new LinearGradientBrush(
    new Point(0, 0),
    new Point(250, 0),
    Color.Red,   
    Color.Blue);  

   //绘制两条使用默认渐变方式填充的矩形,以用作比较
   graphics.FillRectangle(linGrBrush, 0, 0, 250, 15);
   graphics.FillRectangle(linGrBrush, 500, 0, 250, 15);

   //依次改变合成点位置
   int row=1;
   for(float i=0.0f;i<1.0f;i+=0.1f)
   {
    linGrBrush.SetBlendTriangularShape(i); 
    graphics.FillRectangle(linGrBrush, 0, row*15, 250, 15);
    row++;
   }
   graphics.DrawString("改变合成点位置",
    myFont,brush, new PointF(40,200));

   //依次改变彩色合成因子
   row=1;
   for(float i=0.0f;i<1.0f;i+=0.1f)
   {
    //将合成的相对位置设置在整个区域的50%处
    linGrBrush.SetBlendTriangularShape (0.5f,i); 
    graphics.FillRectangle(linGrBrush, 500, row*15, 250, 15);
    row++;
   }
   graphics.DrawString("改变色彩合成因子",
    myFont,brush, new PointF(540,200));

  }
  //基于钟形曲线的渐变画刷  
  private void Brush_LinearGradientBrush_BellShape_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Rectangle myRect = new Rectangle(10, 10, 150, 75);
   //定义线性渐变画刷
   LinearGradientBrush myLGBrush = new LinearGradientBrush(
    myRect,Color.Blue,Color.Red,0.0f,true);

   //使用默认的线性渐变画刷填充椭圆
   graphics.FillEllipse(myLGBrush, myRect);

   //将渐变过程设置成基于钟形曲线的渐变
   myLGBrush.SetSigmaBellShape(.5f, 1.0f);

   //使用自定义渐变过程的画刷填充椭圆
   graphics.TranslateTransform(160,0);
   graphics.FillEllipse(myLGBrush, myRect);
  }

  private void Brush_PathGradientBrush_Star_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Pen pen=new Pen(Color.Gray,1);
   SolidBrush pthGrBrush=new SolidBrush(Color.Red);
   SolidBrush blackbrush=new SolidBrush(Color.Blue);
   graphics.TranslateTransform(20,20);

   //构造五星的10个边的端点坐标
   Point[] points = {
         new Point(75, 0), new Point(100, 50), 
         new Point(150, 50), new Point(112, 75),
         new Point(150, 150), new Point(75, 100), 
         new Point(0, 150), new Point(37, 75), 
         new Point(0, 50), new Point(50, 50),
         new Point(75, 0)
        };

   // 创建路径
   GraphicsPath path=new GraphicsPath();
   //在路径中加入直线
   path.AddLines(points);
   //填充路径
   graphics.FillPath(pthGrBrush, path);
   //绘制边界
   graphics.DrawLines(pen,points);
   //绘制定义10个边的端点
   for(int i=0;i<10;i++)
    //每个圆点的直径为10
    graphics.FillEllipse(blackbrush, points[i].X-5,points[i].Y-5,10,10);
  }
  //使用路径渐变画刷绘制五星
  private void Brush_PathGradientBrush_Star2_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //构造五星的10个边的端点坐标
   Point[] points = {
         new Point(75, 0), new Point(100, 50), 
         new Point(150, 50), new Point(112, 75),
         new Point(150, 150), new Point(75, 100), 
         new Point(0, 150), new Point(37, 75), 
         new Point(0, 50), new Point(50, 50),
         new Point(75, 0)
        };
   // 创建路径
   GraphicsPath path=new GraphicsPath();
   //在路径中添加直线
   path.AddLines(points);
   //创建路径渐变画刷
   PathGradientBrush pthGrBrush=new PathGradientBrush(path);
   //设置中心点色彩(终点色)
   pthGrBrush.CenterColor=Color.Red;

   //设置每个端点的色彩(终点色)
   Color[] colors =new Color[] 
   {
    Color.Black, Color.Green,
    Color.Blue, Color.White, 
    Color.Black, Color.Green, 
    Color.Blue, Color.White,
    Color.Black, Color.Green
   };
   //设置路径渐变画刷的边缘色
   pthGrBrush.SurroundColors=colors;
   // 填充目标路径
   graphics.FillPath(pthGrBrush, path);

   //将中心色及边界色都设置成随机色,查看渐变效果
   Random rand=new Random();
   for(int z=0;z<10;z++)
   {
    //在水平方向上平移绘图平面
    graphics.TranslateTransform(200.0f, 0.0f);
    //设置中心点色彩为随机色
    pthGrBrush.CenterColor=
     (Color.FromArgb(rand.Next(255)%155,rand.Next(255)%255,rand.Next(255)%255));
    //使用原有的边缘色
    pthGrBrush.SurroundColors=colors;
    graphics.FillPath(pthGrBrush,path);
   }
  }
  //使用多个路径渐变画刷
  private void Brush_Using_MorePathGradientBrush_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //定义一个六边形,边长为50 
   float fHalf = 50 * (float)Math.Sin(120.0f/360.0f*Math.PI); 
   PointF[] pts =new PointF[] 
  {
   new PointF( 50, 0),           
   new PointF( 50 * 1.5f,  0),
   new PointF( 50,         0),           
   new PointF( 50 / 2,    -fHalf),
   new PointF(-50 / 2,    -fHalf),
   new PointF(-50,         0),
   new PointF(-50 * 1.5f,  0), 
   new PointF(-50,         0),
   new PointF(-50 / 2,     fHalf),     
   new PointF( 50 / 2,     fHalf)
  };

   //构造六边形渐变画刷
   PathGradientBrush pgbrush1=new PathGradientBrush(pts);

   //在水平和垂直方向上平移六边形的顶点
   for (int i = 0; i <10; i++)
   {
    pts[i].X += 50*1.5f;
    pts[i].Y += fHalf;
   }

   //根据改变坐标后的点重新生成路径渐变画刷
   PathGradientBrush pgbrush2=new PathGradientBrush(pts);

   //设置路径渐变画刷的翻转方式为平铺
   pgbrush1.WrapMode=WrapMode.Tile;
   pgbrush2.WrapMode=WrapMode.Tile;

   //分别设置两个画刷的中心点色彩为红、绿色
   pgbrush1.CenterColor=Color.Red;
   pgbrush2.CenterColor=Color.Green;

   //填充当前窗口
   graphics.FillRectangle(pgbrush1, 0, 0,this.Width,this.Height);
   //在上次未被填充的区域中再次填充当前窗口的空白部份
   graphics.FillRectangle(pgbrush2, 0, 0,this.Width,this.Height);
  }
  //路径渐变画刷的填充方式
  private void Brush_PathGradientBrush_WrapMode_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);
 
   Pen pen=new Pen(Color.Blue, 2);
   SolidBrush brush=new SolidBrush(Color.Black);
   Font myFont=new Font("Arial", 12);

   //定义五星的边线坐标,为演示翻转效果,将五星的一角拉长
   Point[] points = new Point[]
  {
   new Point(75, 0), new Point(100, 50), 
   new Point(150, 50), new Point(112, 75),
   new Point(150, 150), new Point(75, 100), 
   new Point(0, 190), new Point(37, 75), 
   new Point(10, 50), new Point(50, 50)
  };

   GraphicsPath path=new GraphicsPath();
   path.AddLines(points);
 
   // 构造路径渐变画刷
   PathGradientBrush pthGrBrush=new PathGradientBrush(path);
   //设置中心点色彩(终点色)
   pthGrBrush.CenterColor=Color.Red;

   //设置每个端点的色彩(终点色)
   Color[] colors =new Color[]
  {
   Color.Black,   Color.Green,
   Color.Blue, Color.White, 
   Color.Black,   Color.Green, 
   Color.Blue, Color.White,
   Color.Black,   Color.Green
  };

   pthGrBrush.SurroundColors=colors;
   //缩小画刷
   pthGrBrush.ScaleTransform(0.2f,0.2f);
   int i=0;

   //对渐变画刷使用平铺排列方式(默认方式)
   pthGrBrush.WrapMode=WrapMode.Tile;
   graphics.FillRectangle(pthGrBrush,new Rectangle(i*120,0,120,120));
   graphics.DrawRectangle(pen,new Rectangle(i*120,0,120,120));
   graphics.DrawString("Tile",myFont,brush, new PointF(20,125));

   i+=1;
   pthGrBrush.WrapMode=WrapMode.TileFlipX;
   graphics.FillRectangle(pthGrBrush,new Rectangle(i*120,0,120,120));
   graphics.DrawRectangle(pen,new Rectangle(i*120,0,120,120));
   graphics.DrawString("TileFlipX",myFont,brush, new PointF(170,125));

   //对渐变画刷使用垂直翻转排列方式
   pthGrBrush.WrapMode=WrapMode.TileFlipY;
   graphics.FillRectangle(pthGrBrush,new Rectangle(0,200,120,120));
   graphics.DrawRectangle(pen,new Rectangle(0,200,120,120));
   graphics.DrawString("TileFlipY",myFont,brush, new PointF(0,325));

   //对渐变画刷使用水平、垂直同时翻转排列方式
   pthGrBrush.WrapMode=WrapMode.TileFlipXY;
   graphics.FillRectangle(pthGrBrush,new Rectangle(120,200,120,120));
   graphics.DrawRectangle(pen,new Rectangle(120,200,120,120));
   graphics.DrawString("TileFlipXY",myFont,brush, new PointF(170,325));

   //输出路径的约束矩形、中心点信息
   RectangleF rect=new RectangleF();;
   //获取画刷的约束矩形对象
   rect=pthGrBrush.Rectangle;
   PointF CenterPoint=new PointF(0,0);
   //获取画刷的中心点信息
   CenterPoint=pthGrBrush.CenterPoint;
   String tmp=new String('S',256);;

   //格式化字符串
   tmp=string.Format("当前约束矩形的左上坐标为({0},{1}),宽度={2} 高度={3}",
    rect.X,rect.Y,rect.Height,rect.Width);
   tmp+="/n"+string.Format("当前渐变路径的中心点坐标为({0:F2},{1:F2})",
    CenterPoint.X,CenterPoint.Y);
   //输出中心点及约束矩形对象的信息
   graphics.DrawString(tmp,myFont,brush, new PointF(0,395));
  }
  //更改路径渐变画刷的中心点
  private void Brush_PathGradientBrush_CenterPoint_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //构造一个圆形区域
   GraphicsPath path=new GraphicsPath();
   path.AddEllipse(0, 0, 200, 200);
   SolidBrush brush=new SolidBrush(Color.FromArgb(155,Color.Red));
   //构造一个圆形路径渐变画刷
   PathGradientBrush pthGrBrush=new PathGradientBrush(path);
 
   //设置中心点色彩
   pthGrBrush.CenterColor=Color.FromArgb(155,Color.White);
   Color[] colors =new Color[]{Color.FromArgb(55, Color.Blue)};
   //设置边缘色
   pthGrBrush.SurroundColors=colors;
   //填充区域,使用单色画刷
   graphics.FillEllipse(pthGrBrush, 0, 0, 200, 200);
   //获取中心点色彩
   PointF center=new PointF(0,0);
   center=pthGrBrush.CenterPoint;

   //更改画刷的中心点沿圆周的上半部分平移
   for(int i=0;i<200;i++)
   {
    center.X=i;
    center.Y=10;
    pthGrBrush.CenterPoint=center;
    graphics.FillEllipse(pthGrBrush, 0, 0, 200, 200);
    //标记当前中心点
    graphics.FillEllipse(brush, center.X, center.Y, 2, 2);
   }

   //更改画刷的中心点沿圆周的下半部分平移
   for(int i=200;i>0;i--)
   {
    center.X=i;
    center.Y=190;
    pthGrBrush.CenterPoint=center;
    graphics.FillEllipse(pthGrBrush, 0, 0, 200, 200);
    //标记当前中心点
    graphics.FillEllipse(brush, center.X, center.Y, 2, 2);
   }

  }
  //对路径渐变画刷使用多色渐变
  private void Brush_PathGradientBrush_InterpolationColors_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   SolidBrush brush=new SolidBrush(Color.Red);
   //设置三角形的三个点
   Point[] points=new Point[]
  {
   new Point(100, 0), 
   new Point(200, 200),
   new Point(0, 200)
  };
   //创建一个三角形渐变画刷
   PathGradientBrush pthGrBrush=new PathGradientBrush(points);
   //-定义参与渐变的色彩
   Color[]  colors =new Color[] 
  {
   Color.Red,     //红
   Color.Green,     //绿
   Color.Blue // 蓝
  }; 

   //设置合成点的位置
   float[] pos =new float[] 
  {
   0.0f,    // 红色在区域边界为红色
   0.4f,    //在距离中心40%的位置处使用绿色
   1.0f //中心点使用蓝色
  };   

   //设置渐变的过渡色
   ColorBlend  blend=new ColorBlend (3);
   blend.Colors=colors;
   blend.Positions=pos;

   pthGrBrush.InterpolationColors=blend;
   //填充区域
   graphics.FillRectangle(pthGrBrush, 0, 0, 300, 300);  
   //标记中心点
   PointF centerpoint=new PointF(0,0);;
   centerpoint=pthGrBrush.CenterPoint;
   graphics.FillEllipse(brush, centerpoint.X-5, centerpoint.Y-5, 10, 10);  
  }
  //更改路径渐变画刷的焦点缩放比例
  private void Brsuh_PathGradietBrush_Focus_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Pen pen=new Pen(Color.Black,3);
   SolidBrush brush=new SolidBrush(Color.Black);
   Font myFont=new Font("Arial", 12);

   //指定三角形三点坐标,创建三角形渐变画
   Point[] points = new Point[]
 {
  new Point(100, 0),
  new Point(200, 200), 
  new Point(0, 200)
 };
 
   PathGradientBrush pthGrBrush=new PathGradientBrush(points);
   //指明渐变色
   Color[] colors = new Color[]{Color.Red, Color.Blue};
   //指明色彩合成位置
   float[] relativePositions=new float[]
  {
   0.0f,    // 红色做边界
   1.0f // 蓝色为中心
  };  
 
   //定义ColorBlend对象
   ColorBlend clrBlend=new ColorBlend();
   clrBlend.Colors=colors;
   clrBlend.Positions=relativePositions;
   //设置渐变色
   pthGrBrush.InterpolationColors=clrBlend;

   //使用默认缩放因子进行填充
   graphics.FillRectangle(pthGrBrush, 0, 0, 200, 200); 
 
   //获取默认缩放因子 
   PointF FocusScales=new PointF(0,0);
   FocusScales=pthGrBrush.FocusScales;
   //输出缩放信息
   String tmp=new String('D',256);
   tmp=String.Format("水平:x={0:F2}/n垂直:y={1:F2}",FocusScales.X,FocusScales.Y);
   graphics.DrawString(tmp,myFont,brush, new PointF(0,210));

   //平移绘图平面
   graphics.TranslateTransform(200,0);
   //更改缩放因子
   FocusScales.X=0.6f;
   FocusScales.Y=0.6f;
   pthGrBrush.FocusScales=FocusScales;

   graphics.FillRectangle(pthGrBrush, 0, 0, 200, 200);  
   graphics.DrawString("水平:x=0.6/n垂直:y=0.6", 
    myFont,brush, new PointF(0,210));

   //水平缩放不等于垂直缩放时特例
   graphics.TranslateTransform(200,0);
   //更改缩放因子
   FocusScales.X=0.1f;
   FocusScales.Y=0.8f;
   pthGrBrush.FocusScales=FocusScales;

   graphics.FillRectangle(pthGrBrush,0, 0, 200, 200); 
   graphics.DrawString("水平:x=0.1/n垂直:y=0.8",
    myFont,brush, new PointF(0,210));

   //水平缩放=垂直缩放=1.0
   graphics.TranslateTransform(200,0);
   FocusScales.X=1.0f;
   FocusScales.Y=1.0f;
   pthGrBrush.FocusScales=FocusScales;

   graphics.FillRectangle(pthGrBrush, 0, 0, 200, 200); 
   graphics.DrawString("水平:x=1.0/n垂直:y=1.0",
    myFont,brush, new PointF(0,210));

   //水平缩放不等于垂直缩放时特例:放大原有区域
   graphics.TranslateTransform(200,0);
   FocusScales.X=2.0f;
   FocusScales.Y=1.5f;
   pthGrBrush.FocusScales=FocusScales;

   graphics.FillRectangle(pthGrBrush, 0, 0, 200, 200); 
   graphics.DrawString("水平:x=2.0/n垂直:y=1.5",
    myFont,brush, new PointF(0,210));

  }
  //路径渐变画刷的变换
  private void Brush_PathGradientBrush_Transform_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   // 定义一个三角形路径渐变画刷
   Point[] pts =new Point[]{new Point(50, 0), new Point(100, 100), new Point(0, 100)};
   PathGradientBrush pthGrBrush=new PathGradientBrush(pts);

   //对画刷使用垂直翻转方式
   pthGrBrush.WrapMode=WrapMode.TileFlipY;
   //缩小画刷 
   pthGrBrush.ScaleTransform(0.5f, 0.5f);
   //填充当前窗口
   graphics.FillRectangle(pthGrBrush, 0, 0, this.Width,this.Height);

   //将画刷旋转90度
   pthGrBrush.RotateTransform(90.0f, MatrixOrder.Append);
   //再次填充当前窗口
   graphics.FillRectangle(pthGrBrush, 0, 0, this.Width,this.Height);
  }

  private void Brsuh_LinearGradientBrush_UsingGamma_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   LinearGradientBrush linGrBrush = new LinearGradientBrush(
    new Point(0, 10),
    new Point(200, 10),
    Color.Red,
    Color.Blue);

   graphics.FillRectangle(linGrBrush, 0, 0, 200, 50);
   linGrBrush.GammaCorrection = true;
   graphics.FillRectangle(linGrBrush, 0, 60, 200, 50);
  
  }
  //简单的使用字体示意
  private void Font_UsingFontInGDIPlus_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);;
   //新建一个字体对话框
   FontDialog dlg=new FontDialog();
   //允许对字体进行色彩设置
   dlg.ShowColor=true;
   //调用字体选择对话框
   if(dlg.ShowDialog()!=DialogResult.OK)
    return;
   //获取在字体对话框中的字体信息
   Font myFont=dlg.Font;
   //根据字体色彩创建画刷
   SolidBrush brush=new SolidBrush(dlg.Color);
   //设置文本输出格式:在当前窗口中居中显示
   StringFormat fmt=new StringFormat();
   fmt.Alignment=StringAlignment.Center;
   fmt.LineAlignment=StringAlignment.Center;
   //输出文本
   graphics.DrawString("输出文本", myFont,brush,new Rectangle(0,0,this.Width,this.Height),fmt);

  }
  //枚举所有的字体系列
  private void Font_EnumAllFonts_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   SolidBrush   solidBrush=new SolidBrush(Color.Black);
   FontFamily   fontFamily=new FontFamily("Arial");
   Font         font=new Font(fontFamily, 8, FontStyle.Regular, GraphicsUnit.Point);
   //设置文本输出格式
   StringFormat fmt=new StringFormat();
   fmt.Alignment=StringAlignment.Near;
   fmt.LineAlignment=StringAlignment.Near;

   string tmp="";
   //获取所有已经安装的字体系列
   InstalledFontCollection installedFontCollection=new InstalledFontCollection();
   FontFamily[] fontfamily=installedFontCollection.Families;
   int index=0;
   //访问fontfamily数组的每一个成员
   foreach (FontFamily i in fontfamily)
   {
    //获取当前字体系列名称
    tmp+=i.Name+", ";
    index++;
   }

   //在窗口中输出所有的字体系列名
   Rectangle r=new Rectangle(0,10,this.Width,this.Height);
   graphics.DrawString(tmp,font,solidBrush,r,fmt);
   //输出字体系列信息
   tmp=String.Format("在你的系统中已经安装的字体有{0}种,其名称分别为:/n",index+1);
   graphics.DrawString(tmp,font,solidBrush,new Point(0,0));
  }

  //启用增强型选择对话框表单
  private void Font_EnhanceFontDialog_Click(object sender, System.EventArgs e)
  {
   Form3 f=new Form3();
   f.ShowDialog();
  }
  //使用不同的字体边缘处理方式
  private void Font_UsingTextRenderHint_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   SolidBrush brs=new SolidBrush(Color.Black);
   FontFamily  fontFamily=new FontFamily("Arial");
   Font        font=new Font(fontFamily, 60, FontStyle.Regular, GraphicsUnit.Pixel);

   //使用不同的边缘处理方式输出六行文本
   foreach (TextRenderingHint Render in Enum.GetValues(typeof(TextRenderingHint)))
   {
    //设置边缘处理方式
    graphics.TextRenderingHint=Render;
    //输出文本
    graphics.DrawString("Render",font,brs,new PointF(0, 0));
    //绘图平面下移地行
    graphics.TranslateTransform(0,font.Height);
   }
  }
  //使用私有字体集合
  private void Font_Privatefontcollection_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   PointF      pointF=new PointF(0.0f, 10.0f);
   SolidBrush  solidBrush=new SolidBrush(Color.Red);
   //创建私有字体集
   PrivateFontCollection privateFontCollection=new PrivateFontCollection();
 
   //在私有字体集中追迷你繁启体字库文件"繁启体.TTF"
   string fontfile="c://繁启体.TTF";
   try
   {
    privateFontCollection.AddFontFile(fontfile); 
   }
   catch
   {
    MessageBox.Show("字体文件加载失败","出错啦!");
    return;
   }

   //从私有字体集合中构造繁启体,大小为35像素
   FontFamily pFontFamily=new FontFamily("迷你繁启体",privateFontCollection);
   Font tmpFont=new Font(pFontFamily,35);
   //输出繁启体文字
   graphics.DrawString("沉舟侧畔千帆过", tmpFont,solidBrush, pointF);
   //垂直坐标一移一行,行高为  字体的高度
   pointF.Y +=tmpFont.Height;
   graphics.DrawString("病树前头万木春", tmpFont,solidBrush, pointF);
  }

  private void menuItem9_Click(object sender, System.EventArgs e)
  {
  
  }
  //在私有字体集合中使用多种字体
  private void Font_Privatefontcollection2_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   PointF      pointF=new PointF(0.0f, 10.0f);
   SolidBrush  solidBrush=new SolidBrush(Color.Red);
   //创建私有字体集
   PrivateFontCollection privateFontCollection=new PrivateFontCollection();
   //在私有字体集中追加三个不同的字体文件
   privateFontCollection.AddFontFile("C://WINDOWS//Fonts//STCAIYUN.TTF");
   privateFontCollection.AddFontFile("C://WINDOWS//Fonts//SIMLI.TTF");
   privateFontCollection.AddFontFile("C://WINDOWS//Fonts//Arial.ttf");

   //访问私有字体集合中的所有字体系列
   foreach(FontFamily i in privateFontCollection.Families)
   {
    Font tmpFont=new Font(i,35);
    //输出繁启体文字
    graphics.DrawString("字体名:  "+i.Name, tmpFont,solidBrush, pointF);
    graphics.TranslateTransform(0,tmpFont.Height);
   }
 
   //通过访问PrivateFontCollection类的Families数组成员来字体
   for(int index=0;index< privateFontCollection.Families.Length;index++)
   {
    Font tmpFont=new Font(privateFontCollection.Families[index].Name,35);
    //输出繁启体文字
    graphics.DrawString("字体名:  "+privateFontCollection.Families[index].Name,
     tmpFont,solidBrush, pointF);
    graphics.TranslateTransform(0,tmpFont.Height);
   }
  }
  //检查字体风格是否可用
  private void Font_IsStyleAvailable_Click(object sender, System.EventArgs e)
  {

   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Pen pen=new Pen(Color.Gray);
   PointF      pointF=new PointF(10.0f, 0.0f);
   SolidBrush  solidBrush=new SolidBrush(Color.Black);
   //信息输出所使用的字体
   Font msgfont=new Font("Arial",12);

   //创建私有字体集
   PrivateFontCollection privateFontCollection=new PrivateFontCollection();
   //在私有字体集中追加三个字体文件
   //黑体
   privateFontCollection.AddFontFile("C://windows//Fonts//simhei.ttf");
   //Courier New字体
   privateFontCollection.AddFontFile("C://windows//Fonts//CourBI.ttf");
   //华文隶书
   privateFontCollection.AddFontFile("C://windows//Fonts//STLITI.ttf");

   string     familyName=string.Empty;
   string     tmpmsg=string.Empty;

   //查询私有字体集中字体系列数量
   int count=privateFontCollection.Families.Length;
   //获取字体系列数组
   FontFamily[] pFontFamily=new FontFamily[count];   
   //将字体系列中的字体名中加入pFontFamily中
   pFontFamily=privateFontCollection.Families;

   /*对私有字体集中每一个字体系列进行五种字体风格
   的查询,如果字体风格可用,使用该风格进行文本绘制
   */
   for(int j = 0; j< count; ++j)
   {
    //从字体系列中获取字体名
    familyName=pFontFamily[j].Name;
    // 常规风格是否可用
    if(pFontFamily[j].IsStyleAvailable(FontStyle.Regular))
    {
     tmpmsg="  字体的常规风格可用";
     //构造字体
     FontFamily fm=new FontFamily(familyName,privateFontCollection);
     Font tmpFont=new Font(fm, 
      12, FontStyle.Regular, GraphicsUnit.Pixel);
     //输出使用常规风格的字体
     graphics.DrawString(familyName+tmpmsg,tmpFont,solidBrush,pointF );
     //垂直坐标一移一行,行高为  字体的高度
     pointF.Y += tmpFont.Height;
    }
    else
    {
     graphics.DrawString(familyName+tmpmsg+
      "  字体的常规风格不可用",msgfont,solidBrush,pointF);
     pointF.Y += msgfont.Height;
    }
    tmpmsg=string.Empty;

    // 粗体风格是否可用
    if(pFontFamily[j].IsStyleAvailable(FontStyle.Bold))
    {
     tmpmsg="  字体的粗体风格可用";
     //构造字体
     FontFamily fm=new FontFamily(familyName,privateFontCollection);
     Font tmpFont=new Font(fm, 
      12, FontStyle.Bold, GraphicsUnit.Pixel);
     //输出使用常规风格的字体
     graphics.DrawString(familyName+tmpmsg,tmpFont,solidBrush,pointF );
     //垂直坐标一移一行,行高为  字体的高度
     pointF.Y += tmpFont.Height;
    }
    else
    {
     graphics.DrawString(familyName+tmpmsg+
      "  字体的粗体风格不可用",msgfont,solidBrush,pointF);
     pointF.Y += msgfont.Height;
    }
    tmpmsg=string.Empty;

    // 斜体风格是否可用
    if(pFontFamily[j].IsStyleAvailable(FontStyle.Italic))
    {
     tmpmsg="  字体的斜体风格可用";
     //构造字体
     FontFamily fm=new FontFamily(familyName,privateFontCollection);
     Font tmpFont=new Font(fm, 
      12, FontStyle.Italic, GraphicsUnit.Pixel);
     //输出使用常规风格的字体
     graphics.DrawString(familyName+tmpmsg,tmpFont,solidBrush,pointF );
     //垂直坐标一移一行,行高为  字体的高度
     pointF.Y += tmpFont.Height;
    }
    else
    {
     graphics.DrawString(familyName+tmpmsg+
      "  字体的斜体风格不可用",msgfont,solidBrush,pointF);
     pointF.Y += msgfont.Height;
    }
    tmpmsg=string.Empty;

    // 查询下划线风格是否可用
    if(pFontFamily[j].IsStyleAvailable(FontStyle.Underline))
    {
     tmpmsg="  字体的下划线风格可用";
     //构造字体
     FontFamily fm=new FontFamily(familyName,privateFontCollection);
     Font tmpFont=new Font(fm, 
      12, FontStyle.Underline, GraphicsUnit.Pixel);
     //输出使用常规风格的字体
     graphics.DrawString(familyName+tmpmsg,tmpFont,solidBrush,pointF );
     //垂直坐标一移一行,行高为  字体的高度
     pointF.Y += tmpFont.Height;
    }
    else
    {
     graphics.DrawString(familyName+tmpmsg+
      "  字体的下划线风格不可用",msgfont,solidBrush,pointF);
     pointF.Y += msgfont.Height;
    }
    tmpmsg=string.Empty;

    // 查询强调线风格是否可用
    if(pFontFamily[j].IsStyleAvailable(FontStyle.Strikeout))
    {
     tmpmsg="  字体的强调线风格可用";
     //构造字体
     FontFamily fm=new FontFamily(familyName,privateFontCollection);
     Font tmpFont=new Font(fm, 
      12, FontStyle.Strikeout, GraphicsUnit.Pixel);
     //输出使用常规风格的字体
     graphics.DrawString(familyName+tmpmsg,tmpFont,solidBrush,pointF );
     //垂直坐标一移一行,行高为  字体的高度
     pointF.Y += tmpFont.Height;
    }
    else
    {
     graphics.DrawString(familyName+tmpmsg+
      "  字体的强调线风格不可用",msgfont,solidBrush,pointF);
     pointF.Y += msgfont.Height;
    }
    tmpmsg=string.Empty;

    // 在不同的字体系列之间加上间隔线
    graphics.DrawLine(pen,0,(int )pointF.Y,400,(int)pointF.Y);
    pointF.Y += 10.0f;
   }
  }
  //获取字体的大小
  private void Font_Size_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   PointF      pointF=new PointF(0.0f, 0.0f);
   SolidBrush  solidBrush=new SolidBrush(Color.Black);

   string infoString =string.Empty;  
   int  ascent;                 
   float  ascentPixel;            
   int  descent;               
   float  descentPixel;          
   int  lineSpacing;           
   float  lineSpacingPixel;      

   FontFamily   fontFamily=new FontFamily("Arial");
   //创建一个大小为16像素的Aria字体
   Font  font=new Font(fontFamily, 16, FontStyle.Regular, GraphicsUnit.Pixel);
   Font  font2=new Font(fontFamily, 14, FontStyle.Regular, GraphicsUnit.Pixel);

   // 显示字体大小
   infoString=string.Format("font的Size属性值为{0:F2}",font.Size);
   graphics.DrawString(infoString,font2,solidBrush,pointF);
   // 下移一行
   pointF.Y += font2.Height;
   //显示字体高度:像素
   infoString=string.Format("font的Height属性值为{0:F2}", font.Height);
   graphics.DrawString(infoString,font2,solidBrush,pointF);
   // 下移一行
   pointF.Y += font2.Height;

   // 显示字体系列的高度(设计单位)
   infoString=string.Format("使用fontFamily.GetEmHeight函数返回的字体高度为{0}个设计单位。"
    ,fontFamily.GetEmHeight(FontStyle.Regular));
   graphics.DrawString(infoString,font2,solidBrush,pointF);

   // 下移两行(Height属性的值是字体的高度,单位为像素)
   pointF.Y += 2.0f*font2.Height;

   // 获取字体的Ascent(上部距离)
   ascent = fontFamily.GetCellAscent(FontStyle.Regular);

   //将上部距离的设计单位转换成像素单位
   ascentPixel= 
    font.Size * ascent / fontFamily.GetEmHeight(FontStyle.Regular);
   infoString=string.Format("上部距离为{0}个设计单位, {1:F2}个像素。",
    ascent, ascentPixel);
   graphics.DrawString(infoString,font2,solidBrush,pointF);

   // 下移一行
   pointF.Y += font2.Height;
   // 获取字体的Descent(下部距离),设计单位
   descent = fontFamily.GetCellDescent(FontStyle.Regular);

   //将下部距离的设计单位转换成像素单位
   descentPixel = 
    font.Size * descent / fontFamily.GetEmHeight(FontStyle.Regular);
   infoString=string.Format("下部距离为{0} 个设计单位,{1:F2}个像素。",
    descent, descentPixel);
   graphics.DrawString(infoString,font2,solidBrush,pointF);

   // 下移一行
   pointF.Y += font2.Height;
   //获取行距(设计单位)
   lineSpacing = fontFamily.GetLineSpacing(FontStyle.Regular);
   //将行距的设计单位转换成像素单位
   lineSpacingPixel = 
    font.Size * lineSpacing / fontFamily.GetEmHeight(FontStyle.Regular);
   infoString=string.Format("行距为{0} 个设计单位,{1:F2} 像素。",
    lineSpacing, lineSpacingPixel);
   graphics.DrawString(infoString,font2,solidBrush,pointF);
  }
  //设置文本输出基线
  private void Font_BaseLine_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   FontFamily   fontFamily=new FontFamily("Arial");
   //创建一个大小为60像素的Aria字体
   Font  font=new Font(fontFamily, 60, FontStyle.Regular, GraphicsUnit.Pixel);
   //获取当前窗口的矩形宽、高
   int  cy=this.Height;
   int cx=this.Width;

   Pen pen=new Pen(Color.Blue, 1);
   SolidBrush brush=new SolidBrush(Color.Blue);

   //将窗口垂直方向的1/2部分作为基线
   float yBaseline = cy / 2;
   //绘制基线
   graphics.DrawLine(pen, new PointF(0, yBaseline),new PointF(cx,yBaseline));
   //得到字体高度
   float cyLineSpace = font.Height;
   //获取行距
   int   iCellSpace  = fontFamily.GetLineSpacing(FontStyle.Regular);
   //得到上半部分距离
   int   iCellAscent = fontFamily.GetCellAscent(FontStyle.Regular);
   //计算文本输出的起始位置相对于基线的偏移
   float cyAscent    = cyLineSpace * iCellAscent / iCellSpace;

   //从中央向上绘制两条直线,间隔为cyAscent
   graphics.DrawLine(pen, 
    new PointF(0, yBaseline-cyAscent), new PointF(cx,yBaseline-cyAscent));
   graphics.DrawLine(pen, 
    new PointF(0, yBaseline-2.0f*cyAscent), new PointF(cx,yBaseline-2.0f*cyAscent));

   //分别在两条基线上输出文本
   graphics.DrawString("AaFfgSs}", font,brush,new PointF(0,yBaseline - cyAscent));
   graphics.DrawString("AaFfgSs}",font,brush,new PointF(0,yBaseline - 2.0f*cyAscent));

  }

  private void Font_DrawString_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //输出文本
   string msg="示例文本";
 
   Font myFont=new Font("宋体", 16);
   Rectangle layoutRect=new Rectangle(50, 50, 200, 50);
   //设置对齐方式
   StringFormat format=new StringFormat();
   format.Alignment=StringAlignment.Center;
   SolidBrush blackBrush=new SolidBrush(Color.Black);

   // 绘制文本
   graphics.DrawString(msg,myFont,blackBrush,layoutRect,format);
   // 绘制文本输出的矩形区域
   graphics.DrawRectangle(new Pen(Color.Black, 3), layoutRect);

  }

  private void Font_MeasureString_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //设置一个包含三行文本的字符串
   string txtOut="123456789/n";
   txtOut+="ABCDEFGHIJKLM/n";
   txtOut+="一二三四五六七八九";

   FontFamily   fontFamily=new FontFamily("Arial");
   //创建两个个大小不同的Aria字体
   Font  font=new Font(fontFamily, 30, FontStyle.Regular, GraphicsUnit.Pixel);
   Font  font2=new Font(fontFamily, 14, FontStyle.Regular, GraphicsUnit.Pixel);
   SolidBrush brush=new SolidBrush(Color.Black);

   StringFormat fmt=new StringFormat();
   fmt.Alignment=StringAlignment.Center;
   fmt.LineAlignment=StringAlignment.Center;

   SizeF stringSize = new SizeF();   
   //测量输出字符串所需要的矩形空间
   stringSize=graphics.MeasureString(txtOut,font);

   string tmp=string.Empty;
   tmp=string.Format("输出字符串所需要的宽度为:{0:F2}  高度为{1:F2}",
    stringSize.Width,stringSize.Height,font.Height);

   // 绘制输出文本的限制矩形
   graphics.DrawRectangle(new Pen(Color.Red),
    10.0f,10.0f,stringSize.Width,stringSize.Height);
   //输出字符串的测量信息
   graphics.DrawString(txtOut,font,brush,
    new RectangleF(10.0f,10.0f,stringSize.Width,stringSize.Height),fmt);
   graphics.TranslateTransform(0,10+stringSize.Height);
   graphics.DrawString(tmp,font2,brush,new PointF(0,0));
  }
  //计算在指定的区域中显示的字符总数及行数
  private void Font_MeasureString2_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   string txtOut="123456789";
   txtOut+="ABCDEFGHIJKLM";
   txtOut+="一二三四五六七八九";

   FontFamily   fontFamily=new FontFamily("Arial");
   //创建两个个大小不同的Aria字体
   Font  font=new Font(fontFamily, 30, FontStyle.Regular, GraphicsUnit.Pixel);
   Font  font2=new Font(fontFamily, 14, FontStyle.Regular, GraphicsUnit.Pixel);
   //设置文本输出矩形
   Rectangle layoutRect=new Rectangle(10, 10,100,100);
   SolidBrush brush=new SolidBrush(Color.Black);

   //设置文本显示格式
   StringFormat fmt=new StringFormat();  
   fmt.Alignment=StringAlignment.Center;
   fmt.LineAlignment=StringAlignment.Center;

   int codepointsFitted=0;
   int linesFilled=0;
 
   SizeF stringSize = new SizeF();   
   //计算指定的区域能够显示的字符总数及行数
   stringSize=graphics.MeasureString(txtOut,
    font,new SizeF(layoutRect.Width,layoutRect.Height) ,
    fmt,out codepointsFitted,out linesFilled);

   string tmp=string.Empty;
   tmp=string.Format("欲输出的字串共{0}个字符/n其中,在指定的输出矩形中/n只输出了{1}行共{2}个字符",txtOut.Length,linesFilled,codepointsFitted);

   // 绘制指定的文本输出区域
   graphics.DrawRectangle(new Pen(Color.Blue,2), layoutRect);
   //在指定的区域矩形中显示文本
   graphics.DrawString(txtOut,font,brush,layoutRect,fmt);

   //输出字符串的测量信息
   graphics.TranslateTransform(0,10+stringSize.Height);
   graphics.DrawString(tmp,font2,brush,new PointF(0,0));
  }
  //文本的分栏输出
  private void Font_ColumnTextOut_Click(object sender, System.EventArgs e)
  {
   //选定欲分栏显示的文件
   OpenFileDialog  dlg=new OpenFileDialog();
   dlg.ShowReadOnly=true;
   //文件对话框标题
   dlg.Title="选择欲分栏显示的文本文件";
   dlg.Filter="文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*";
   //选择了取消
   if(dlg.ShowDialog()!=DialogResult.OK)
    return;
   StreamReader stream =new StreamReader(dlg.FileName,
    System.Text.Encoding.Unicode);
   string buffer=string.Empty;
   //读取所有的文件内容 
   buffer=stream.ReadToEnd();
   //关闭文件
   stream.Close();
   String str=buffer;
 
   //定义栏宽及栏与栏之间的间隔
   int COLUMWIDTH=100;
   int SPACE=10;

   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   SolidBrush brush=new SolidBrush(Color.Black);
   Font myFont=new Font("宋体", 10);
   int codepointsFitted=0;
   int linesFilled=0;

   //设置输出格式
   StringFormat format=new StringFormat();
   //禁用自动剪载
   format.FormatFlags=StringFormatFlags.NoClip;
   //输出文本以单词结束
   format.Trimming=StringTrimming.Word ;

   //从左至右按列(栏)输出文本
   for (int x = 0; str.Length> 0&&x
   
   
    
    <3; 清空制表位 firstTabOffset); tabStops="stringFormat.GetTabStops(out" firstTabOffset="0;" 获取制表信息 tabs2); 60.0f,60}; tabs2="{60.0f," 设置制表位信息2 text="One two three four five seven eight nine ten" 使用制表位信息的进行文本输出 30.0f,40}; {40.0f, 设置制表位信息1 不使用制表位信息的输出 输出文本使用的字体 Font_TextoutUsingTabs_Click(object 使用制表位 2),strfmt); PointF(this.ClientSize.Width graphics.DrawString(s,font,brush,new 在当前区域中按照设置的对齐方式绘制文本 strAlign[iVert],strAlign[iHorz]); 将对齐信息输出 strfmt.Alignment="(StringAlignment)Align[iHorz];" 设置水平对齐方式 strfmt.LineAlignment="(StringAlignment)Align[iVert];" 设置垂直对齐方式 iHorz+="2)" 3; iHorz="0;" iVert+="2)" iVert="0;" 分别在垂直和水平方向上使用三种不同的对齐方式 strfmt="new" FontStyle.Regular); FontFamily(?幼圆?); 设置输出字体 ?远? ?中?, ?近?, string[]{ strAlign="new" StringAlignment.Far StringAlignment.Center, StringAlignment.Near, StringAlignment[3] Align="new" StringAlignment[] 将StringAlignment枚举的三种不同的对齐方式设置成数组成员,以便直接访问 2)); PointF(rect.Width,rect.Height 2),new PointF(0,rect.Height 2,rect.Height)); 2,0),new 以当前窗口中心点为原点绘制坐标轴 this.ClientSize.Height); this.ClientSize.Width, 将当前窗口大小信息保存 Font_TextAlignment2_Click(object this.Invalidate(); Form1_Resize(object System.Windows.Forms.PaintEventArgs Form1_Paint(object strfmt); graphics.DrawString(s,font,brush,rect, iHorz++) iVert++) Font_TextAlignment_Click(object 设置文本对齐方式 graphics.DrawString(ts,myFont,brush,f,strFormat); graphics.DrawRectangle(pen,f); 绘制输出区间及文本 strFormat.LineAlignment="StringAlignment.Center;" strFormat.Alignment="StringAlignment.Center;" strFormat.FormatFlags="flag;" 设置输出格式标志 flag|="StringFormatFlags.DirectionVertical;" 文本在竖直方向上输出 flag="StringFormatFlags.DirectionRightToLeft;" StringFormatFlags 从至左输出文本 strFormat="new" 构造StringFormat对象 Rectangle(10,10,120,myFont.Height*8); f="new" 设置输出区间 ts+="万里长征人未还。" ts="秦时明月汉时关," 添加需要输出的字串 Font_TextoutDirection_Click(object 控件文本输出方向 CharRangeRegions[i]); graphics.FillRegion(RegionBrush, i++) <4; layoutRect_C.X,layoutRect_C.Y,layoutRect_C.Width,layoutRect_C.Height); strFormat); myFont,TextBrush,layoutRect_C, graphics.DrawString(ts, CharRangeRegions="new" 在矩形layoutRect_c中对文本进行局部测量,测量的结果保存在CharRangeRegions中 layoutRect_B.X,layoutRect_B.Y,layoutRect_B.Width,layoutRect_B.Height); myFont,TextBrush,layoutRect_B, layoutRect_B, myFont, 在矩形layoutRect_B中对文本进行局部测量,测量的结果保存在CharRangeRegions中 4; 填充由CharRangeRegions保存的区域 i; short layoutRect_A.X,layoutRect_A.Y,layoutRect_A.Width,layoutRect_A.Height); 绘制文本输出边框 myFont,TextBrush,layoutRect_A, 在矩形layoutRect_A中对文本进行局部测量,测量的结果保存在CharRangeRegions中 strFormat.SetMeasurableCharacterRanges(charRanges); 在字体格式中设置需要局部测量的区域 Region[4]; Region[] 指向需要局部测量区域的数组 FontStyle.Italic, FontFamily(?华文新魏?); 绘制文本时使用的字体及大小 3) CharacterRange(28, 3), CharacterRange(20, CharacterRange(12, CharacterRange(4, CharacterRange[] charRanges="new" 在字串中需要局部测量的文本定义区域:每行诗的最后三个字 180.0f, RectangleF(280.0f, layoutRect_C="new" 140.0f, RectangleF(140.0f, layoutRect_B="new" 120.0f, RectangleF(20.0f, layoutRect_A="new" 使用三个宽度不同的矩形区域绘制文本,示意不同局部区域测量结果 SolidBrush(Color.FromArgb(100, RegionBrush="new" TextBrush="new" 设置绘制文本、填充区域的画刷 Font_MeasureCharacterRanges_Click(object 测量文本局部输出区域 outtext.Width,outtext.Height); outtext.X,outtext.Y, 绘制文本输出区域 graphics.DrawString(text,font,solidBrush,outtext, stringFormat.FormatFlags="StringFormatFlags.NoClip;" 在输出文本时不使用剪截 graphics.TranslateTransform(120,0); out2.Y,out2.Width,out2.Height); out2.X, graphics.DrawString(text,font,solidBrush,out2, out2.Height="font.Height*2;" 将输出区域的高度调整为字体高度的整数倍 out2="outtext;" 在水平方向平移170个像素更 outtext.Y,outtext.Width,outtext.Height); outtext.X, 使用默认值输出文本 45); RectangleF(10, outtext="new" Font_TextOutClip_Click(object 文本输出的剪裁处理 msgFormat); graphics.DrawString(?EllipsisPath?,font2,solidBrush,outrect, graphics.DrawString(text,font,solidBrush, stringFormat.Trimming="StringTrimming.Character;" graphics.TranslateTransform(160,0); 更改去尾方式:EllipsisPath graphics.DrawString(?EllipsisWord?,font2,solidBrush,outrect, 更改去尾方式:EllipsisWord graphics.DrawString(?EllipsisCharacter?,font2,solidBrush,outrect, 更改去尾方式:EllipsisCharacter graphics.DrawString(?Word?,font2,solidBrush,outrect, 更改去尾方式:Word 绘图平面沿水平方向平移160个像素 graphics.DrawString(?Character?,font2,solidBrush,outrect, 输出提示信息 去尾方式:Character font2.Height*2); outrect="new" 提示信息输出区域 msgFormat.LineAlignment="StringAlignment.Center;" msgFormat.Alignment="StringAlignment.Center;" msgFormat="new" 设置文本输出的格式 font2="new" 用于提示信息的字体及格式 用于文本输出的字体 Font_StirngTrimming_Click(object 设置文本的去尾方式 str="str.Substring(codepointsFitted);" 去掉已经输出的字符,以便下一栏能够正常显示 layoutRect,format); graphics.DrawString(str,myFont,brush, 显示一栏文本 linesFilled); codepointsFitted,out format,out , SizeF(layoutRect.Width,layoutRect.Height) myFont,new stringSize="new" 计算指定的区域能够显示的字符总数及行数 SizeF(); SizeF COLUMWIDTH,this.Height-myFont.Height); RectangleF(x, 设置文本对应的矩形区域(一栏)>B)
   graphics.TranslateTransform(width+10,0);
   //设置R->B色彩变换矩阵
   imageAttributes.SetColorMatrix(
    colorMatrix, 
    ColorMatrixFlag.Default,
    ColorAdjustType.Bitmap);
   graphics.DrawImage(
    image, 
    new Rectangle(0, 10, width, height),  
    0, 0,width,height,      
    GraphicsUnit.Pixel,
    imageAttributes);

   //清除已经采取的色彩变换
   imageAttributes.ClearColorMatrix(ColorAdjustType.Bitmap);
 
   //重新加载另一变换矩阵Matrix2
   //绿色绕着红色旋转
   float[][] colorMatrixElements2=
 {
  new float[]{1,  0, 0.0f, 0.0f, 0.0f},
  new float[]{0, (float)Math.Cos(r), (float)Math.Sin(r), 0.0f, 0.0f},
  new float[]{0.0f, -(float)Math.Sin(r), (float)Math.Cos(r), 0.0f, 0.0f},
  new float[]{0.0f,    0.0f,   0.0f, 1.0f, 0.0f},
  new float[]{0.0f,    0.0f,   0.0f, 0.0f, 1.0f}
 };
   ColorMatrix colorMatrix2=new ColorMatrix(colorMatrixElements2);

   imageAttributes.SetColorMatrix(
    colorMatrix2, 
    ColorMatrixFlag.Default,
    ColorAdjustType.Bitmap);

   //在第二行输出
   graphics.ResetTransform();
   graphics.TranslateTransform(0,height+10);
   graphics.DrawImage(image, 
    new Rectangle(0, 0, width, height),
    0, 0,width, height,GraphicsUnit.Pixel,
    imageAttributes);

   //清除已经采取的色彩变换
   imageAttributes.ClearColorMatrix(ColorAdjustType.Bitmap);
   //蓝色绕着红色旋
   float[][] colorMatrixElements3=
 {

  new float[]{(float)Math.Cos(r),  0, -(float)Math.Sin(r), 0.0f, 0.0f},
  new float[]{0, 1, 0.0f, 0.0f, 0.0f},
  new float[]{(float)Math.Sin(r), 0, (float)Math.Cos(r), 0.0f, 0.0f},
  new float[]{0.0f,    0.0f,   0.0f, 1.0f, 0.0f},
  new float[]{0.0f,    0.0f,   0.0f, 0.0f, 1.0f}
 };
   ColorMatrix colorMatrix3 =new ColorMatrix(colorMatrixElements3);

   //重新加载另一变换矩阵Matrix3
   imageAttributes.SetColorMatrix(
    colorMatrix3, 
    ColorMatrixFlag.Default,
    ColorAdjustType.Bitmap);
   graphics.TranslateTransform(width+10,0);
   graphics.DrawImage(
    image, 
    new Rectangle(0, 0, width, height),
    0, 0,
    width, height,GraphicsUnit.Pixel,
    imageAttributes);
  }

  private void ColorShear_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //加载图片
   Bitmap  image=new Bitmap("Colorinput.bmp");
   ImageAttributes  imageAttributes=new ImageAttributes();
   int   width = image.Width;
   int   height = image.Height;

   //定义色彩变换矩阵
   float[][] colorMatrixElements=
 {
  new float[]{1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
  new float[]{0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
  new float[]{0.5f, 0.0f, 1.0f, 0.0f, 0.0f},
  new float[]{0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
  new float[]{ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}
 };

   ColorMatrix colorMatrix=new ColorMatrix(colorMatrixElements);
   //启用色彩变换矩阵
   imageAttributes.SetColorMatrix(
    colorMatrix, 
    ColorMatrixFlag.Default,
    ColorAdjustType.Bitmap);

   //绘制源图
   graphics.DrawImage(image, 0, 0);
   //使用色彩变换矩阵输出图片
   graphics.TranslateTransform(width+10,0);
   graphics.DrawImage(image, new Rectangle(0, 0, width, height),
    0, 0,width, height,GraphicsUnit.Pixel,imageAttributes);

  }

  private void ColorRemap_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //加载蓝色背景的图片
   Bitmap            image=new Bitmap("Nemo_Blue.bmp");
   ImageAttributes  imageAttributes=new ImageAttributes();

   int   width = image.Width;
   int   height = image.Height;
   //将蓝色替换成白色,以达到抠除的效果
   ColorMap   colorMap=new ColorMap();
   colorMap.OldColor = Color.FromArgb(255, 0, 0, 255); 
   colorMap.NewColor = Color.FromArgb(255, 255,255,255);
   //设置色彩转换表
   ColorMap[] remapTable = {colorMap};

   //设置图片的色彩信息
   imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
   //绘制原始图像
   graphics.DrawImage(image, 0, 0, width, height);
   //绘制已经抠除背景色的新图像
   graphics.DrawImage(image, 
    new Rectangle(width+10, 0, width, height),  //目标区域
    0, 0,        // 源图左上角坐标
    width,       // 源图宽
    height,      // 源图宽
    GraphicsUnit.Pixel,
    //图片的色彩信息
    imageAttributes);
  }

  private void SetRGBOutputChannel_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //加载图片
   Bitmap  image=new Bitmap("jieba.bmp");
   //绘制源图
   graphics.DrawImage(image, 0, 0);
 
   int  width = image.Width;
   int height = image.Height;
   ImageAttributes  imageAttributes=new ImageAttributes();

   //设置红色通道
   float[][] colorMatrixElements=
  {
   new float[]{1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 1.0f}
  };
   ColorMatrix colorMatrix=new ColorMatrix(colorMatrixElements);
 
   //启用色彩变换矩阵
   imageAttributes.SetColorMatrix(
    colorMatrix, 
    ColorMatrixFlag.Default,
    ColorAdjustType.Bitmap);
   //使用色彩变换矩阵输出图片
   graphics.TranslateTransform(width+10,0);
   graphics.DrawImage(image, new Rectangle(0, 0, width, height),
    0, 0,width, height,GraphicsUnit.Pixel,imageAttributes);

   //清除已经采取的色彩变换
   imageAttributes.ClearColorMatrix(ColorAdjustType.Bitmap);
   //设置绿色通道
   float[][] colorMatrixElements2=
  {
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 1.0f}
  };
   ColorMatrix colorMatrix2=new ColorMatrix(colorMatrixElements2);
 
   //启用色彩变换矩阵
   imageAttributes.SetColorMatrix(
    colorMatrix2, 
    ColorMatrixFlag.Default,
    ColorAdjustType.Bitmap);
   //使用色彩变换矩阵输出图片
   graphics.ResetTransform();
   graphics.TranslateTransform(0,height+10);
   graphics.DrawImage(image, new Rectangle(0, 0, width, height),
    0, 0,width, height,GraphicsUnit.Pixel,imageAttributes);

   //清除已经采取的色彩变换
   imageAttributes.ClearColorMatrix(ColorAdjustType.Bitmap);

   //设置蓝色通道
   float[][] colorMatrixElements3=
  {
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 1.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 1.0f}
  };
   ColorMatrix colorMatrix3 =new ColorMatrix(colorMatrixElements3);

   //启用色彩变换矩阵
   imageAttributes.SetColorMatrix(
    colorMatrix3, 
    ColorMatrixFlag.Default,
    ColorAdjustType.Bitmap);

   //使用色彩变换矩阵输出图片
   graphics.TranslateTransform(width+10,0);
   graphics.DrawImage(image, new Rectangle(0, 0, width, height),
    0, 0,width, height,GraphicsUnit.Pixel,imageAttributes);
  }

  private void Metafile_Click(object sender, System.EventArgs e)
  {
   Graphics metagraph=this.CreateGraphics();

   //新建一个图元文件
   IntPtr hdc =metagraph.GetHdc();
   Metafile metaFile1 = new Metafile("图元文件示例.emf", hdc);
   //使用Metafile对象的地址做为绘图平面
   Graphics graphics=Graphics.FromImage(metaFile1);

   //定义一个由红到蓝的渐变色画刷
   LinearGradientBrush RtoBBrush=new LinearGradientBrush(
    new Point(0, 10),
    new Point(200, 10),
    Color.Red,   
    Color.Blue);

   //定义一个由蓝到黄的渐变色画刷
   LinearGradientBrush BtoYBrush=new LinearGradientBrush(
    new Point(0, 10),
    new Point(200, 10),
    Color.Blue,   
    Color.Yellow);
   Pen bluePen=new Pen(Color.Blue);
   // 以下的操作是往屏幕上绘制一八卦图形
   Rectangle ellipseRect=new Rectangle(0, 0, 200, 200);
   Rectangle left=new Rectangle(0, 50, 100, 100);
   graphics.DrawArc(bluePen,left,180.0f,180.0f);
   Rectangle right=new Rectangle(100, 50, 100, 100);
   graphics.FillPie(RtoBBrush, ellipseRect,0.0f,180.0f);
   graphics.FillPie(BtoYBrush, ellipseRect,180.0f,180.0f);
   graphics.FillPie(RtoBBrush, left,180.0f,180.0f);
   graphics.FillPie(BtoYBrush, right,0.0f,180.0f);

   //文本输出 
   SolidBrush solidBrush=new SolidBrush(Color.Black);
   FontFamily fontFamily=new FontFamily("隶书");
   Font font=new Font(fontFamily, 27,
    FontStyle.Regular, GraphicsUnit.Pixel);
   graphics.DrawString("图元文件示例", font, solidBrush,
    new PointF(20.0f, 80.0f));
   //到此,GDI+进行的只是往硬盘中存放图片信息的操作

   //释放所有资源。
   graphics.Dispose();
   metaFile1.Dispose();
   metagraph.ReleaseHdc(hdc);
   metagraph.Dispose();

   //将上面的绘图信息进行回放
   Graphics playbackGraphics=this.CreateGraphics();
   playbackGraphics.Clear(Color.White);
   //打开并显示图元文件
   Metafile metaFile2 = new Metafile("图元文件示例.emf");
   playbackGraphics.DrawImage(metaFile2,new Point(0,0));
   //关闭已经打开的图元文件
   metaFile2.Dispose();
  }

  private void CroppingAndScaling_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //加载图片
   Bitmap image=new Bitmap("nemo.bmp");
   int width = image.Width;
   int height = image.Height;

   // 目标显示区域在源图大小的基础上放大1.4倍
   RectangleF destinationRect=new RectangleF(
    width+10, 0.0f, 1.4f* width, 1.4f* height);
   //绘制源图
   graphics.DrawImage(image, 0, 0);
 
   //在目标区域内输出位图
   graphics.DrawImage(
    image,
    destinationRect,
    new RectangleF(0, 0,    // 原图左上角
    0.65f*width,      // 仅显示原图宽度的65%部分
    0.65f*height),      // 仅显示原图高度的65%部分
    GraphicsUnit.Pixel);
  }

  private void UsingInterpolationMode_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //装入图片
   Bitmap image=new Bitmap("eagle.bmp");
   int width = image.Width;
   int height = image.Height;

   //绘制源图
   graphics.DrawImage(
    image,
    new Rectangle(0, 0, width, height),  //目标区域 
    0, 0,        //源图左上角坐标
    width,       //源图宽度
    height,      //源图高
    GraphicsUnit.Pixel);

   //绘图平面右移
   graphics.TranslateTransform( width+10,0);
   //最临近插值法(低质量)
   graphics.InterpolationMode=InterpolationMode.NearestNeighbor;
   graphics.DrawImage(
    image,
    new RectangleF(0.0f, 0.0f, 0.6f*width, 0.6f*height),  //目标区域
    new RectangleF(0, 0,        //源图左上角坐标
    width,       //源图宽度
    height),      //源图高
    GraphicsUnit.Pixel);

   //绘图平面右移
   graphics.TranslateTransform( 0.6f*width+10,0);
   // 高质量双线性插值法
   graphics.InterpolationMode=InterpolationMode.HighQualityBilinear;
   graphics.DrawImage(
    image,
    new RectangleF(0, 0, 0.6f * width, 0.6f * height),  //目标区域
    new Rectangle(0, 0,        //源图左上角坐标
    width,       //源图宽度
    height),      //源图高
    GraphicsUnit.Pixel);

   //绘图平面右移
   graphics.TranslateTransform(0.6f*width+10,0f);
   // 高质量双三次插值法
   graphics.InterpolationMode=InterpolationMode.HighQualityBicubic;
   graphics.DrawImage(
    image,
    new RectangleF(0, 0, 0.6f * width, 0.6f * height),  //目标区域
    new Rectangle(0, 0,        //源图左上角坐标
    width,       //源图宽度
    height),      //源图高
    GraphicsUnit.Pixel);
  }

  private void RotateFlip_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);
   //加载图片 
   Bitmap photo=new Bitmap("nemo2.bmp");

   //得到图片尺寸
   int iWidth = photo.Width;
   int iHeight = photo.Height;
   //绘制原始图片
   graphics.DrawImage(photo, 10+photo.Width+2,
    10, photo.Width, photo.Height);
   //水平翻转图片 
   photo.RotateFlip(RotateFlipType.RotateNoneFlipX);  
   //旋转后的图片
   graphics.DrawImage( photo, 10, 10, photo.Width, photo.Height);  
  }

  private void ImageSkewing_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //定义图形的目标显示区域
   Point[] destination=new Point[]
  {
   new Point(200, 20),   //原始图像左上角映射后的坐标
   new Point(110, 100), //原始图像右上角映射后的坐标
   new Point(250, 30)  //原始图像左下角映射后的坐标
  };
   Bitmap image=new Bitmap("Stripes.bmp");
   // 绘制原始图像
   graphics.DrawImage(image, 0, 0);
 
   // 绘制基于平行四边形映射后的图像
   graphics.TranslateTransform(image.Width,0);
   graphics.DrawImage(image, destination); 

  }


  private void Cubeimage_Click(object sender, System.EventArgs e)
  {
   int WIDTH=200;
   int LEFT=200;
   int TOP=200;

   Graphics graphics=this.CreateGraphics();
   //使用黑色做背景色清屏
   graphics.Clear(Color.Black);

   //设置插值模式:高质量双三次插值法
   graphics.InterpolationMode=InterpolationMode.HighQualityBicubic;

   //分别装入张贴在立方体三面的图片
   Bitmap face=new Bitmap("rose.bmp");
   Bitmap top=new Bitmap("flower.bmp");
   Bitmap right=new Bitmap("yujinxiang.bmp");

   //重新定义用于张贴在正面的图片坐标
   Point[] destinationFace = new Point[]
  {
   new Point(LEFT,TOP), 
   new Point(LEFT+WIDTH, TOP),
   new Point(LEFT, TOP+WIDTH)
  };  
   //张贴正面图像
   graphics.DrawImage(face,destinationFace); 

   //重新定义用于张贴在顶部的图片坐标 
   PointF[] destinationTop= new PointF[]
  {
   new PointF(LEFT+WIDTH/2, TOP-WIDTH/2),
   new PointF(LEFT+WIDTH/2+WIDTH, TOP-WIDTH/2), 
   new PointF(LEFT, TOP)
  };  
   //张贴顶部面图像  
   graphics.DrawImage(top, destinationTop); 

   //重新定义用于张贴在右侧的图片坐标    
   Point[] destinationRight= new Point[]
  {
   new Point(LEFT+WIDTH, TOP),
   new Point(LEFT+WIDTH/2+WIDTH, TOP-WIDTH/2), 
   new Point(LEFT+WIDTH,TOP+WIDTH)
  };
   //张贴右侧面图像      
   graphics.DrawImage(right, destinationRight);
  }

  public bool ThumbnailCallback()
  {
   return false;
  }

  private void ThumbnailImage_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);
 
   //设置插值模式:高质量双三次插值法
   graphics.InterpolationMode=InterpolationMode.HighQualityBicubic;

   //加载欲查看缩略图的图片
   Bitmap image=new Bitmap("flower.bmp");
   //获取当前窗口大小
   Rectangle client=new Rectangle(0,0,
    this.ClientSize.Width,this.ClientSize.Height);
 
   float width=image.Width;
   float height=image.Height;
 
   //获取指定大小的缩略图
   Image.GetThumbnailImageAbort myCallback =
    new Image.GetThumbnailImageAbort(ThumbnailCallback);
   Image pThumbnail = image.GetThumbnailImage(40,40,  myCallback ,IntPtr.Zero);

   //将缩略图作为画刷
   TextureBrush  picBrush=new TextureBrush(pThumbnail);
   //填充窗口
   graphics.FillEllipse(picBrush,client);
  }

  private void Clone_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Bitmap image=new Bitmap("head.bmp");
   int Height=image.Height;
   int Width=image.Width;

   //定义将图片切分成四个部分的区域
   RectangleF[] block=new RectangleF[4];
   block[0]=new Rectangle(0,0,Width/2,Height/2);
   block[1]=new Rectangle(Width/2,0,Width/2,Height/2);
   block[2]=new Rectangle(0,Height/2,Width/2,Height/2);
   block[3]=new Rectangle(Width/2,Height/2,Width/2,Height/2);

   //分别克隆图片的四个部分 
   Bitmap[] s=new Bitmap[4];
   s[0]=image.Clone(block[0],PixelFormat.DontCare);
   s[1]=image.Clone(block[1],PixelFormat.DontCare);
   s[2]=image.Clone(block[2],PixelFormat.DontCare);
   s[3]=image.Clone(block[3],PixelFormat.DontCare);
   //绘制图片的四个部分,各部分绘制时间间隔为1秒
   graphics.DrawImage(s[0],0,0);

   //延时,以达到分块显示的效果
   Thread.Sleep(1000);
   graphics.DrawImage(s[1],Width/2,0);
   Thread.Sleep(1000);
   graphics.DrawImage(s[3],Width/2,Height/2);
   Thread.Sleep(1000);
   graphics.DrawImage(s[2],0,Height/2);
  }

  private void Picturescale_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //装入图片
   Bitmap image=new Bitmap("photo.bmp");
 
   //定义图片的显示区域
   Rectangle rect=new Rectangle(0,0,image.Width,image.Height);
   graphics.DrawImage(image,rect);
 
   //局部缩小的区域大小为80*80
   graphics.TranslateTransform(image.Width+10,0);
   Rectangle smallrect=new Rectangle(0,0,80,80);
   //局部缩小
   graphics.DrawImage(image,smallrect,80,10,106,112,GraphicsUnit.Pixel);

   graphics.TranslateTransform(0,100);
   //局部放大的区域大小为80*80
   Rectangle largerect=new Rectangle(0,0,80,80);
   //绘制放大后的局部图像
   graphics.DrawImage(image,largerect,56,101,35,40,GraphicsUnit.Pixel);
  }

  private void ImageAttributesSetNoOp_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Bitmap image=new Bitmap("ColorTable.bmp");
   int width=image.Width;
   //绘制标准图片  
   graphics.DrawImage(image,0,0);

   graphics.TranslateTransform(image.Width+10,0);
   ImageAttributes imAtt=new ImageAttributes();

   //构造一个红色转换到绿色的变换矩阵   


   float[][] colorMatrixElements=
  {     
   new float[]{0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 1.0f, 0.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
   new float[]{0.0f, 0.0f, 0.0f, 0.0f, 1.0f}
  };
   ColorMatrix brushMatrix=new ColorMatrix(colorMatrixElements);
   //设置色彩校正
   imAtt.SetColorMatrix(
    brushMatrix, 
    ColorMatrixFlag.Default, 
    ColorAdjustType.Bitmap);

   //使用色彩校正绘制图片
   graphics.DrawImage(
    image,
    new Rectangle(0, 0, image.Width, image.Height),  //目标位置
    0, 0, image.Width, image.Height,        //源位置
    GraphicsUnit.Pixel,
    imAtt);

   //临时关闭色彩校正
   imAtt.SetNoOp(ColorAdjustType.Bitmap);

   //不使用色彩校正绘制图片红色->红色
   graphics.TranslateTransform(width+10,0);
   graphics.DrawImage(
    image,
    new Rectangle(0, 0, image.Width, image.Height),  //目标位置
    0, 0, image.Width, image.Height,          //源位置
    GraphicsUnit.Pixel,
    imAtt);

   //撤消对色彩校正的关闭
   imAtt.ClearNoOp(ColorAdjustType.Bitmap);

   //使用色彩校正绘制图片:红色->绿色
   graphics.TranslateTransform(width+10,0);
   graphics.DrawImage(
    image,
    new Rectangle(0, 0, image.Width, image.Height),  //目标位置
    0, 0, image.Width, image.Height,          //源位置
    GraphicsUnit.Pixel,
    imAtt);
  }


  private void CreateMetaFile()
  {
   Graphics metagraph=this.CreateGraphics();

   //新建一个图元文件
   IntPtr hdc =metagraph.GetHdc();
   Metafile metaFile1 = new Metafile("ddd.emf", hdc);
   //使用Metafile对象的地址做为绘图平面
   Graphics graphics=Graphics.FromImage(metaFile1);
   graphics.ScaleTransform(0.8f,0.8f);

   //在沿水平方向输出三个椭圆并填充
   graphics.SmoothingMode=SmoothingMode.HighQuality;
   //红色椭圆
   graphics.DrawEllipse(new Pen(Color.Red,10),
    new Rectangle(0, 0, 75, 95));
   graphics.FillEllipse(Brushes.Red,
    new Rectangle(0, 0, 75, 95));

   //绿色椭圆
   graphics.DrawEllipse(new Pen(Color.Green,10),
    new Rectangle(40, 0, 75, 95));
   graphics.FillEllipse(Brushes.Green,
    new Rectangle(40, 0, 75, 95));

   //蓝色椭圆
   graphics.DrawEllipse(new Pen(Color.Blue,10),
    new Rectangle(80, 0, 75, 95));
   graphics.FillEllipse(Brushes.Blue, new Rectangle(80, 0, 75, 95));

   // 追加三种色彩的文本
   FontFamily fontFamily=new FontFamily("Arial");
   Font font=new Font(fontFamily,
    24, FontStyle.Regular, GraphicsUnit.Pixel);
   graphics.TextRenderingHint=TextRenderingHint.AntiAlias;

   //红色文字
   graphics.DrawString("GDI+",font, Brushes.Red,
    new PointF(-80.0f, 0.0f));
   //绿色文字
   graphics.DrawString("GDI+",font,Brushes.Green,
    new PointF(-80.0f, font.Height));
   //蓝色文字
   graphics.DrawString("GDI+",font, Brushes.Blue,
    new PointF(-80.0f, font.Height*2));
   //释放所有资源。
   graphics.Dispose();
   metaFile1.Dispose();
   metagraph.ReleaseHdc(hdc);
   metagraph.Dispose();
  }

  private void SetColorMatrices_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //加载图元文件 
   Metafile image=new Metafile("ddd.emf");
   GraphicsUnit  unit=GraphicsUnit.Pixel;
   //获取图片区间
   RectangleF   rect=image.GetBounds(ref unit);
 
   //不使用任何色彩校正输出图片
   graphics.DrawImage(image, 0.0f, 0.0f, rect.Width, rect.Height);
   ImageAttributes  imAtt=new ImageAttributes();
 
   //定义一个使红色分量递增1.5的矩阵
   float[][] colorMatrixElements=
  { 
   new float[]{1.5f,  0.0f,  0.0f,  0.0f,  0.0f},
   new float[]{0.0f,  1.0f,  0.0f,  0.0f,  0.0f},
   new float[]{0.0f,  0.0f,  1.0f,  0.0f,  0.0f},
   new float[]{0.0f,  0.0f,  0.0f,  1.0f,  0.0f},
   new float[]{0.0f,  0.0f,  0.0f,  0.0f,  1.0f}
  };
   ColorMatrix defaultColorMatrix=new ColorMatrix(colorMatrixElements);
 
   //定义一个使绿色分量递增1.5的矩阵
   float[][] colorMatrixElements2=
  {  
   new float[]{1.0f,  0.0f,  0.0f,  0.0f,  0.0f},
   new float[]{0.0f,  1.5f,  0.0f,  0.0f,  0.0f},
   new float[]{0.0f,  0.0f,  1.0f,  0.0f,  0.0f},
   new float[]{0.0f,  0.0f,  0.0f,  1.0f,  0.0f},
   new float[]{0.0f,  0.0f,  0.0f,  0.0f,  1.0f}
  };
   ColorMatrix defaultGrayMatrix=new ColorMatrix(colorMatrixElements2);
 
   //画笔的彩色色彩信息较校正矩阵:蓝色分量递增1.5的矩阵
   float[][] colorMatrixElements3= 
  {  
   new float[]{1.0f,  0.0f,  0.0f,  0.0f,  0.0f},
   new float[]{0.0f,  1.0f,  0.0f,  0.0f,  0.0f},
   new float[]{0.0f,  0.0f,  1.5f,  0.0f,  0.0f},
   new float[]{0.0f,  0.0f,  0.0f,  1.0f,  0.0f},
   new float[]{0.0f,  0.0f,  0.0f,  0.0f,  1.0f}
  };
   ColorMatrix penColorMatrix=new ColorMatrix(colorMatrixElements3);

   //画笔的灰度色矩阵:所有分量递增1.5的矩阵
   float[][] colorMatrixElements4=
 {      
  new float[]{1.5f,  0.0f,  0.0f,  0.0f,  0.0f},
  new float[]{0.0f,  1.5f,  0.0f,  0.0f,  0.0f},
  new float[]{0.0f,  0.0f,  1.5f,  0.0f,  0.0f},
  new float[]{0.0f,  0.0f,  0.0f,  1.0f,  0.0f},
  new float[]{0.0f,  0.0f,  0.0f,  0.0f,  1.0f}
 };

   ColorMatrix penGrayMatrix =new ColorMatrix(colorMatrixElements4);
 
   // 设置默认的彩色及灰度校正矩阵.
   //ColorAdjustType.Default:修改所有的色彩信息
   imAtt.SetColorMatrices(
    defaultColorMatrix,
    defaultGrayMatrix, 
    ColorMatrixFlag.AltGrays,
    ColorAdjustType.Default);
   //使用校正矩阵绘制图元文件:校正所有的色彩
   graphics.TranslateTransform(image.Width+10,0);
   graphics.DrawImage(
    image, 
    new Rectangle(0, 0, (int)rect.Width,(int)rect.Height),  
    rect.X, rect.Y,               
    rect.Width,                   
    rect.Height,                   
    GraphicsUnit.Pixel,
    imAtt);

   //设置画笔的彩色及灰度色彩校正矩阵
   //ColorAdjustType.Pen:修正画笔色彩
   imAtt.SetColorMatrices(
    penColorMatrix,
    penGrayMatrix, 
    ColorMatrixFlag.AltGrays,
    ColorAdjustType.Pen); 
   //在第二行绘制
   graphics.ResetTransform();
   graphics.TranslateTransform(0,image.Height);
   //使用修正后的画笔绘制图片 
   graphics.DrawImage(
    image, 
    new Rectangle(0, 0, (int)rect.Width,(int)rect.Height),  
    rect.X, rect.Y,               
    rect.Width,                   
    rect.Height,                   
    GraphicsUnit.Pixel,
    imAtt);

   graphics.TranslateTransform(image.Width+10,0);
   //清除在画笔上的所有变换
   imAtt.ClearColorMatrix(ColorAdjustType.Pen);
   graphics.DrawImage(
    image, 
    new Rectangle(0, 0, (int)rect.Width,(int)rect.Height),  
    rect.X, rect.Y,               
    rect.Width,                   
    rect.Height,                   
    GraphicsUnit.Pixel,
    imAtt); 
  }

  private void SetOutputChannelColorProfile_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Bitmap image=new Bitmap("car.bmp");
   ImageAttributes imAtt=new ImageAttributes();
   int width = image.Width;
   int height = image.Height;
   Rectangle rect=new Rectangle(0, 0, width, height);
   //绘制原始图片
   graphics.DrawImage(image, rect);

   graphics.TranslateTransform(width,0);
   //设置色彩配置文件
   imAtt.SetOutputChannelColorProfile(
    "kodak_dc.ICM", ColorAdjustType.Bitmap);

   //使用色彩配置文件输出图片
   graphics.DrawImage(
    image,
    rect,  
    0, 0, width, height,          
    GraphicsUnit.Pixel,
    imAtt);
  }

  private void Gammaadjust_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);
 
   //装入原始图片
   Bitmap image=new Bitmap("warrior.bmp");
   int width = image.Width;
   int height = image.Height;

   // 设置字体信息
   Font myFont=new Font("宋体", 12);
   //设置提示信息的显示区域
   PointF origin=new PointF(width+10, height+20);
   SolidBrush blackBrush=new SolidBrush(Color.Black);

   ImageAttributes imAtt=new ImageAttributes();   
   string msg=string.Empty;
   //从0-3依次调整输出图片时所使用的Gamma值
   for(float i=0.0f;i<3.0f;i+=0.1f)
   { 
    //绘制原始图片
    graphics.DrawImage(image,0,0);
  
    //设置Gamma值
    imAtt.SetGamma(i,ColorAdjustType.Bitmap);
    //使用修改后Gamma值进行图片输出
    graphics.DrawImage(
     image,
     new Rectangle(width+10, 0, width, height),  //目标区域
     0, 0, width, height,           //源区域
     GraphicsUnit.Pixel,
     imAtt);
    msg=string.Format("正在修改Gamma值,Gamma={0:F2}",i);
    //显示当前的Gamma值信息
    graphics.DrawString(msg,myFont,blackBrush,origin);
    //延时一秒以便观看效果
    Thread.Sleep(100);
    graphics.Clear(Color.White);
    imAtt.ClearGamma();
   }

  }

  private void SetOutputChannel_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   //装入图片
   Bitmap image=new Bitmap("jieba.bmp");
   //图片的高度
   int width = image.Width;
   int height = image.Height;

   //绘制原始图片
   graphics.DrawImage(image, new RectangleF(0, 0, width, height));
   ImageAttributes imAtt=new ImageAttributes();
   //设置色彩输出通道cyan
   imAtt.SetOutputChannel(ColorChannelFlag.ColorChannelC,
    ColorAdjustType.Bitmap);
   //右移,绘制图片
   graphics.TranslateTransform(width, 0);
   graphics.DrawImage(
    image,
    new Rectangle(0, 0, width, height),  
    0, 0, width, height,           
    GraphicsUnit.Pixel,
    imAtt);

   //设置色彩输出通道:magenta 
   imAtt.SetOutputChannel(ColorChannelFlag.ColorChannelM, 
    ColorAdjustType.Bitmap);
   //右移,绘制图片
   graphics.TranslateTransform(width, 0);
   graphics.DrawImage(
    image,
    new Rectangle(0, 0, width, height),
    0, 0, width, height,           
    GraphicsUnit.Pixel,
    imAtt);

   //设置色彩输出通道:yellow
   imAtt.SetOutputChannel(ColorChannelFlag.ColorChannelY, 
    ColorAdjustType.Bitmap);
   //右移,绘制图片
   graphics.TranslateTransform(width, 0);
   graphics.DrawImage(
    image,
    new Rectangle(0, 0, width, height),
    0, 0, width, height,           
    GraphicsUnit.Pixel,
    imAtt);

   //设置色彩输出通道:black
   imAtt.SetOutputChannel(ColorChannelFlag.ColorChannelK, 
    ColorAdjustType.Bitmap);
   //右移,绘制图片
   graphics.TranslateTransform(width, 0);
   graphics.DrawImage(
    image,
    new Rectangle(0, 0, width, height),
    0, 0, width, height,            
    GraphicsUnit.Pixel,
    imAtt); 

  }

  private void Colorkey_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);
 
   //装入前后背景图片
   Bitmap forground=new Bitmap("grid.bmp");
   Bitmap background=new Bitmap("snike.bmp");

   int width=background.Width;
   int height=background.Height;
   Rectangle rect=new Rectangle(0,0,width,height);

   //将红色设置成关键色
   ImageAttributes imAtt=new ImageAttributes();
   imAtt.SetColorKey(
    Color.Red,
    Color.Red,
    ColorAdjustType.Bitmap);

   //绘制背景
   graphics.DrawImage(background,0,0); 
   //绘制前景
   graphics.DrawImage(
    forground, 
    rect,
    0, 0, forground.Width, forground.Height,        
    GraphicsUnit.Pixel,
    imAtt);
 
   graphics.TranslateTransform(width+20,0);
   graphics.DrawImage(background,0,0); 
   //清除已经应用的关键色信息
   imAtt.ClearColorKey(ColorAdjustType.Bitmap);   
   ///将蓝色设置成关键色
   imAtt.SetColorKey(
    Color.Blue,
    Color.Blue,
    ColorAdjustType.Bitmap);
   graphics.DrawImage(forground, 
    rect,
    0, 0, forground.Width, forground.Height,        
    GraphicsUnit.Pixel,
    imAtt);
   graphics.TranslateTransform(width+20,0);

   //绘制源图
   graphics.DrawImage(background,0,0); 
  }

  private void Setthreshold_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);

   Bitmap image=new Bitmap("box-2.bmp");
   int Width=image.Width;
   int Height=image.Height;
   //绘制原始图片
   graphics.DrawImage(image, 10, 10, Width, Height);

   //将阈值从0到1依次运用
   ImageAttributes imAtt=new ImageAttributes();
   for(float i=0.0f;i<1.0f;i+=0.1f)
   {
    //设置输出图片时使用的阈值
    imAtt.SetThreshold(i, ColorAdjustType.Bitmap);
    //绘制已经使用了阈值的图片
    graphics.DrawImage(image,
     new Rectangle(10+Width, 10, Width, Height),  
     0, 0, Width, Height, 
     GraphicsUnit.Pixel,
     imAtt);
    //延时
    Thread.Sleep(1000);
   }
  }

  private void AdjustedPalette_Click(object sender, System.EventArgs e)
  {
   Graphics graphics=this.CreateGraphics();
   graphics.Clear(Color.White);
   graphics.ScaleTransform(0.7f,0.7f);
 
   //加载图片
   Bitmap image=new Bitmap("lord-256.bmp");
   //复制图片
   Bitmap image2=(Bitmap)image.Clone();
   //获取图片使用的调色板信息
   ColorPalette palette=image.Palette;
    
   //获取调色板所包含的色彩总数
   int count=palette.Entries.Length;
   if(count<1)
   {
    MessageBox.Show("图片无调色板信息可用");
    return;
   } 
 
   //更改调色板中的每一种色彩信息  
   for(int i=0;i
    
    
     
     < 0); SolidBrush(Color.Black); graphics.ResetTransform(); graphics.DrawImage(image, ImageAttributes(); ImageAttributes 加载图片 byte[] RectangleF fontFamily="new" FontFamily msg="string.Empty;" PointF(0,0)); graphics.DrawString msg+='string.Format("编码器名称:{0}/t文件格式扩展名:{1}/t/n",' string ; GraphicsUnit.Pixel); FontStyle.Regular, Font(fontFamily, FontFamily(?华文楷体?); SolidBrush(Color.Blue); graphics.DrawImage(image,rect); rect="new" Rectangle Bitmap(?jieba.bmp?); 2, 2); [] 16, return; (msg, this.ClientSize.Width,this.ClientSize.Height); Rectangle(0,0, FontFamily(?宋体?); tmp="string.Empty;" 0) graphics.TranslateTransform(rect.Width,0); 绘图平面右移 ++j) count; count="pEncoderParameters.Param.GetLength(0);" 3); brush, myFont, if(avg avg="(color.R+color.G+color.B)/3;" avg; 根据该点RGB的平均值来确认该点的”明暗” tmp; color; colorTemp,color2; Bitmap(?box-2.bmp?); OnWood_Click(object 动态绘制滤镜效果图 color); 将该点的RGB值设置成附近五点之内的任一点 j+a); a="rand.Next(1000)%5;" j
     
     
      
      =128)
    tmp=255;
   else
    tmp=0;
   colorTemp=Color.FromArgb(255,tmp,tmp,tmp);
   //将计算后的RGB值回写到位图
   image.SetPixel(i, j, colorTemp);
  }
  //动态绘制滤镜效果图
  graphics.DrawImage(
   image, new Rectangle(Width, 0, Width, Height));
 }

}
  //计算两点A、B之间的绝对距离
  float fDistance(Point A,Point B)
  {
   double i=Math.Pow((A.X-B.X),2)+Math.Pow((A.Y-B.Y),2);
   return (float)Math.Sqrt(i);
  }

private void Flashligt_Click(object sender, System.EventArgs e)
{
 Graphics graphics=this.CreateGraphics();
 graphics.Clear(Color.White);
 
 Bitmap image=new Bitmap("sports.bmp");
 int Width = image.Width;
 int Height = image.Height;
 int A=Width/2;
 int B=Height/2;
 //Center:图片中心点,发亮此值会让强光中心发生偏移
 Point Center=new Point(A,B);
 //R:强光照射面的半径,即”光晕”
 int R=100;
 Color colorTemp,color2;
 Color color;
 graphics.DrawImage(
  image, new Rectangle(0, 0, Width, Height));
 //依次访问每个像素
 for(int x=0;x
      
      
        < y); y, Point image2, colorLeft="image2.GetPixel(i-1," float tmp="new" graphics.ScaleTransform(0.8f,0.8f); i++) 动态绘制滤镜效果图 Bitmap(?snike.bmp?); pre this.label1.Text="DateTime.Now.ToString();" EventArgs timer1_Tick(object this.timer1.Enabled="true;" Form1_Load(object colorTemp); image2.SetPixel(i, 将计算后的RGB值回写到位图 colorTemp="Color.FromArgb(255,(int)r,(int)g,(int)b);" -colorLeft.B*dep); -colorLeft.G*dep); -colorLeft.R*dep); j-1); colornow="image2.GetPixel(i," j++) dep="0.550f;" 常量dep:锐化系数,此值越大,锐化效果越明显 colorLeft,colornow; 进行锐化处理 绘制经过平滑处理的效果图 j,colorTemp); 9)); 9),(int)(bSum 9),(int)(gSum (int)(rSum 用RGB的平均值做为当前点的RGB值 bSum+="color[n,nn].B;" gSum+="color[n,nn].G;" rSum+="color[n,nn].R;" nn="0;nn<3;nn++)" n="0;n<3;n++)" 分别求出周围9个点的R、G、B之和 bSum="0;" gSum="0;" rSum="0;" j+1); color[2,2]="image.GetPixel(i+1," color[2,1]="image.GetPixel(i+1," color[2,0]="image.GetPixel(i+1," color[1,2]="image.GetPixel(i," color[1,1]="image.GetPixel(i," color[1,0]="image.GetPixel(i," color[0,2]="image.GetPixel(i-1," color[0,1]="image.GetPixel(i-1," color[0,0]="image.GetPixel(i-1," 访问周围9个点的RGB值 j 
        
      
     
     
    
    
   
   
  
  
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值