PDFiumVCL Docs

Bitmap property

この API エントリでは識別子、シグネチャ、コードブロック、PDF 用語を元の表記のまま保持します。
Component: TPdf  ·  Unit: PDFium
Returns a freshly-decoded VCL TBitmap holding the raster data of the specified image object on the current page. The bitmap is newly allocated on each call; the caller owns it and is responsible for calling Free.

Syntax

property Bitmap[Index: Integer]: TBitmap; // read only

IndexZero-based image index on the current page, in the range 0 to BitmapCount - 1.

Description

Bitmap returns a TBitmap containing the pixel data of the n-th raster image on the current page. PDFium decodes the underlying stream (JPEG, JPEG2000, CCITT, JBIG2, or FlateDecode pixel data) and PDFiumVCL converts the result into a VCL TBitmap at the image's stored resolution, with alpha preserved as a 32-bit ARGB surface where the source provides a soft mask.

Every call allocates a fresh bitmap; the property does not cache. This makes the property safe to call from worker threads but means callers must always free the returned object, typically inside a try .. finally block.

When you also need the image's on-page transformation matrix and bounding rectangle use Image[Index] instead — it returns a record that bundles the same TBitmap with positional metadata. The shape-agnostic sibling ObjectBitmap[ObjectIndex] indexes into the full page-object array (mixed text, paths, images) and returns the same bitmap if the targeted object happens to be an image.

Remarks

Example

// Export every image on the current page as numbered BMP files
var
  I: Integer;
  Bmp: TBitmap;
begin
  for I := 0 to Pdf.BitmapCount - 1 do
  begin
    Bmp := Pdf.Bitmap[I];
    try
      Bmp.SaveToFile(Format('page_%d_img_%d.bmp', [Pdf.PageNumber, I]));
    finally
      Bmp.Free;
    end;
  end;
end;

See Also

BitmapCount, Image, ImageCount, ObjectBitmap