PDFium Component Docs

Bitmap property

Component: TPdf  ·  Unit: PDFium
یک VCL TBitmap تازه‌رمزگشایی‌شده که دادهٔ raster object تصویر مشخص‌شده روی صفحهٔ جاری را در خود دارد برمی‌گرداند. bitmap در هر فراخوانی از نو تخصیص داده می‌شود؛ مالکیت آن با caller است و باید 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 PDFiumPas 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