When we convert pixels between different color spaces (RGB<->CMYK, RGB<->Grayscale, and CMYK<->Grayscale), Graphics Mill for .NET allows to choose whether to apply color management. If we do not use color management, it works faster, but conversion is inaccurate. Colors may look non-realistic. Vice versa, color management allows to preserve natural colors, but works slower. To choose the color management engine, use the ColorManagementEngine property of the ColorManagementProvider returned by the Bitmap class instance. When this property is true , the color management is enabled, otherwise - disabled.

Also, color management can be successfully used only if input and output profiles are provided.

This topic demonstrates how to apply color management when converting pixels between CMYK and RGB, and vice versa.

Converting CMYK to RGB

To get convinced of the importance of the color management, let's compare results of conversion between CMYK and RGB with color management disabled and enabled.

This code loads CMYK JPEG and converts it to RGB without color management:

Visual Basic CopyCode imageCopy Code
        Dim bitmap As New Aurigma.GraphicsMill.Bitmap

        'Disable color management
        bitmap.ColorManagement.ColorManagementEngine = Aurigma.GraphicsMill.Transforms.ColorManagementEngine.None

        'Load CMYK image with embedded ICM profile from file
        bitmap.Load("C:\Horses.jpg")

        'Convert to RGB
        bitmap.ColorManagement.ConvertToContinuous( _
         Aurigma.GraphicsMill.ColorSpace.Rgb, False, bitmap.IsExtended)
C# CopyCode imageCopy Code
            Aurigma.GraphicsMill.Bitmap bitmap = 
                new Aurigma.GraphicsMill.Bitmap();

            //Disable color management
            bitmap.ColorManagement.ColorManagementEngine = Aurigma.GraphicsMill.Transforms.ColorManagementEngine.None;

            //Load CMYK image with embedded ICM profile from file
            bitmap.Load(@"C:\Horses.jpg");

            //Convert to RGB
            bitmap.ColorManagement.ConvertToContinuous(
                Aurigma.GraphicsMill.ColorSpace.Rgb, true, bitmap.IsExtended);

The result is displayed on the figure below. Colors look too saturated and non-realistic (trees are as green as tropic plants, soil and stones are too bluish instead of being gray):

Converting without color management

Now let's apply the conversion with color management. To accomplish this, we need to specify the profile of the color space which we are converting to. Let's take a standard sRGB Leave site profile:

Visual Basic CopyCode imageCopy Code
        Dim bitmap As New Aurigma.GraphicsMill.Bitmap

        'Enable color management
        bitmap.ColorManagement.ColorManagementEngine = Aurigma.GraphicsMill.Transforms.ColorManagementEngine.LittleCms

        'Load CMYK image with embedded ICM profile from file
        bitmap.Load("C:\Horses.jpg")

        'Assing output RGB profile for conversion
        bitmap.ColorManagement.RgbColorProfile = Aurigma.GraphicsMill.ColorProfile.FromSrgb

        'Convert to RGB
        bitmap.ColorManagement.ConvertToContinuous( _
         Aurigma.GraphicsMill.ColorSpace.Rgb, False, bitmap.IsExtended)
C# CopyCode imageCopy Code
            Aurigma.GraphicsMill.Bitmap bitmap = 
                new Aurigma.GraphicsMill.Bitmap();

            //Enable color management
            bitmap.ColorManagement.ColorManagementEngine = Aurigma.GraphicsMill.Transforms.ColorManagementEngine.LittleCms;

            //Load CMYK image with embedded ICM profile from file
            bitmap.Load(@"C:\Horses.jpg");

            //Assing output RGB profile for conversion
            bitmap.ColorManagement.RgbColorProfile = Aurigma.GraphicsMill.ColorProfile.FromSrgb();

            //Convert to RGB
            bitmap.ColorManagement.ConvertToContinuous( 
                Aurigma.GraphicsMill.ColorSpace.Rgb, false, bitmap.IsExtended);

Below we can see the result produced by this code. As you see colors look much more natural:

Converting with color management

Converting RGB to CMYK

Converting color from RGB to CMYK is almost the same. We need to specify the color profile of the CMYK color space (which corresponds to the device where we want to display this image, for example your printer). In this code example we will take Euroscale Coated profile which can be downloaded from the Adobe Systems Incorporated web site Leave site . To make the example more interesting, let's assume that the source file does not contain an embedded profile. We presume that the image is stored in the standard sRGB Leave site color space and embeds this profile.

Here is a code which applies the conversion between RGB and CMYK:

Visual Basic CopyCode imageCopy Code
        Dim bitmap As New Aurigma.GraphicsMill.Bitmap

        'Enable color management
        bitmap.ColorManagement.ColorManagementEngine = Aurigma.GraphicsMill.Transforms.ColorManagementEngine.LittleCms

        'Load RGB image without embedded ICM profile from file
        bitmap.Load("C:\Flower.jpg")

        'Assign input sRGB profile
        bitmap.ColorProfile = Aurigma.GraphicsMill.ColorProfile.FromSrgb

        'Assing output CMYK profile for conversion
        bitmap.ColorManagement.CmykColorProfile = New Aurigma.GraphicsMill.ColorProfile( _
         "C:\windows\system32\spool\drivers\color\EuroscaleCoated.icc")

        'Convert to CMYK
        bitmap.ColorManagement.ConvertToContinuous( _
         Aurigma.GraphicsMill.ColorSpace.Cmyk, False, bitmap.IsExtended)
C# CopyCode imageCopy Code
            Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap();

            //Enable color management
            bitmap.ColorManagement.ColorManagementEngine = Aurigma.GraphicsMill.Transforms.ColorManagementEngine.LittleCms;

            //Load RGB image without embedded ICM profile from file
            bitmap.Load(@"C:\Flower.jpg");

            //Assign input sRGB profile
            bitmap.ColorProfile = Aurigma.GraphicsMill.ColorProfile.FromSrgb();

            //Assing output CMYK profile for conversion
            bitmap.ColorManagement.CmykColorProfile = new Aurigma.GraphicsMill.ColorProfile( 
                @"C:\windows\system32\spool\drivers\color\EuroscaleCoated.icc");

            //Convert to CMYK
            bitmap.ColorManagement.ConvertToContinuous( 
                Aurigma.GraphicsMill.ColorSpace.Cmyk, false, bitmap.IsExtended);