一、颜色表示方式

        //
// Summary:
// Creates a System.Drawing.Color structure from a 32-bit ARGB value.
//
// Parameters:
// argb:
// A value specifying the 32-bit ARGB value.
//
// Returns:
// The System.Drawing.Color structure that this method creates.
public static Color FromArgb(int argb);argb-such as 0xff0000ff, the first "ff" is the alpha value, and then R,G,B. if the alpha is "" the color turn to be transparent //
// Summary:
// Creates a System.Drawing.Color structure from the specified System.Drawing.Color
// structure, but with the new specified alpha value. Although this method allows
// a 32-bit value to be passed for the alpha value, the value is limited to
// 8 bits.
//
// Parameters:
// alpha:
// The alpha value for the new System.Drawing.Color. Valid values are 0 through
// 255.
//
// baseColor:
// The System.Drawing.Color from which to create the new System.Drawing.Color.
//
// Returns:
// The System.Drawing.Color that this method creates.
//
// Exceptions:
// System.ArgumentException:
// alpha is less than 0 or greater than 255.
public static Color FromArgb(int alpha, Color baseColor);
//
// Summary:
// Creates a System.Drawing.Color structure from the specified 8-bit color values
// (red, green, and blue). The alpha value is implicitly 255 (fully opaque).
// Although this method allows a 32-bit value to be passed for each color component,
// the value of each component is limited to 8 bits.
//
// Parameters:
// red:
// The red component value for the new System.Drawing.Color. Valid values are
// 0 through 255.
//
// green:
// The green component value for the new System.Drawing.Color. Valid values
// are 0 through 255.
//
// blue:
// The blue component value for the new System.Drawing.Color. Valid values are
// 0 through 255.
//
// Returns:
// The System.Drawing.Color that this method creates.
//
// Exceptions:
// System.ArgumentException:
// red, green, or blue is less than 0 or greater than 255.
public static Color FromArgb(int red, int green, int blue);
//
// Summary:
// Creates a System.Drawing.Color structure from the four ARGB component (alpha,
// red, green, and blue) values. Although this method allows a 32-bit value
// to be passed for each component, the value of each component is limited to
// 8 bits.
//
// Parameters:
// alpha:
// The alpha component. Valid values are 0 through 255.
//
// red:
// The red component. Valid values are 0 through 255.
//
// green:
// The green component. Valid values are 0 through 255.
//
// blue:
// The blue component. Valid values are 0 through 255.
//
// Returns:
// The System.Drawing.Color that this method creates.
//
// Exceptions:
// System.ArgumentException:
// alpha, red, green, or blue is less than 0 or greater than 255.
public static Color FromArgb(int alpha, int red, int green, int blue); 二、颜色操作 、String转换成Color
Color color = (Color)ColorConverter.ConvertFromString(string); 、String转换成Brush BrushConverter brushConverter = new BrushConverter();
Brush brush = (Brush)brushConverter.ConvertFromString(string); 、Color转换成Brush Brush brush = new SolidColorBrush(color)); 、Brush转换成Color有两种方法: ()先将Brush转成string,再转成Color。 Color color= (Color)ColorConverter.ConvertFromString(brush.ToString()); ()将Brush转成SolidColorBrush,再取Color。 Color color= ((SolidColorBrush)CadColor.Background).Color; 三、Brush // (实心刷)
Rectangle rect1 = new Rectangle(, , , );
SolidBrush sbrush1 = new SolidBrush(Color.DarkOrchid);
SolidBrush sbrush2 = new SolidBrush(Color.Aquamarine);
SolidBrush sbrush3 = new SolidBrush(Color.DarkOrange);          //(梯度刷)
LinearGradientBrush lbrush1 = new LinearGradientBrush(rect1,
Color.DarkOrange, Color.Aquamarine,
LinearGradientMode.BackwardDiagonal); //(阴影刷)
HatchBrush hbrush1 = new HatchBrush(HatchStyle.DiagonalCross,
Color.DarkOrange, Color.Aquamarine);
HatchBrush hbrush2 = new HatchBrush(HatchStyle.DarkVertical,
Color.DarkOrange, Color.Aquamarine);
HatchBrush hbrush3 = new HatchBrush(HatchStyle.LargeConfetti,
Color.DarkOrange, Color.Aquamarine); //(纹理刷)
textureBrush = new TextureBrush(new Bitmap(@"e:\123.jpg"));
//e.Graphics.FillRectangle(hbrush1, rect1);
//e.Graphics.FillRectangle(sbrush1, rect1);
//e.Graphics.FillRectangle(textureBrush, rect1);
e.Graphics.FillRectangle(lbrush1, rect1);

转自:http://huangdingjun.blog.163.com/blog/static/3110639201011223130486/

