---
title: "CMYK To RGB With Color Management"
canonical: https://www.graphicsmill.com/samples/ColorManagement/ConvertingColorValues/CmykToRgbWithColorManagement_cs
product: "Graphics Mill"
source: "ColorManagement/ConvertingColorValues/CmykToRgbWithColorManagement.cs"
---

# CMYK To RGB With Color Management

Converts a color specified in CMYK color space to RGB color space.

## Instruction

Converts a CMYK color to RGB using a specific color profile and prints the result.

## Usings

```csharp
using System;
using Aurigma.GraphicsMill.Transforms;
```

## Code Snippet

```csharp
public static class ColorExtension
{
    public static T To<T>(
        this Color color,
        ColorProfile destinationProfile = null,
        ColorManagementEngine engine = ColorManagementEngine.LittleCms,
        ColorProfile targetDeviceProfile = null,
        ColorTransformationIntent transformationIntent = ColorTransformationIntent.Perceptual)
        where T : Color, new() => ColorExtension.ConvertColor<T>(color, destinationProfile, engine, targetDeviceProfile, transformationIntent);

    internal static T ConvertColor<T>(
        Color color,
        ColorProfile destinationProfile,
        ColorManagementEngine engine = ColorManagementEngine.LittleCms,
        ColorProfile targetDeviceProfile = null,
        ColorTransformationIntent transformationIntent = ColorTransformationIntent.Perceptual)
        where T : Color, new()
    {
        if (destinationProfile == null)
        {
            Type colorType = typeof(T);
            if (colorType != typeof(LabColor) && colorType != typeof(Lab16Color))
            {
                throw new ArgumentException("Destination profile should be specified for converting to non-absolute color space (LabColor or Lab16Color)", "destinationProfile");
            }
        }

        using (var cc = new Aurigma.GraphicsMill.Transforms.ColorConverter())
        {
            cc.DestinationProfile = destinationProfile;
            cc.TargetDeviceProfile = targetDeviceProfile;
            cc.ColorManagementEngine = engine;
            cc.TransformationIntent = transformationIntent;

            T tempColor = new T();

            cc.DestinationPixelFormat = tempColor.PixelFormat;

            return (T)cc.ConvertColor(color, color.Profile);
        }
    }

    internal static T ConvertColor<T>(
        Color color,
        string destinationProfile,
        ColorManagementEngine engine = ColorManagementEngine.LittleCms,
        ColorProfile targetDeviceProfile = null,
        ColorTransformationIntent transformationIntent = ColorTransformationIntent.Perceptual)
        where T : Color, new()
    {
        return ConvertColor<T>(color, new ColorProfile(destinationProfile), engine, targetDeviceProfile, transformationIntent);
    }
}

public class ConvertCmykToRgbWithColorManagement
{
    public static void Run()
    {
        CmykColor cmykColor = new CmykColor(20, 42, 211, 40)
        {
            Profile = new ColorProfile("ISOcoated_v2_eci.icc"),
        };

        RgbColor rgbColor = cmykColor.To<RgbColor>(ColorProfile.FromSrgb());

        Console.WriteLine("With color management: {0} to {1}", cmykColor, rgbColor);
    }
}
```

## Explanation

The code:

- Creates a `CmykColor` instance with values (20, 42, 211, 40) and assigns a color profile "ISOcoated_v2_eci.icc".
- Converts the CMYK color to RGB using the `sRGB` color profile as the destination profile.
- Outputs the CMYK to RGB conversion result in the console.

## Tags

- [Color Conversion](<https://www.graphicsmill.com/samples/tags/color-conversion_md>): Converting colors between color spaces
- [Color Management](<https://www.graphicsmill.com/samples/tags/color-management_md>): Color management with ICC profiles

## Input

- [ISOcoated\_v2\_eci.icc](<https://www.graphicsmill.com/samples/ColorManagement/compiled/Debug/ISOcoated_v2_eci_icc>) (download)

## Output

- [ConvertCmykToRgbWithColorManagement.txt](<https://www.graphicsmill.com/samples/ColorManagement/compiled/Debug/ConvertCmykToRgbWithColorManagement_txt>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.CmykColor](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_CmykColor.htm.md>)
- [Aurigma.GraphicsMill.Color](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Color.htm.md>)
- [Aurigma.GraphicsMill.Color.PixelFormat](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Color_PixelFormat.htm.md>)
- [Aurigma.GraphicsMill.Color.Profile](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Color_Profile.htm.md>)
- [Aurigma.GraphicsMill.ColorProfile](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_ColorProfile.htm.md>)
- [Aurigma.GraphicsMill.ColorProfile.FromSrgb](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_ColorProfile_FromSrgb.htm.md>)
- [Aurigma.GraphicsMill.Lab16Color](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Lab16Color.htm.md>)
- [Aurigma.GraphicsMill.LabColor](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_LabColor.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorConverter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_ColorConverter.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorConverter.ColorManagementEngine](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Transforms_ColorConverter_ColorManagementEngine.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorConverter.ConvertColor(Color,ColorProfile)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Transforms_ColorConverter_ConvertColor_2_6c08ebc6.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorConverter.DestinationPixelFormat](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Transforms_ColorConverter_DestinationPixelFormat.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorConverter.DestinationProfile](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Transforms_ColorConverter_DestinationProfile.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorConverter.TargetDeviceProfile](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Transforms_ColorConverter_TargetDeviceProfile.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorConverter.TransformationIntent](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Transforms_ColorConverter_TransformationIntent.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorManagementEngine](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_ColorManagementEngine.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorTransformationIntent](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_ColorTransformationIntent.htm.md>)
