IRONSOFTWAREHOME
Create Color
using IronSoftware.Drawing;

// Create a new Color object
Color fromHex = new Color("#191919");
Color fromRgb = new Color(255, 255, 0);
Color fromEnum = Color.Crimson;

// Cast between System.Drawing.Color and IronSoftware.Drawing.Color
System.Drawing.Color drawingColor = System.Drawing.Color.Red;
IronSoftware.Drawing.Color ironColor = drawingColor;

// Get the Alpha, Red, Green, or Blue channel value of a Color
var alpha = ironColor.A;
var red = ironColor.R;
var green = ironColor.G;
var blue = ironColor.B;

// Luminance
ironColor.GetLuminance();


NuGet Download
PM > Install-Package IronSoftware.System.Drawing
Create Color

Create Color

IronDrawing enables users to create their own color using various ways including Hexadecimal, RGB values, and also from Enum where the customer can choose an already available color.

Color creation

To create a color using a Hexadecimal value, simply create a variable with the type Color and assign the hexadecimal value in terms of string to the variable using new Color("#191919") method. To create color using RGB values, key in the RGB values new Color(255, 255, 0) and store it inside a Color type variable.

Casting System.Drawing.Color to IronSoftware.Drawing.Color

Simply assign a System.Drawing.Color type variable with a color System.Drawing.Color.Red. Next, assign the variable to a new IronSoftware.Drawing.Color variable. ARGB values can be extracted and read from the color casted.

Luminance

To get the luminance of the color casted, or any IronSoftware.Drawing.Color, use the .GetLuminance() method on the color. Luminance is a value from 0 (black) to 100 (white) where 50 is the perceptual "middle gray".

View on GitHub

Ready to Get Started?

Nuget Downloads 19,926,787Version:2025.3just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required