DecodeModernImageToPNG

Image handling

Description

Decodes a modern image stream to a PNG image stream

A registered backend callback runs first; without one the native codec library renders the image, applies EXIF orientation when requested and preserves the embedded ICC profile

Syntax

Delphi

Function DecodeModernImageToPNG(InStream, OutPNG: TStream;
  ImageFormat: TPDFlibModernImageFormat;
  ApplyOrientation: Boolean= True): Boolean;

Parameters

InStreamStream holding the complete modern image; the position is saved and restored
OutPNGStream receiving the PNG bytes; with a backend callback it is reset to position 0 and sized to the output on success
ImageFormatFormat to decode, from DetermineModernImageFormat; mifUnknown fails immediately
ApplyOrientationApplies the stored orientation so the PNG is upright, on by default

Return values

FalseNo backend is registered and the codec module is missing or lacks the coder, the format is unknown, or the decode failed
TrueOutPNG holds a complete PNG image

Remarks

The AddModernImageFromStream family wraps this helper and embeds the PNG into the page; calling it directly is the way to pre-convert or inspect images without a TPDFlib instance

See also

DetermineModernImageFormat, RegisterModernImageDecoderBackend, AddModernImageFromStream, ModernImageCodecAvailable