THotPDF.DecodeLoadedImageColorKeyMask Method
Builds the colour-key mask bitmap for a loaded image whose dictionary carries an array /Mask entry
Declaration
function DecodeLoadedImageColorKeyMask(
AImageStream: THPDFStreamObject): TBitmap;
Unit
HPDFDoc
Parameters
| Name | Purpose |
|---|---|
AImageStream | Loaded image stream object whose dictionary holds the colour-key /Mask array |
Return value
A 24-bit greyscale bitmap of the image's dimensions in which black marks pixels whose samples all fall within their component ranges and white marks pixels with any component outside its range; nil when the image does not qualify
Usage notes
- Eligibility follows the PDF colour-key masking rules: the image must be decodable, must not be an image mask, must carry 1 to 4 colour components, and must own a /Mask array with 2 values per component
- The ranges are compared with the samples as stored, before
/Decode; for an Indexed image that is the palette index, so two entries of the same colour can be masked differently - DCTDecode, JPXDecode, JBIG2Decode and CCITT-encoded streams return nil: lossy codecs do not keep exact sample values
RenderLoadedPageToBitmapandBuildLoadedPageSVGapply this mask when they draw the image- Decoding respects the configured decode byte budget, so hostile or oversized images fail cleanly rather than exhausting memory
- The caller owns the returned bitmap; use it alongside
DecodeLoadedImageStreamto preview which regions the viewer will treat as masked