AddModernImageFromStream
Image handling, Modern image codecs, Streams
Description
Validates an AVIF, HEIF, HEIC, or JPEG XL stream, decodes its primary image in memory, and adds the result to the selected document
Syntax
Function TPDFlib.AddModernImageFromStream(
InStream: TStream;
Options: Integer= 8): Integer;
Parameters
| InStream | Seekable stream containing a complete supported image from offset 0 |
|---|---|
| Options | Import mode from 0 to 8, with 8 retaining image data, alpha, ICC, and up to 16-bit samples |
Option modes
| 0 | Image data with high bit depth |
|---|---|
| 1 | Alpha as a greyscale image with high bit depth |
| 2 | Image and alpha, forcing alpha to 8 bits |
| 3 | Image data forced to 8 bits |
| 4 | Alpha as a greyscale image forced to 8 bits |
| 5 | Image and alpha both forced to 8 bits |
| 6 | Image and alpha with high bit depth |
| 7 | Image and ICC with high bit depth |
| 8 | Image, alpha, and ICC with high bit depth |
Return values
Returns the new ImageID or 0 when validation or decoding fails
Remarks
The built-in dynamic backend performs no temporary-file round trip and retains the original ICC profile bytes when creating the PNG bridge
AddImageFromStream also auto-detects these formats, while this method rejects every other container before invoking the decoder
See also
AddModernImageFromFile, AddModernImageFromString, SetModernImageCodecLibrary