THotPDF.DecodeLoadedImageColorKeyMask Method
Builds the color-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 contains the color-key /Mask array |
Return value
24-bit grayscale bitmap matching the image dimensions where black marks pixels whose samples all fall inside their component ranges and white marks pixels with any component outside its range; nil when the image is not eligible
Usage notes
- Eligibility mirrors the PDF color-key masking rules: the image must be decodable, not an image mask, carry 1 to 4 color components, and own a /Mask array of 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 color 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 honors the configured decode byte budget, so hostile or oversized images fail cleanly instead of exhausting memory
- The caller owns the returned bitmap; combine it with
DecodeLoadedImageStreamto preview which regions the viewer will treat as masked