property Bitmap[Index: Integer]: TBitmap; // read only
| Index | Zero-based image index on the current page, in the range 0 to BitmapCount - 1. |
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.
nil when Index is out of range or when the document is not active.
// 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;