如何使用.NET从十六进制颜色code得到的颜色? [英] How to get Color from Hexadecimal color code using .NET?

查看:122
本文介绍了如何使用.NET从十六进制颜色code得到的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能得到一个16进制的颜色code一个Color或者说,哈希code(例如#FFDFD991 )?

How can I get a Color from a Hexadecimal color code or say, Hash code (e.g. #FFDFD991)?

我读一个文件,并得到16进制的颜色code,我需要为十六进制的颜色$ C创建相应的 System.Windows.Media.Color 实例$ C。是否有任何框架内置的方法来做到这一点?

I am reading a file and getting Hexadecimal color code, I need to create the corresponding System.Windows.Media.Color instance for the Hexadecimal color code. Is there any inbuilt method in framework to do this?

推荐答案

我假定这是一个ARGB code ...你指的的System.Drawing.Color System.Windows.Media.Color ?后者在WPF用于示例。我还没有看到任何人提到它,所以以防万一你要找的是:

I'm assuming that's an ARGB code... Are you referring to System.Drawing.Color or System.Windows.Media.Color? The latter is used in WPF for example. I haven't seen anyone mention it yet, so just in case you were looking for it:

using System.Windows.Media;

Color color = (Color)ColorConverter.ConvertFromString("#FFDFD991");

这篇关于如何使用.NET从十六进制颜色code得到的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