如何使用.NET从十六进制颜色code得到的颜色?

编程入门 行业动态 更新时间:2024-10-10 10:31:13
本文介绍了如何使用.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得到的颜色?

本文发布于:2023-06-10 18:42:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/616568.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:颜色   如何使用   十六进制   NET   code

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!