Converts the pages of an image to BGR and returns the resulting image.
public RasterImage ConvertCmykPlanes(
RasterImage image
)
image
The image that contains the CMKY planes to be saved. The image should contain the four C, M, Y, K planes (in this order) with an optional alpha plane. Therefore, the number of pages in this parameter should be 4 (if no alpha) or 5 (if there is alpha). All pages should be 8-bit grayscale and have the same width, height and view perspective.
The BGR image containing the result.
This method is designed to convert the alpha plane images returned by RasterCodecs.LoadCmykPlanes. A typical reason for using this method is to perform the CMYK->BGR conversion using a particular ICC profile or CMYK color conversion settings.
By default, if the CMYK file is loaded using the RasterCodecs.Load or RasterCodecs.LoadAsync method, LEADTOOLS will automatically convert the CMYK data to BGR during the load. The conversion will be performed using the CMYK ICC profile embedded in the input file (if exists), or using the default LEADTOOLS CMYK ICC profile.
To change the default behavior to perform the conversion using a particular ICC profile, do the following:
If successful, ConvertCmykPlanes will allocate an image and return it. The user should dispose it when it is no longer needed.
The color conversion will be performed only on the first 4 planes. If a 5th plane exists, it will be considered an alpha plane and will be stored without being converted into the target bitmap.
Therefore, the output bitmap will be:
If the source image is in BGR format, use RasterColorConverterEngine.ConvertImage method instead.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ColorConversion;
using Leadtools.ImageProcessing;
private static void ConvertCMYKPlanes()
{
using (RasterColorConverterEngine converter = new RasterColorConverterEngine())
{
ConversionParameters parameters = new ConversionParameters();
parameters.InputProfile = @"C:\test\LEAD-cmyk.ICC";
parameters.ActiveMethod = ConversionMethodFlags.UseCustomIcc;
parameters.Method = parameters.ActiveMethod;
converter.Start(ConversionColorFormat.Cmyk, ConversionColorFormat.Bgr, parameters);
try
{
using (RasterCodecs codecs = new RasterCodecs())
{
string srcFile = @"C:\test\input.jpg";
string dstFile = @"C:\test\dst.png";
using (RasterImage cmykPlanes = codecs.LoadCmykPlanes(srcFile, 8, 1))
{
using (RasterImage dstImage = converter.ConvertCmykPlanes(cmykPlanes))
{
codecs.Save(dstImage, dstFile, RasterImageFormat.Png, 0);
}
}
}
}
finally
{
converter.Stop();
}
}
}
RasterColorConverterEngine Class
RasterColorConverterEngine Members
RasterColorConverterEngine.ConvertImage
Leadtools.ColorConversion Namespace
Handling CMYK Files as Separate Images
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document