C#,silverlight中 将颜色字符串的RRGGBB转换成为颜色
生活随笔
收集整理的這篇文章主要介紹了
C#,silverlight中 将颜色字符串的RRGGBB转换成为颜色
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
代碼 private?Color?ReturnColorFromString(string?color)
????????{
????????????string?alpha?=?color.Substring(0,?2);
????????????string?red?=?color.Substring(2,?2);
????????????string?green?=?color.Substring(4,?2);
????????????string?blue?=?color.Substring(6,?2);
????????????byte?alphaByte?=?Convert.ToByte(alpha,?16);
????????????byte?redByte?=?Convert.ToByte(red,?16);
????????????byte?greenByte?=?Convert.ToByte(green,?16);
????????????byte?blueByte?=?Convert.ToByte(blue,?16);
????????????return?Color.FromArgb(alphaByte,?redByte,?greenByte,?blueByte);
????????} ??
int argb = color.A << 24;
argb += color.R << 16;
argb += color.G << 8;
argb += color.B;
return argb;
}
????????{
????????????string?alpha?=?color.Substring(0,?2);
????????????string?red?=?color.Substring(2,?2);
????????????string?green?=?color.Substring(4,?2);
????????????string?blue?=?color.Substring(6,?2);
????????????byte?alphaByte?=?Convert.ToByte(alpha,?16);
????????????byte?redByte?=?Convert.ToByte(red,?16);
????????????byte?greenByte?=?Convert.ToByte(green,?16);
????????????byte?blueByte?=?Convert.ToByte(blue,?16);
????????????return?Color.FromArgb(alphaByte,?redByte,?greenByte,?blueByte);
????????} ??
顏色到數(shù):
?
public static int ToArgb(this Color color) {int argb = color.A << 24;
argb += color.R << 16;
argb += color.G << 8;
argb += color.B;
return argb;
}
?
轉(zhuǎn)載于:https://www.cnblogs.com/xtechnet/archive/2010/03/23/1692752.html
總結(jié)
以上是生活随笔為你收集整理的C#,silverlight中 将颜色字符串的RRGGBB转换成为颜色的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Eclipse反编译插件: Jodecl
- 下一篇: android布局之LinearLayo