system.drawing.color

.NET - Converting Color Name Strings into System.Drawing.Color

心已入冬 提交于 2019-12-21 03:37:36
问题 What is the best way to turn strings like "red", "green", "yellow", "aliceblue", etc... into the actual System.Drawing.Color value? I was looking at reflection and something about that didn't seem right. 回答1: You can use Color.FromName() 回答2: System.Drawing.Color has a static method: public static Color FromName(string name) Use it like so: Color c = Color.FromName("AliceBlue") 回答3: System.Drawing.Color.FromName("Red"); 来源: https://stackoverflow.com/questions/579528/net-converting-color-name

C# Color constant R,G,B values

强颜欢笑 提交于 2019-12-18 03:39:40
问题 Where can I find a list of all the C# Color constants and the associated R,G,B (Red, Green, Blue) values? e.g. Color.White == (255,255,255) Color.Black == (0,0,0) etc... 回答1: Run this program: using System; using System.Drawing; using System.Reflection; public class Test { static void Main() { var props = typeof(Color).GetProperties(BindingFlags.Public | BindingFlags.Static); foreach (PropertyInfo prop in props) { Color color = (Color) prop.GetValue(null, null); Console.WriteLine("Color.{0} =

trying to convert rgb from a .net Color to a string such as “red” or “blue”

那年仲夏 提交于 2019-12-17 14:00:51
问题 All of my methods are failing me in various ways. different lighting can mess it all up too. has anyone every trying to return a name given a rgb value? "red" "green" "blue" would be enough to satisfy my needs for today. i have unsafe byte processing of images from my web cam. 回答1: If you have a list of known colors with names, you can see which of those known colors a given target color is 'closest' to, using a 'closeness' function along the lines of (F# code): let Diff (c1:Color) (c2:Color)

How to determine if color is close to other color

强颜欢笑 提交于 2019-12-11 18:38:38
问题 I am creating kind of color tool and this tool should tell me if color is close to other color, For example: Color[] colors = new colors[] { Color.FromArgb(0,0,255), Color.FromArgb(0,109,251)}; //colors[0] IS BLUE //colors[1] IS BRIGHTER BLUE (#006DFB) bool TheyClose = ColorsAreClose(colors[0],colors[1]); //TRUE BLUE IS CLOSE //TheyColse Should Be = TURE How should ColorsAreClose() Function Look? 回答1: How about something like this? bool ColorsAreClose(Color a, Color z, int threshold = 50) {

Is there an online example of all the colours in System.Drawing.Color?

江枫思渺然 提交于 2019-12-06 18:21:48
问题 Can anyone point me to a reference chart that has swatches of all the colours that are represented in System.Drawing.Color? 回答1: From here: The following image shows the color of each predefined brush, its name, and its hexadecimal value. May as well have the details right here on SO: 回答2: "Web Colors - X11 color names" from wikipedia: http://en.wikipedia.org/wiki/Web_colors http://en.wikipedia.org/wiki/X11_color_names WPF Colors Color names in Windows Presentation Foundation (WPF) match the

Is there an online example of all the colours in System.Drawing.Color?

廉价感情. 提交于 2019-12-04 23:50:49
Can anyone point me to a reference chart that has swatches of all the colours that are represented in System.Drawing.Color? From here: The following image shows the color of each predefined brush, its name, and its hexadecimal value. May as well have the details right here on SO: "Web Colors - X11 color names" from wikipedia: http://en.wikipedia.org/wiki/Web_colors http://en.wikipedia.org/wiki/X11_color_names WPF Colors Color names in Windows Presentation Foundation (WPF) match the color names in Microsoft .NET Framework, Windows Forms, and Microsoft Internet Explorer. These colors and their

Extension method library for actions on System.Drawing.Color

孤者浪人 提交于 2019-12-04 09:18:00
Has anyone written a nice extension method 'library' for System.Drawing.Color. Would be nice to say : Color.Red.AdjustBrightness(.5) Color.Red.AdjustAlpha(.5) Color.Red.ToHSV() or something like that. Alpha is easy, but others become time consuming because you have to go off and fine all the right mathematical equations for HSV and HSB and all that fun stuff. Hoping someone else had done the work already :-) Microsoft doesn't seem to want to do it for me. CodeProject has some code for an HSBColor class. It doesn't include extension methods, but they would be very straightforward to write once

Set System.Drawing.Color values

瘦欲@ 提交于 2019-12-04 08:46:45
问题 Hi how to set R G B values in System.Drawing.Color.G ? which is like System.Drawing.Color.G=255; is not allowed because its read only Property or indexer 'System.Drawing.Color.G' cannot be assigned toit is read only i just need to create a Color Object by assigning custom R G B values 回答1: You could create a color using the static FromArgb method: Color redColor = Color.FromArgb(255, 0, 0); You can also specify the alpha using the following overload. 回答2: The Color structure is immutable (as

Set System.Drawing.Color values

眉间皱痕 提交于 2019-12-03 01:58:17
Hi how to set R G B values in System.Drawing.Color.G ? which is like System.Drawing.Color.G=255; is not allowed because its read only Property or indexer 'System.Drawing.Color.G' cannot be assigned toit is read only i just need to create a Color Object by assigning custom R G B values You could create a color using the static FromArgb method: Color redColor = Color.FromArgb(255, 0, 0); You can also specify the alpha using the following overload . The Color structure is immutable (as all structures should really be), meaning that the values of its properties cannot be changed once that

Using ToArgb() followed by FromArgb() does not result in the original color

老子叫甜甜 提交于 2019-12-01 05:21:05
This does not work int blueInt = Color.Blue.ToArgb(); Color fred = Color.FromArgb(blueInt); Assert.AreEqual(Color.Blue,fred); Any suggestions? [Edit] I'm using NUnit and the output is failed: Expected: Color [Blue] But was: Color [A=255, R=0, G=0, B=255] [Edit] This works! int blueInt = Color.Blue.ToArgb(); Color fred = Color.FromArgb(blueInt); Assert.AreEqual(Color.Blue.ToArgb(),fred.ToArgb()); From the MSDN documentation on Color.operator == : This method compares more than the ARGB values of the Color structures. It also does a comparison of some state flags. If you want to compare just the