一、颜色表示方式

        //
// 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. 基于“基于dockerhub的jetty镜像的ossfs镜像”部署war包,遇到的文件夹读写权限被限制的问题解决方案

    前提: “基于dockerhub的jetty镜像的ossfs镜像” 已经搭建好了. 部署准备: 1.本地打包:war包-->idea工具 mvn 打包. 2.本地sh脚本:compile_vps ...

  2. Nuxt / Vue.js in TypeScript: Object literal may only specify known properties, but 'components' does not exist in type 'VueClass'

    项目背景, Nuxt(vue), TypeScript 生成完项目框架, 添加测试demo页面. 在生成的模板代码中添加layout配置如下: <script lang="ts&quo ...

  3. java中大数类的学习

    java中提供了大数类BigInteger和BigDecimal分别表示大整数类和大浮点数类,这两个类都在java.math.*包中,因此每次必须在开头处引用该包. 一.BigInteger构造函数: ...

  4. UOJ222 【NOI2016】区间

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...

  5. linux防火墙开关

    对于普通Linux机器开关防火墙命令: 1重启后生效 chkconfig iptables off chkconfig iptables on 2即时生效 serivce iptables statu ...

  6. windows live writer 设置默认字体

      下载 Text Template 插件 设置默认字体添加模版. <p style="padding-bottom: 0px; line-height: 130%; margin-t ...

  7. 51nod 1625 贪心/思维

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1625 1625 夹克爷发红包 基准时间限制:1 秒 空间限制:13107 ...

  8. 项目管理理论与实践(4)——UML应用(上)

    本篇文章介绍UML的相关知识.参考<UML从入门到精通> 一.UML综述 1. UML简介 统一建模语言(UML)是一个通用的可视化建模语言,用于对软件进行描述.可视化处理.构造和建立软件 ...

  9. cmd命令之查看进程到杀掉进程

    1. cmd命令查看当前进程 netstat -ano | findstr “port”

  10. nyoj-451-光棍节的快乐(错排公式)

     题目链接 /* Name:nyoj-451-光棍节的快乐 Copyright: Author: Date: 2018/4/25 16:44:47 Description:D(n)=(n-1)*(D( ...