HEX to RGB Color C#

HEX color codes are represented with a leading number sign. A hex triplet can denote a specific color that can be converted to an RGB value. In specific scenarios, you may need to convert a HEX color to RGB color space. In accordance with such requirements, this article explains how to convert HEX color to RGB or RGBA color code programmatically in C#.

Hexadecimal to RGB or RGBA Color Space Conversion – C# API Download

Aspose.SVG for .NET includes different classes, properties, and interfaces, like IConvertibleColor, which can be used to convert different color spaces like RGB, CMYK, HEX, etc. You can install the API by downloading its reference DLL files from the New Releases page, or running the following NuGet installation command:

PM> Install-Package Aspose.SVG

Convert HEX to RGB Color in C#

You can convert a HEX color code to RGB format by following the steps below:

  1. Parse the HEX color from a string.
  2. Convert HEX to RGB color code.
  3. Print the RGB color value on the console.

The following code snippet shows how to convert HEX to RGB color programmatically in C#:

Convert HEX to RGBA Color in C#

You can quickly convert HEX color to RGBA format programmatically in C# with the following steps:

  1. Parse the input HEX string.
  2. Convert HEX color string to RGBA color space.
  3. Print the output RGBA color code.

The code snippet below elaborates on how to convert a HEX color code to RGBA color space in C#:

Get Free API License

You can request a free temporary license to evaluate the API without any limitations.

Conclusion

In this article, you have learned how to convert a HEX to RGB or HEX color code to RGBA space programmatically in C#. Furthermore, you can visit the documentation space to take an overview of converting other color spaces and SVG manipulating features. If you need to discuss any of your queries or ambiguities, please feel free to write to us at forum.

See Also