如果颜色未知,如何从十六进制值获取颜色名称 [英] How to get color name from Hexdecimal value if it is unknown color

查看:93
本文介绍了如果颜色未知,如何从十六进制值获取颜色名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,如果选择黑色,我将使用颜色对话框,但我将color.name设置为黑色,但是我选择了不同的颜色,即十六进制十进制值,如何将十六进制十进制值转换为颜色名称

In my application i am using color dialog if select black i get color.name as black but i select different color that it gives hex decimal value , how to convert hex decimal value to color name

推荐答案

获取所有颜色名称,并使用其十六进制值作为键将它们放入字典中.检查字典以查看您使用的十六进制值是否存在.如果是这样,请从字典中获取值,然后您便拥有颜色名称.
Get all the color names, and put them in a dictionary using their hex value as the key. Check the dictionary to see if the hex value you are working with exists. If it does, get the value out of the dictionary and you have your color name.


如果您确实想要颜色名称,将无济于事.
但是,如果您需要该十六进制值中的颜色对象,则可以使用

If you really want the color name, can''t help.
But if you require color object from that Hex value, then you can use

Dim c As Color = ColorTranslator.FromHtml("#25A595")


这篇关于如果颜色未知,如何从十六进制值获取颜色名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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