API referenceGraphics

pdfSetColorMask

Set a /Mask color-key range ([min1 max1 min2 max2 ...]) on

C
BOOL32 __stdcall pdfSetColorMask(PPDF IPDF, uint32_t ImageHandle, int32_t* Mask, uint32_t Count);
Delphi
function pdfSetColorMask(const IPDF: PPDF; ImageHandle: Cardinal; Mask: PInteger; Count: Cardinal): LongBool; stdcall;

Purpose. Set a /Mask color-key range ([min1 max1 min2 max2 ...]) on an already-inserted image, making pixels whose component values fall inside the given per-component ranges transparent.

Description. Locates the image by ImageHandle in the document's image list; requires Count to be exactly 2 * NumComps for that image (two values — a min and a max — per color component; e.g. 6 values for an RGB image), rejecting an empty or mismatched-length array outright with no partial application. On success, copies the Count integers verbatim into the image entry's ColorMask field, which is consulted at image-serialization time to emit the PDF /Mask color-key array on that image's XObject dictionary.

Parameters.

ParameterDescription
IPDFDocument handle.
ImageHandleHandle of a previously-inserted image.
MaskCount integers: [Comp1Min, Comp1Max, Comp2Min, Comp2Max, ...].
CountMust equal exactly 2 * (the image's component count); any other length fails.

Return value. True if ImageHandle was found and Count matched 2 * NumComps; False otherwise.

See also. pdfSetTransparentColor (a different, document-global transparency mechanism — not per-image).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Graphics
Category

Setters

Exported names

pdfSetColorMask

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.