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 LittleCms or AdobeCmm, color management is enabled, if None - 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.
To get convinced of the importance of the color management, let us 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:
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)
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):
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 profile:
Dim bitmap As New Aurigma.GraphicsMill.Bitmap 'Choose LittleCMS color management engine 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)
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(); //Choose LittleCMS color management engine 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 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. 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 color space and embeds this profile.
Here is a code which applies the conversion between RGB and CMYK:
Dim bitmap As New Aurigma.GraphicsMill.Bitmap 'Choose LittleCMS color management engine 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)
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(); //Choose LittleCMS color management engine 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);