No, there is no such thing as a GreyColor in .NET. A GreyColor is just a particular case of a color, the same way that lime green is a particular case of a color. There is no need for complicating the model.
There are some pre-defined colors that you can use if you can find the color you're looking for. These simply return a Color object that has an ARGB value matching the pre-defined color, so they're really not doing anything different than your code is doing above. They're simply there for the convenience of the programmer who can't or doesn't want to remember the not-so-intuitive RGB color model.
You seem to be concerned about the potential expense or redundancy of creating a Color object, but there are a couple of reasons why this shouldn't be a concern. You can think of the FromArgb method as an overloaded constructor for the Color
object: this is the way that you create a color other than the pre-defined ones. It simply creates the color object that is defined as the RGB values that you specify. In fact, there's really no other way to represent a color (aside from alternative color models such as HSV, but even then you'd have to specify three separate values: a hue of 0, a saturation of 0, and a value of 39). We humans can describe colors in much more abstract ways, but a computer doesn't really understand or care about these things. The documentation for the Color structure itself explains that it just represents the RGB values, along with the alpha (transparency) value. It's a very small object that contains about 4 byte values. And that's precisely how the method that you pass the color to (Bitmap.SetPixel
) is going to draw the color, based on those red, green, and blue values.
It's also worth pointing out that Color
is a structure, which is a value type, rather than a reference type. That means, among other things, that it lives inline, wherever your variable is defined. It doesn't point to another object, it lives locally on the stack rather than on the heap, and the stack is cheap. This makes it at least somewhat less expensive than a reference type such as a class.
Finally, I'd be remiss if I didn't point out that this type of micro-optimization is rarely going to make any difference in the performance of your code.
In short, no there's no such thing, but that's nothing to worry about.