Loads TIFF or JPEG CMYK streams as CMYK and avoids the colorspace conversion to RGB.
public RasterImage LoadCmykPlanes(
Stream stream,
int bitsPerPixel,
int pageNumber
)
- (nullable LTRasterImage *)loadCmykPlanesFromStream:(LTLeadStream *)stream
bitsPerPixel:(NSInteger)bitsPerPixel
pageNumber:(NSInteger)pageNumber
error:(NSError **)error
public RasterImage loadCmykPlanes(ILeadStream stream, int bitsPerPixel, int pageNumber)
public:
RasterImage^ LoadCmykPlanes(
Stream^ stream,
int bitsPerPixel,
int pageNumber
)
def LoadCmykPlanes(self,stream,bitsPerPixel,pageNumber):
stream
A Stream containing the data of the image file to load. The image data must be CMYK; otherwise, the method will fail and throw an exception.
bitsPerPixel
Resulting image pixel depth. Possible values are:
Value | Meaning |
---|---|
0 | Each plane will have the same bits/pixel as the source file (8 or 16). |
8 | Each plane will be a grayscale 8 bits per pixel image. |
16 | Each plane will be a grayscale 16 bits per pixel image. This is not available for saving JPEG CMYK files. |
pageNumber
1-based index of the page from which the planes should be loaded.
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 have to 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, the alpha channel(s) will be loaded as well. First alpha channel will be stored as page 5, second alpha as plane 6, etc.
Use RasterImagePainter.PaintCmykPlanes to display the array and SaveCmykPlanes to save an image as a CMYK TIFF or JPEG file.
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:
If an alpha image is available and a BGR image is generated using ColorMergeCommand, use RasterImage.SetAlphaImage to add the alpha image to the result of ColorMergeCommand.
If the BGR image is generated using RasterColorConverterEngine.ConvertCmykPlanes, the alpha image will be added automatically.
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 planes, use the normal Load or LoadAsync methods and then use the ColorSeparateCommand and RasterImage.CreateAlphaImage methods.
import java.io.*;
import java.net.*;
import java.nio.file.Paths;
import java.util.*;
import java.time.Instant;
import java.time.Duration;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.codecs.*;
import leadtools.codecs.RasterCodecs.FeedCallbackThunk;
import leadtools.drawing.internal.*;
import leadtools.imageprocessing.*;
import leadtools.imageprocessing.color.ChangeIntensityCommand;
import leadtools.svg.*;
public void cmykPlanesExample() {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
ILeadStream cmykTifFile = LeadStreamFactory.create(combine(LEAD_VARS_IMAGES_DIR, "cmykTifFile.tif"));
ILeadStream destFileName = LeadStreamFactory.create(combine(LEAD_VARS_IMAGES_DIR, "CmykPlanesTif.tif"));
RasterCodecs codecs = new RasterCodecs();
// Load the CMYK Planes of this image
RasterImage cmykImage = codecs.loadCmykPlanes(cmykTifFile, 8, 1);
System.out.printf("CMYK planes loaded into an image with %s pages", cmykImage.getPageCount());
assertTrue(cmykImage.getPageCount() == 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!
System.out.printf("Changing the intensity of the K plane (the 4th page)");
ChangeIntensityCommand command = new ChangeIntensityCommand();
command.setBrightness(500);
cmykImage.setPage(4);
command.run(cmykImage);
cmykImage.setPage(1);
System.out.println("Saving the image to the destination file");
codecs.saveCmykPlanes(cmykImage, destFileName, RasterImageFormat.TIFLZW_CMYK, 8, 1, CodecsSavePageMode.OVERWRITE);
cmykImage.dispose();
// Clean up
codecs.dispose();
}
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);
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, destFileName, RasterImageFormat.TifLzwCmyk, 8, 1, CodecsSavePageMode.Overwrite);
cmykImage.Dispose();
// Clean up
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\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