LEADTOOLS Image File Support (Leadtools.Codecs assembly)

LoadCmykPlanes(String,Int32,Int32) Method

Show in webframe
Example 







A System.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.
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
public RasterImage LoadCmykPlanes( 
   string fileName,
   int bitsPerPixel,
   int page
)
'Declaration
 
Public Overloads Function LoadCmykPlanes( _
   ByVal fileName As String, _
   ByVal bitsPerPixel As Integer, _
   ByVal page As Integer _
) As RasterImage
'Usage
 
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)
public RasterImage LoadCmykPlanes( 
   string fileName,
   int bitsPerPixel,
   int page
)

            

            
 function Leadtools.Codecs.RasterCodecs.LoadCmykPlanes(String,Int32,Int32)( 
   fileName ,
   bitsPerPixel ,
   page 
)
public:
RasterImage^ LoadCmykPlanes( 
   String^ fileName,
   int bitsPerPixel,
   int page
) 

Parameters

fileName
A System.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:
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.
page
1-based index of the page from which the planes should be loaded.

Return Value

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

If the data does not have to be loaded as CMYK, use Load(String) or LoadAsync(String,LeadRect,Int32,CodecsLoadByteOrder,Int32,Int32,Object).

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 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 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(String) or LoadAsync(String,LeadRect,Int32,CodecsLoadByteOrder,Int32,Int32,Object) method and then use ColorSeparateCommand and RasterImage.CreateAlphaImage method.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Drawing

Private Sub CmykPlanesExample(ByVal cmykTifFile As String)
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "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()
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;

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

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
RasterCodecsExamples.prototype.CmykPlanesExample = function () {
   Tools.SetLicense();
   with (Leadtools) {
      with (Leadtools.Codecs) {
         var cmykTifFile = "Assets\\Cmyktif.tif";
         var codecs = new RasterCodecs();

         var destFileName = "CmykPlanesTif.tif";
         var cmykImage;
         // Load the CMYK Planes of this image
         return Tools.AppInstallFolder().getFileAsync(cmykTifFile).then(function (loadFile) {
            return codecs.loadCmykPlanesAsync(LeadStreamFactory.create(loadFile), 8, 1)
         })
            .then(function (cmykImg) {
               cmykImage = cmykImg;
               console.info("CMYK planes loaded into an image with " + cmykImage.pageCount + " pages");
               console.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.info("Changing the intensity of the K plane (the 4th page)");
               var command = new Leadtools.ImageProcessing.Color.ChangeIntensityCommand();
               command.brightness = 500;
               cmykImage.Page = 4;
               command.run(cmykImage);
               cmykImage.page = 1;

               console.info("Saving the image to the destination file");
               return Tools.AppLocalFolder().createFileAsync(destFileName)
            })
            .then(function (saveFile) {
               return codecs.saveCmykPlanesAsync(cmykImage, LeadStreamFactory.create(saveFile), RasterImageFormat.tifLzwCmyk, 8, 1, CodecsSavePageMode.overwrite)
            })
            .then(function () {
               cmykImage.close();

               // Clean up
               codecs.close();
            });
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;

      
async Task CmykPlanesExample(string cmykTifFile)
{
   RasterCodecs codecs = new RasterCodecs();
   string destFileName = "CmykPlanesTif.tif";

   // Load the CMYK Planes of this image
   IStorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(cmykTifFile);
   RasterImage cmykImage = await codecs.LoadCmykPlanesAsync(LeadStreamFactory.Create(loadFile), 8, 1);

   Debug.WriteLine("CMYK planes loaded into an image with {0} pages", cmykImage.PageCount);
   Assert.IsTrue(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!

   Debug.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;

   Debug.WriteLine("Saving the image to the destination file");
   IStorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName);
   await codecs.SaveCmykPlanesAsync(cmykImage, LeadStreamFactory.Create(saveFile), RasterImageFormat.TifLzwCmyk, 8, 1, CodecsSavePageMode.Overwrite);
   cmykImage.Dispose();

   // Clean up
   codecs.Dispose();
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Examples;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Windows.Media;

void CmykPlanesExample(Stream inStreamCmykTif, Stream outStreamTifLzwCmyk)
{
   RasterCodecs codecs = new RasterCodecs();
   // Load the CMYK Planes of this image
   RasterImage cmykImage = codecs.LoadCmykPlanes(inStreamCmykTif, 8, 1);

   Debug.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!

   Debug.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;

   Debug.WriteLine("Saving the image to the destination file");
   codecs.SaveCmykPlanes(cmykImage, outStreamTifLzwCmyk, RasterImageFormat.TifLzwCmyk, 8, 1, CodecsSavePageMode.Overwrite);
   cmykImage.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media

Private Sub CmykPlanesExample(ByVal inStreamCmykTif As Stream, ByVal outStreamTifLzwCmyk As Stream)
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' Load the CMYK Planes of this image
   Dim cmykImage As RasterImage = codecs.LoadCmykPlanes(inStreamCmykTif, 8, 1)

   Debug.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!

   Debug.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

   Debug.WriteLine("Saving the image to the destination file")
   codecs.SaveCmykPlanes(cmykImage, outStreamTifLzwCmyk, RasterImageFormat.TifLzwCmyk, 8, 1, CodecsSavePageMode.Overwrite)
   cmykImage.Dispose()
End Sub
Requirements

Target Platforms

See Also

Reference

RasterCodecs Class
RasterCodecs Members
Overload List
Handling CMYK Files as Separate Images

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.