←Select platform

ConvertCmykPlanes Method

Summary

Converts the pages of an image to BGR and returns the resulting image.

Syntax

C#
public RasterImage ConvertCmykPlanes( 
   RasterImage image 
) 

Parameters

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.

Return Value

The BGR image containing the result.

Remarks

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:

  1. Load the CMYK planes using RasterCodecs.LoadCmykPlanes.
  2. Initialize the color conversion engine using RasterColorConverterEngine.Start.
  3. Convert the CMYK planes to BGR using ConvertCmykPlanes.
  4. Dispose the image containing the CMYK planes.

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.

Example

C#
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(); 
      } 
   } 
} 

Requirements

Target Platforms

See Also

RasterColorConverterEngine Class

RasterColorConverterEngine Members

RasterColorConverterEngine.ConvertImage

RasterCodecs.LoadCmykPlanes

Leadtools.ColorConversion Namespace

Handling CMYK Files as Separate Images

Help Version 23.0.2024.10.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ColorConversion Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.