PDFium Delphi Component Docs

Optional LittleCMS 2 ICC transformation backend

CreatePdfLittleCmsColourTransform implements IPdfColourTransform for buffers of original Gray, RGB, CMYK and ICCBased components, including those supplied by the document colour-conversion helper

Give the absolute path of a library built for the process architecture; it must export the LittleCMS 2 cdecl API, which the supplied build helper produces from the MIT-licensed LittleCMS 2.19 source

A DLL built with Microsoft's stdcall configuration cannot be used by the Win32 provider; undecorated export names are insufficient to establish the calling convention

On failure, TryCreatePdfLittleCmsColourTransform returns dependency diagnostics with a nil transform and leaves the process search path as it was

Calls own their native contexts, profiles and transforms individually; sharing the provider is supported, provided sample buffers remain unchanged throughout each call

Sample buffers pack complete pixels without gaps, using 1, 3 or 4 components as 8-bit bytes or native-endian 16-bit unsigned words; the document helper converts PDF big-endian image samples before passing them here

DeviceRGB without a profile uses sRGB, and unprofiled DeviceGray uses a D50 gamma-2.2 profile; DeviceCMYK and ICCBased need an explicit source ICC profile, whose data colour space must agree with its declared component count

The destination must be DeviceGray, DeviceRGB or DeviceCMYK with a corresponding ICC profile; leaving out that profile is supported only for the provider's default Gray and RGB spaces

Default uses relative colorimetric intent and black point compensation, allowing 256 MiB of sample data and 16 MiB of ICC profile data; the latter allowance cannot exceed 16 MiB

Cancellation is tested around native setup and between blocks containing at most 65,536 pixels; native profile opening and a single transformation block offer no cancellation callback

A failed transformation empties the destination buffer and raises EPdfColourBackendError; cancellation continues to raise EPdfOperationCancelled

Delphi and FPC Win32/Win64 tests verify real LittleCMS 2.19 transformations alongside PDF saving, reopening and rendering

Public declarations

type
  EPdfColourBackendError = class(EPdfProduction);
  TPdfLittleCmsOptions = record
    RenderingIntent: Cardinal;
    BlackPointCompensation: Boolean;
    MaxSampleBytes: Integer;
    MaxProfileBytes: Integer;
    CancellationToken: IPdfCancellationToken;
    class function Default: TPdfLittleCmsOptions; static;
  end;

function CreatePdfLittleCmsColourTransform(const LibraryPath: string;
  const Options: TPdfLittleCmsOptions): IPdfColourTransform;
function TryCreatePdfLittleCmsColourTransform(const LibraryPath: string;
  const Options: TPdfLittleCmsOptions; out Transform: IPdfColourTransform;
  out ErrorText: string): Boolean;
function CreatePdfLittleCmsGrayProfile(const LibraryPath: string;
  Gamma: Double = 2.2): TBytes;
function CreatePdfLittleCmsSrgbProfile(const LibraryPath: string): TBytes;

CreatePdfLittleCmsGrayProfile requires a finite gamma between 0.1 and 10; both profile helpers serialise real native ICC profiles suitable for embedding or reuse

Building the optional native library

pwsh Native/ColourLittleCms/Build-LittleCms.ps1 -SourceDirectory C:/deps/lcms2.19 -OutputDirectory C:/deps/lcms-bin -Platform Win64

The build helper needs compatible MinGW GCC and an existing LittleCMS 2.19 source checkout; it places the applicable native licence notices in the output directory without downloading or installing dependencies