PDFium Delphi Component Docs

Optional LittleCMS 2 ICC transform provider

CreatePdfLittleCmsColourTransform implements IPdfColourTransform for original Gray, RGB, CMYK and ICCBased component buffers and the document color conversion helper

Supply an explicit absolute library path whose architecture matches the process; the native library must expose the LittleCMS 2 cdecl API, and the supplied build helper produces that ABI from the MIT-licensed LittleCMS 2.19 source

A DLL using the Microsoft stdcall build configuration is incompatible with the Win32 provider; calling conventions cannot be inferred reliably from undecorated exported names

TryCreatePdfLittleCmsColourTransform returns dependency diagnostics and leaves the transform nil on failure without changing the process search path

Each call owns its native context, profiles and transform; the provider can be shared, but callers must keep their sample buffers immutable for the duration of a call

Buffers contain tightly packed whole pixels with 1, 3 or 4 components and 8-bit bytes or 16-bit unsigned words in native byte order; PDF big-endian image samples are converted by the document helper before invoking this provider

Unprofiled DeviceRGB uses sRGB and unprofiled DeviceGray uses a D50 gamma-2.2 profile; DeviceCMYK and ICCBased require an explicit source ICC profile, and every profile data color space must match its declared component count

Targets are DeviceGray, DeviceRGB or DeviceCMYK with a matching ICC profile; an omitted target profile is supported only for the provider's Gray and RGB defaults

Default selects relative colorimetric intent, black point compensation, 256 MiB of sample bytes and 16 MiB of ICC profile bytes; the profile limit is capped at 16 MiB

Cancellation is checked before and after native setup and between blocks of at most 65,536 pixels; native profile opening and an individual transform block have no cancellation callback

Failed transforms clear the target buffer and raise EPdfColourBackendError; cancellation preserves EPdfOperationCancelled

Real LittleCMS 2.19 transforms and PDF save/reopen/render fixtures are verified with Delphi and FPC on Win32 and Win64

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 accepts a finite gamma from 0.1 through 10; both profile helpers serialize genuine native ICC profiles for embedding or reuse

Build the optional native library

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

The helper requires a compatible MinGW GCC installation and an existing LittleCMS 2.19 source checkout, copies applicable native license notices into the output directory and does not download or install dependencies