C#的颜色解析及操作和相关Brush
一、颜色表示方式 //
// 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的更多相关文章
- python 全栈开发,Day52(关于DOM操作的相关案例,JS中的面向对象,定时器,BOM,client、offset、scroll系列)
昨日作业讲解: 京东购物车 京东购物车效果: 实现原理: 用2个盒子,就可以完整效果. 先让上面的小盒子向下移动1px,此时就出现了压盖效果.小盒子设置z-index压盖大盒子,将小盒子的下边框去掉, ...
- 前端JavaScript(3)-关于DOM操作的相关案例,JS中的面向对象、定时器、BOM、位置信息
小例子: 京东购物车 京东购物车效果: 实现原理: 用2个盒子,就可以完整效果. 先让上面的小盒子向下移动1px,此时就出现了压盖效果.小盒子设置z-index压盖大盒子,将小盒子的下边框去掉,就可以 ...
- JavaScript对SVG进行操作的相关技术
原文地址:http://www.ibm.com/developerworks/cn/xml/x-svgscript/ 本文主要介绍在 SVG 中通过编程实现动态操作 SVG 图像的知识. SVG ...
- 『学了就忘』Linux基础命令 — 19、目录操作的相关命令
目录 1.ls命令 2.cd命令 (1)绝对路径和相对路径 (2)cd命令的简化用法 3.pwd命令 4.mkdir命令 5.rmdir命令 常用目录操作的相关命令: ls命令 cd命令 pwd命令 ...
- scrapy架构与目录介绍、scrapy解析数据、配置相关、全站爬取cnblogs数据、存储数据、爬虫中间件、加代理、加header、集成selenium
今日内容概要 scrapy架构和目录介绍 scrapy解析数据 setting中相关配置 全站爬取cnblgos文章 存储数据 爬虫中间件和下载中间件 加代理,加header,集成selenium 内 ...
- 通过pull解析器操作安卓的xml
通过pull解析器操作安卓的xml 例子定义了一个javabean用于存放上面解析出来的xml内容, 这个javabean为Person,代码请见本页下面备注: =================== ...
- Selenium2Lib库之操作浏览器相关的关键字实战
1.1 操作浏览器相关的关键字 Selenium2Lib提供了与浏览器交互的关键词 1.1.1 Open Browser关键字 按F5 查看Open Browser关键字的说明,如下图: Open ...
- 前端 ----关于DOM的操作的相关实例
关于DOM操作的相关案例 1.模态框案例 需求: 打开网页时有一个普通的按钮,点击当前按钮显示一个背景图,中心并弹出一个弹出框,点击X的时候会关闭当前的模态框 代码如下: <!DOCTYPE ...
- Ubuntu软件操作的相关命令
Ubuntu软件操作的相关命令 sudo apt-get update ------------------------------- 更新源 sudo apt-get install package ...
随机推荐
- php提前输出响应及注意问题
1.浏览器和服务器之间是通过HTTP进行通信的,浏览器发送请求给服务器,服务器处理完请求后,发送响应结果给浏览器,浏览器展示给用户.如果服务器处理请求时间比较长,那么浏览器就需要等待服务器的处理结果. ...
- volist/foreach下,点击循环中的一个进行操作
第一种方法,是给点击元素绑定事件,用ajax将值传到控制器中,其中传的值,用jquery选择器选择值. 1.在html中 <foreach name="save" item= ...
- nova shelve
当一个虚机不需要使用的时候,可以将其 shelve 起来.该操作会创建该虚机的一个快照并传到 Glance 中,然后在 Hypervisor 上将该虚机删除,从而释放其资源. 其主要过程为: dest ...
- struts2学习(4)
Struts2拦截器概述 1 Struts2是框架,封装了很多功能,struts2里面封装的概念都是在拦截器里面 2 Struts2里面封装了很多的概念,有很多拦截器,不是每次这些拦截器都执行,每次执 ...
- StringUtil方法全集
org.apache.commons.lang.StringUtils中方法的操作对象是Java.lang.String类型的对象,是JDK提供的String类型操作方法的补充,并且是null安全的( ...
- lightoj1422 区间dp
对于这一题想了很久真的是一点头绪也没有,还有组数明明是200,数据范围100,O(n^3)的复杂度居然不会爆掉(可能是因为一直在想怎么用O(n^2)的复杂度做这题 做法是先预处理dp,对于dp[i][ ...
- 关于js序列化时间的方法
var time = new Date(); var otime = getMyDate(time); //将毫秒转换成 年月日+时分秒 格式的 (1970-01-11 00:00:00) funct ...
- html5视频video积累
又是好几个月没有写东西,还是太懒散了~必须要教育下自己罗~ 这次做了个播放视频的移动H5,之前没有仔细玩过,好好记录下基本知识,还有遇到的一些坑,方便之后再次遇见后进行解决 一.基本 video标签在 ...
- 加密算法之BLOWFISH算法
加密信息 BlowFish算法用来加密64Bit长度的字符串. BlowFish算法使用两个"盒"--ungignedlongpbox[18]和unsignedlongsbox[4 ...
- nodejs读取excel内容批量替换并生成新的html和新excel对照文件
因为广告投放需要做一批对外投放下载页面,由于没有专门负责填充页面的编辑同学做,只能前端来做了, 拿到excel看了一下,需要生成200多个文件,一下子懵逼了. 这要是来回复制粘贴太low了 正好最新用 ...