Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
LoadCmykPlanes Method
See Also  Example
Leadtools.Codecs Namespace > RasterCodecs Class : LoadCmykPlanes Method



fileName
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.
bitsPerPixel
Resulting image pixel depth. Possible values are:
ValueMeaning
8Each plane will be a grayscale 8 bis per pixel image.
16Each plane will be a grayscale 16 bits per pixel image.
page
1-based index of the page from which the planes should be loaded.
Loads CMYK TIFF files as CMYK and avoids the colorspace conversion to RGB.

Syntax

Visual Basic (Declaration) 
Public Function LoadCmykPlanes( _
   ByVal fileName As String, _
   ByVal bitsPerPixel As Integer, _
   ByVal page As Integer _
) As RasterImage
Visual Basic (Usage)Copy Code
Dim instance As RasterCodecs
Dim fileName As String
Dim bitsPerPixel As Integer
Dim page As Integer
Dim value As RasterImage
 
value = instance.LoadCmykPlanes(fileName, bitsPerPixel, page)
C# 
public RasterImage LoadCmykPlanes( 
   string fileName,
   int bitsPerPixel,
   int page
)
C++/CLI 
public:
RasterImage LoadCmykPlanes( 
   String^ fileName,
   int bitsPerPixel,
   int page
) 

Parameters

fileName
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.
bitsPerPixel
Resulting image pixel depth. Possible values are:
ValueMeaning
8Each plane will be a grayscale 8 bis per pixel image.
16Each plane will be a grayscale 16 bits per pixel image.
page
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.

Example

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

Visual BasicCopy Code
Private Sub CmykPlanesExample(ByVal cmykTifFile As String)
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim destFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "CmykPlanesTif.tif"

   ' Load the CMYK Planes of this image
   Dim cmykImage As RasterImage = 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)")
   Dim command As ChangeIntensityCommand = New ChangeIntensityCommand()
   command.Brightness = 500
   cmykImage.Page = 4
   command.Run(cmykImage)
   cmykImage.Page = 1

   Console.WriteLine("Saving the image to the destination file")
   codecs.SaveCmykPlanes(cmykImage, destFileName, RasterImageFormat.TifLzwCmyk, 8, 1, CodecsSavePageMode.Overwrite)
   cmykImage.Dispose()

   ' Clean up
   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
void CmykPlanesExample(string cmykTifFile) 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   string destFileName = LeadtoolsExamples.Common.ImagesPath.Path + "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; 
   command.Run(cmykImage); 
   cmykImage.Page = 1; 
 
   Console.WriteLine("Saving the image to the destination file"); 
   codecs.SaveCmykPlanes(cmykImage, destFileName, RasterImageFormat.TifLzwCmyk, 8, 1, CodecsSavePageMode.Overwrite); 
   cmykImage.Dispose(); 
 
   // Clean up 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Remarks

If the data does not have to be loaded as CMYK, use RasterCodecs.Load(String).

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

This method uses the values of RasterCodecs.Options.Load.AllocateImage, RasterCodecs.Options.Load.StoreDataInImage and RasterCodecs.Options.Load.SuperCompressed.

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 RasterImage.PaintCmykPlanes to display the array and SaveCmykArray to save an image as a CMYK TIFF 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 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 method and then use ColorSeparateCommand and RasterImage.CreateAlphaImage method.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also