←Select platform

LoadCmykPlanes(string,int,int) Method

Loads CMYK, TIFF or JPEG files as CMYK and avoids the colorspace conversion to RGB.
public RasterImage LoadCmykPlanes( 
   string fileName, 
   int bitsPerPixel, 
   int pageNumber 
Public Overloads Function LoadCmykPlanes( _ 
   ByVal fileName As String, _ 
   ByVal bitsPerPixel As Integer, _ 
   ByVal pageNumber As Integer _ 
) As RasterImage 
- (nullable LTRasterImage *)loadCmykPlanesFromFile:(NSString *)file  
                                             error:(NSError **)error 
RasterImage^ LoadCmykPlanes(  
   String^ fileName, 
   int bitsPerPixel, 
   int pageNumber 


A String containing the name of the image file to load. The file must be CMYK, otherwise the method will fail and throw an exception.

Resulting image pixel depth. Possible values are:

Value Meaning
8 Each plane will be a grayscale 8 bits per pixel image.
16 Each plane will be a grayscale 16 bits per pixel image. Not available for JPEG CMYK files.

1-based index of the page from which the planes should be loaded.

Return Value

A RasterImage that this method loads. The image will contain one page for each of the CMYK planes.


If the data does not have to be loaded as CMYK, use Load or LoadAsync.

Support for 16-bit grayscale images is only available in the Document/Medical Imaging editions.

This method will fail if the input file is not TIFF or JPEG CMYK. Note that not all the pages should be CMYK - it is enough if only the page that you wish to load is CMYK.

Only the following memory load options are supported by this method:

This method uses the values of RasterCodecs.Options.Tiff.Load.ImageFileDirectoryOffset.

If the image being loaded contains alpha channel information, it will be stored in the 5th page of the returned image.

Use RasterImagePainter.PaintCmykPlanes to display the array and SaveCmykPlanes to save an image as a CMYK TIFF or JPEG file.

If you want to convert the CMYK array to a regular BGR image and use the other methods or save to a file format other than TIFF or JPEG CMYK, use ColorMergeCommand and set the ColorMergeCommand.Type to ColorMergeCommandType.Cmyk.

If you have an alpha image, use RasterImage.SetAlphaImage to set the alpha image.

You can apply image processing on each individual image. This allows you to process each color plane separately.

If you want to load a non-CMYK file as an array of color plane, use the normal Load or LoadAsync method and then use ColorSeparateCommand and RasterImage.CreateAlphaImage method.


This example will load a CMYK TIFF file, increase the brightness of the K plane only (which will darken the image) and save the file as CMYK TIFF.

using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
void CmykPlanesExample(string cmykTifFile) 
	RasterCodecs codecs = new RasterCodecs(); 
	string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "CmykPlanesTif.tif"); 
	// Load the CMYK Planes of this image 
	RasterImage cmykImage = codecs.LoadCmykPlanes(cmykTifFile, 8, 1); 
	Console.WriteLine("CMYK planes loaded into an image with {0} pages", cmykImage.PageCount); 
	Debug.Assert(cmykImage.PageCount == 4); 
	// The load has succeeded. Increase the brightness of the K (black) plane by 50% 
	// Note that this will DARKEN the image, because we increased the amount of black! 
	Console.WriteLine("Changing the intensity of the K plane (the 4th page)"); 
	ChangeIntensityCommand command = new ChangeIntensityCommand(); 
	command.Brightness = 500; 
	cmykImage.Page = 4; 
	cmykImage.Page = 1; 
	Console.WriteLine("Saving the image to the destination file"); 
	codecs.SaveCmykPlanes(cmykImage, destFileName, RasterImageFormat.TifLzwCmyk, 8, 1, CodecsSavePageMode.Overwrite); 
	// Clean up 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 

Target Platforms

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

Leadtools.Codecs Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.