C#的颜色解析及操作和相关Brush的更多相关文章

  1. python 全栈开发,Day52(关于DOM操作的相关案例,JS中的面向对象,定时器,BOM,client、offset、scroll系列)

    昨日作业讲解: 京东购物车 京东购物车效果: 实现原理: 用2个盒子,就可以完整效果. 先让上面的小盒子向下移动1px,此时就出现了压盖效果.小盒子设置z-index压盖大盒子,将小盒子的下边框去掉, ...

  2. 前端JavaScript(3)-关于DOM操作的相关案例,JS中的面向对象、定时器、BOM、位置信息

    小例子: 京东购物车 京东购物车效果: 实现原理: 用2个盒子,就可以完整效果. 先让上面的小盒子向下移动1px,此时就出现了压盖效果.小盒子设置z-index压盖大盒子,将小盒子的下边框去掉,就可以 ...

  3. JavaScript对SVG进行操作的相关技术

    原文地址:http://www.ibm.com/developerworks/cn/xml/x-svgscript/   本文主要介绍在 SVG 中通过编程实现动态操作 SVG 图像的知识. SVG ...

  4. 『学了就忘』Linux基础命令 — 19、目录操作的相关命令

    目录 1.ls命令 2.cd命令 (1)绝对路径和相对路径 (2)cd命令的简化用法 3.pwd命令 4.mkdir命令 5.rmdir命令 常用目录操作的相关命令: ls命令 cd命令 pwd命令 ...

  5. scrapy架构与目录介绍、scrapy解析数据、配置相关、全站爬取cnblogs数据、存储数据、爬虫中间件、加代理、加header、集成selenium

    今日内容概要 scrapy架构和目录介绍 scrapy解析数据 setting中相关配置 全站爬取cnblgos文章 存储数据 爬虫中间件和下载中间件 加代理,加header,集成selenium 内 ...

  6. 通过pull解析器操作安卓的xml

    通过pull解析器操作安卓的xml 例子定义了一个javabean用于存放上面解析出来的xml内容, 这个javabean为Person,代码请见本页下面备注: =================== ...

  7. Selenium2Lib库之操作浏览器相关的关键字实战

    1.1  操作浏览器相关的关键字 Selenium2Lib提供了与浏览器交互的关键词 1.1.1 Open Browser关键字 按F5 查看Open Browser关键字的说明,如下图: Open ...

  8. 前端 ----关于DOM的操作的相关实例

    关于DOM操作的相关案例   1.模态框案例 需求: 打开网页时有一个普通的按钮,点击当前按钮显示一个背景图,中心并弹出一个弹出框,点击X的时候会关闭当前的模态框 代码如下: <!DOCTYPE ...

  9. Ubuntu软件操作的相关命令

    Ubuntu软件操作的相关命令 sudo apt-get update ------------------------------- 更新源 sudo apt-get install package ...

随机推荐

  1. Mybatis单个参数的if判断(针对异常:There is no getter for property..)------mybatis的内置对象

    这里有一个删除方法: int deleteByPrimaryKey(Integer id); 然后对应的sql的xml如下: <delete id="deleteByPrimaryKe ...

  2. Qt5.3.2_vs10_发布时所需DLL的路径

    1. ???\Qt5.3.2_vs2010\5.3\msvc2010_opengl\bin 2.

  3. css开发素材网址

    1.border-collapse 为表格设置合并边框模型 2.border-spacing border-spacing 属性设置相邻单元格的边框间的距离 backface-visibility:h ...

  4. Linux下Apache的安装与配置

    本文安装的httpd版本为httpd 2.4.4安装之前确保 Development Libraries与Development tools安装上.安装方法参考:http://www.linuxidc ...

  5. bt种子文件是什么(包括bt文件结构)

    bt种子文件是什么(包括bt文件结构) 一.总结 一句话总结:带特定格式特定信息(资源的url相关信息)的一个字符串(和json有点异曲同工之妙的感觉). 1.bt种子文件和json的区别和联系? 共 ...

  6. git将代码上传到coding分支

    分支 我理解的分支 分支,简单地讲就是一个项目的不同分支存放不同的代码,这样的话一个项目就有了几分代码,但是最终的代码一般放在主分支里面,即master分支里,分支在实际中可以方便的隔离开发. 假设你 ...

  7. iostream,iostream.h差异

    1. 不加.h的是现在C++中规定的标准,目的在于使C++代码用于移植和混合嵌入时不受扩展名.h的限制, 避免因为.h而造成的额外的处理和修改而加.h的是c语言的用法,但是在c++中也支持这种用法, ...

  8. Eclipse_插件_05_自动下载jar包源码插件

    一.Java Source Attacher 1.下载 官网:http://marketplace.eclipse.org/content/java-source-attacher#.U5RmTePp ...

  9. LeetCode OJ:Kth Smallest Element in a BST(二叉树中第k个最小的元素)

    Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Not ...

  10. 剑指offer--5.变态跳台阶

    WA了一次,错误数据4,输出8,怎么真么熟悉呢?改个return过了,OMG ------------------------------------------------------------- ...