How to convert Hexadecimal Color to RGB color (24 Bit)

落花浮王杯 提交于 2020-01-04 20:23:31

问题


I use C# and asp.net 4.

How to convert and Hexadecimal Color in an equivalent RGB Color?

Example: FF0000 to 255,0,0.

My aim is to pass this color to the method FromArgb namespace System.Drawing

FromArgb Method (Int32, Int32, Int32) (Alpha is implicit as opaque)

At the moment I use this code to Clear and Image and apply a opaque flat color:

System.Drawing.Graphics.Clear(System.Drawing.Color.Red));

This works fine with predefined color like "Red", "Black" and so on, but not obviously with a Custom more precise color.

Any ideas? Thanks for your help!

Resource:

http://msdn.microsoft.com/en-us/library/cce5h557.aspx

http://msdn.microsoft.com/en-us/library/system.drawing.color.aspx


回答1:


Why don't you just do this?

System.Drawing.Color myColor = System.Drawing.Color.FromArgb(0xFF0000);  



回答2:


This answer may help: C# convert integer to hex and back again



来源:https://stackoverflow.com/questions/5553673/how-to-convert-hexadecimal-color-to-rgb-color-24-bit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!