THotPDF.DecodeLoadedImageRegionAtResolution Method

Decodes a source-coordinate rectangle while allowing the decoder to select a lower resolution level that still satisfies the requested output size

Declaration

function DecodeLoadedImageRegionAtResolution(
  AImageStream: THPDFStreamObject;
  RegionLeft, RegionTop, RegionRight, RegionBottom,
  TargetPixelWidth, TargetPixelHeight: Integer): TBitmap;

Unit

HPDFDoc

Parameters

NamePurpose
AImageStreamLoaded image XObject stream to decode
RegionLeftInclusive left source coordinate
RegionTopInclusive top source coordinate
RegionRightExclusive right source coordinate
RegionBottomExclusive bottom source coordinate
TargetPixelWidthMinimum useful decoded width before final rendering scale
TargetPixelHeightMinimum useful decoded height before final rendering scale

Return value

Returns a newly allocated bitmap for the clamped non-empty region, or nil when the image or requested geometry cannot be decoded

Resolution selection

Example

Preview := PDF.DecodeLoadedImageRegionAtResolution(
  ImageStream, 0, 0, SourceWidth, SourceHeight, 320, 200);
try
  Canvas.StretchDraw(TargetRect, Preview);
finally
  Preview.Free;
end;

Related APIs