如何以十六进制颜色在图形对象上绘制实心圆?
我需要以十六进制给出的特定颜色在位图上绘制一个圆圈。 “Brushes”类仅给出特定颜色的名称。
Bitmap bitmap = new Bitmap(20, 20);
Graphics g = Graphics.FromImage(bitmap);
g.FillEllipse(Brushes.AliceBlue, 0, 0, 19, 19); //The input parameter is not a Hex
//g.FillEllipse(new Brush("#ff00ffff"), 0, 0, 19, 19); <<This is the kind of think I need.
有办法做到这一点吗?
确切的问题: 我正在生成 KML(用于 Google 地球),并且正在生成许多具有不同十六进制颜色的线条。颜色是通过数学方式生成的,我需要保持这种方式,这样我就可以制作尽可能多的颜色。我需要为每条线生成一个颜色完全相同的 PNG 图标。
I need to draw a circle onto a bitmap in a specific colour given in Hex. The "Brushes" class only gives specific colours with names.
Bitmap bitmap = new Bitmap(20, 20);
Graphics g = Graphics.FromImage(bitmap);
g.FillEllipse(Brushes.AliceBlue, 0, 0, 19, 19); //The input parameter is not a Hex
//g.FillEllipse(new Brush("#ff00ffff"), 0, 0, 19, 19); <<This is the kind of think I need.
Is there a way of doing this?
The exact problem:
I am generating KML (for Google earth) and I am generating lots of lines with different Hex colours. The colours are generated mathematically and I need to keep it that way so I can make as many colours as I want. I need to generate a PNG icon for each of the lines that is the same colour exactly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ColorTranslator.FromHtml
将为您提供相应的 System.Drawing.Color:ColorTranslator.FromHtml
will give you the corresponding System.Drawing.Color:使用由适当的 SolidBrush 构建的="http://msdn.microsoft.com/en-us/library/system.drawing.color.aspx" rel="nofollow noreferrer">颜色。
例子:
Use a SolidBrush constructed with the appropiate Color.
Example:
您可能必须手动解析颜色字符串。
正如 Aaronaught 指出的,如果你的 ARGB 是按照这个顺序,那么 FromARGB 就会有一个重载,它接受一个整数中的所有组件:
You may have to manually parse the color string.
As Aaronaught points out, if your ARGB is in that order, there is an overload for FromARGB that accepts all components in one integer: