This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/editor/manipulation/colors.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Set color in image or PDF using C# .NET | Nutrient .NET SDK
Download sample

The color property is one of the most frequently used parameters in Nutrient .NET SDK (formerly GdPicture.NET) methods. It’s used when:

  • Drawing shapes
  • Adding annotations
  • Creating images
  • Setting up borders

There are two main ways to set a color:

Color object

Use the GdPictureColor object to specify the color you want to use. It’s part of the GdPicture14.Imaging namespace. It provides named colors such as GdPictureColor.Red and GdPictureColor.Teal. For other colors, use the GdPictureColor.FromArgb method.

To set the bottom border color of an image to aquamarine, use the following code:

Register the SDK license before running SDK operations. For setup details, refer to the getting started with .NET SDK guide.

using GdPicture14;
using GdPicture14.Imaging;
LicenseManager license = new LicenseManager();
license.RegisterKEY("");
{
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"input.jpg", true);
int borderHeight = 10;
// Set the bottom border color to aquamarine.
GdPictureColor borderColor = GdPictureColor.FromArgb(127, 255, 212);
gdpictureImaging.AddBorderBottom(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, @"output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}

ARGB method

The ARGB method returns a GdPictureColor object and accepts one of the following:

  • 32-bit color value (0x78FF0000)
  • RGB code (255, 87, 51)
  • Alpha value (opacity in range between 0 and 255) and RGB code (100, 255, 87, 51)

To set the right border color of an image to dark violet with 80 percent opacity, use the following code:

{
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"input.jpg", true);
int borderHeight = 10;
// Set the right border color to dark violet with 80 percent opacity.
GdPictureColor borderColor = gdpictureImaging.ARGB(204, 148, 0, 211);
gdpictureImaging.AddBorderRight(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, @"output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}

Color conversion

This section outlines ways to convert colors.

From RGB to 32-bit

Use the ARGBI method to convert a color from RGB to a 32-bit value:

{
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int bitColor = gdpictureImaging.ARGBI(100, 255, 87, 51);
}

Other conversion methods

Using other conversion methods results in receiving reference parameters depending on the method used. Each CMYK component ranges from 0 to 255. The following code gives you the red, green, and blue parameters of the dark violet RGB code (148, 0, 211):

{
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int red = 0, green = 0, blue = 0;
// Get the RGB code from CMYK for dark violet.
gdpictureImaging.ColorCMYKtoRGB(77, 255, 0, 44, ref red, ref green, ref blue);
Console.WriteLine(red + ", " + green + ", " + blue);
}

Below is the list of all possible conversion methods: