ICC component transforms
Color management
Description
TPDFICCComponentTransform in PDFlibICCComponents converts complete GRAY, RGB, CMYK, CMY, Lab, XYZ or N-channel (2CLR through FCLR) component tuples between compatible ICC profiles through an optional LittleCMS 2 runtime
Input and output components use the unit range 0 through 1, including all four CMYK components; the implementation converts CMYK, CMY and nCLR values with five or more channels to and from the CMM's percentage representation internally (two to four nCLR channels stay in the unit range), maps Lab components from 0 through 1 to L* 0 through 100 and a* and b* -128 through 127, and maps XYZ components to 0 through 1.99997
Each instance owns its library handle, CMM context, profiles and transform; use a separate instance per concurrent caller
Syntax
constructor TPDFICCComponentTransform.Create(
const SourceProfile, TargetProfile: AnsiString;
RenderingIntent: Integer = 1;
BlackPointCompensation: Boolean = False;
const LibraryFileName: AnsiString = '');
function TPDFICCComponentTransform.Transform(
const Samples: array of Double;
var Converted: TPLICCComponentValues): Boolean;
Parameters and status
| SourceProfile, TargetProfile | Raw ICC profile bytes; an empty value selects the CMM's standard sRGB profile |
|---|---|
| RenderingIntent | 0 for perceptual, 1 for relative colorimetric, 2 for saturation or 3 for absolute colorimetric |
| BlackPointCompensation | Requests the CMM's black-point compensation when constructing the transform |
| LibraryFileName | An optional explicit library path; defaults are liblcms2-2.dll on Windows, liblcms2.so.2 on Linux and liblcms2.2.dylib under the architecture-specific Homebrew prefix on macOS |
| Samples | Interleaved complete source tuples; finite values outside the unit range are clamped, and an empty input succeeds with an empty output |
| Converted | Interleaved destination tuples; in-place conversion may reuse the source variable, and failure clears this array |
| Valid, LastError | Check availability after construction and inspect the English diagnostic when construction or conversion fails |
| InputComponents, OutputComponents | The actual source and target channel counts, from 1 to 15 |
| BackendVersion | The encoded version returned by the loaded LittleCMS runtime |
Validation and limits
Nonempty profiles must have a complete header and tag-count field, the ICC signature and a declared size within the supplied bytes; each supplied profile is limited to 16 MiB
The CMM must accept both profiles and provide the requested conversion direction; unsupported component models, missing functions, unavailable libraries and invalid rendering intents leave Valid false
Combined caller-input and converted-output component storage is limited to 256 MiB before conversion; temporary CMM buffers process up to 4096 pixels at a time
Incomplete source tuples and NaN or infinity samples reject before conversion; these checks bound this wrapper's storage and do not certify every internal ICC transform tag or the CMM's internal allocation behavior
Native rendering integration
On native non-Windows targets, the existing TPDFICCTransform display path uses LittleCMS when available for sources with one to eight components, including two- and five-to-eight-channel nCLR profiles, sampled into its bounded display LUT; a GRAY, CMYK, CMY, Lab, XYZ or nCLR target profile is a proofing space, so colors are converted into it and then shown through sRGB
Missing native CMM support leaves that display transform invalid so the existing documented alternate-color-space path remains available; Windows display rendering uses its WCS implementation for one-, three- and four-component sources with an RGB target, and uses LittleCMS (liblcms2-2.dll) for two- and five-to-eight-component nCLR sources and for non-RGB proofing targets when the library can be loaded
PDF rendering starts with RelativeColorimetric intent and an unrecognized ri name retains the current intent
Windows transforms pass the selected rendering intent for both profiles so the destination does not fall back to its separate match intent
Intent clones retain the target profile, black-point compensation and component ranges; malformed declared destination lengths cannot read beyond the supplied profile bytes
Arbitrary four-component output conversion is available through TPDFICCComponentTransform; transparency-group component storage and blending require their own renderer support and are not implemented merely by constructing this converter
Example
program ConvertICCComponents;
uses SysUtils, PDFlibICCComponents;
var
Converter: TPDFICCComponentTransform;
Samples, Converted: TPLICCComponentValues;
begin
Converter := TPDFICCComponentTransform.Create('', '', 1, False);
try
if not Converter.Valid then
raise Exception.Create(string(Converter.LastError));
SetLength(Samples, 3);
Samples[0] := 0.2;
Samples[1] := 0.4;
Samples[2] := 0.6;
if not Converter.Transform(Samples, Converted) then
raise Exception.Create(string(Converter.LastError));
Writeln(Converted[0]:0:6, ' ', Converted[1]:0:6, ' ', Converted[2]:0:6);
finally
Converter.Free;
end;
end.