---
title: "Set color in image or PDF using C# .NET | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/editor/manipulation/colors/"
md_url: "https://www.nutrient.io/guides/dotnet/editor/manipulation/colors.md"
last_updated: "2026-05-21T17:12:02.203Z"
description: "Learn how to set and adjust colors in images and PDF documents programmatically in C# using Nutrient .NET SDK. Customize document appearance in your applications."
---

# Set image or PDF colors in C#

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](#color-object)

- [`ARGB` method](#argb-method)

## Color object

Use the `Color` object to specify the color you want to use. It’s part of the `System.Drawing` namespace. For more information about available properties, refer to the [Microsoft documentation](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.color?view=net-6.0).

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

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg", true);
int borderHeight = 10;
// Set the bottom border color to aquamarine.
Color borderColor = Color.Aquamarine;
gdpictureImaging.AddBorderBottom(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg", True)
    Dim borderHeight = 10
    ' Set the bottom border color to aquamarine.
    Dim borderColor As Color = Color.Aquamarine
    gdpictureImaging.AddBorderBottom(imageID, borderHeight, borderColor)
    gdpictureImaging.SaveAsPNG(imageID, "C:\temp\output.png")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods

- [`AddBorderBottom`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~AddBorderBottom.html)

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveAsPNG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsPNG.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## ARGB method

The [`ARGB`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ARGB.html) method returns a [`Color` object](#color-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:

### C#

```csharp

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

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg", True)
    Dim borderHeight = 10
    ' Set the right border color to dark violet with 80 percent opacity.
    Dim borderColor As Color = gdpictureImaging.ARGB(204, 148, 0, 211)
    gdpictureImaging.AddBorderRight(imageID, borderHeight, borderColor)
    gdpictureImaging.SaveAsPNG(imageID, "C:\temp\output.png")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods

- [`ARGB`]

- [`AddBorderRight`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~AddBorderRight.html)

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveAsPNG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsPNG.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Color conversion

This section outlines ways to convert colors.

### From RGB to 32-bit

Use the [`ARGBI`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ARGBI.html) method to convert a color from RGB to a 32-bit value:

### C#

```csharp

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

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim bitColor As Integer = gdpictureImaging.ARGBI(100, 255, 87, 51)
End Using

```

### Other conversion methods

Using other conversion methods results in receiving reference parameters depending on the method used. The following code gives you the `red`, `green`, and `blue` parameters of the dark violet RGB code:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int red = 0, green = 0, blue = 0;
// Get the RGB code from CMYK for dark violet.
gdpictureImaging.ColorCMYKtoRGB(30, 100, 0, 17, ref red, ref green, ref blue);
Console.WriteLine(red + ", " + green + ", " + blue);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim red = 0, green = 0, blue = 0
    ' Get the RGB code from CMYK for dark violet.
    gdpictureImaging.ColorCMYKtoRGB(30, 100, 0, 17, red, green, blue)
    Console.WriteLine(red & ", " & green & ", " & blue)
End Using

```

Below is the list of all possible conversion methods:

- [`ColorCMYKtoRGB`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ColorCMYKtoRGB.html) – CMYK to RGB

- [`ColorCMYtoRGB`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ColorCMYtoRGB.html) – CMY to RGB

- [`ColorHSLtoRGB`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ColorHSLtoRGB.html) – HSL to RGB

- [`ColorRGBtoCMYK`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ColorRGBtoCMYK.html) – RGB to CMYK

- [`ColorRGBtoCMY`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ColorRGBtoCMY.html) – RGB to CMY

- [`ColorRGBtoHSL`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ColorRGBtoHSL.html) – RGB to HSL
---

## Related pages

- [Extract pages from a PDF in C#](/guides/dotnet/editor/manipulation/extract.md)
- [Replace colors in an image](/guides/dotnet/editor/manipulation/replace-colors-from-image.md)
- [Image filters using C# .NET](/guides/dotnet/editor/manipulation/filters.md)
- [Blur images in C# .NET](/guides/dotnet/editor/manipulation/blur.md)
- [PDF and image manipulation in C# .NET](/guides/dotnet/editor/manipulation.md)
- [Crop images in C# .NET](/guides/dotnet/editor/manipulation/crop.md)
- [Remove pages from PDFs in C#](/guides/dotnet/editor/manipulation/remove-page.md)
- [Rotate images and PDFs in C# .NET](/guides/dotnet/editor/manipulation/rotate.md)
- [Move or copy PDF pages and TIFF images in C#](/guides/dotnet/editor/manipulation/move-or-copy-page.md)

