PDFium Delphi Component 文件

Bitmap 屬性

元件: TPdf  ·  單元: PDFium
傳回一個新解碼的 VCL TBitmap,其中包含目前頁面指定影像物件的光柵資料。每次呼叫都會新配置點陣圖;呼叫端擁有該物件並負責呼叫 Free

Syntax

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

Index目前頁面上以 0 為基底的影像索引,範圍 0 到 BitmapCount - 1

Description

Bitmap 傳回包含目前頁面第 n 個點陣影像像素資料的 TBitmap。PDFium 會解碼底層串流(JPEG、JPEG2000、CCITT、JBIG2 或 FlateDecode 像素資料),PDFium Delphi Component 再將結果轉換為以影像儲存解析度呈現的 VCL TBitmap;當來源提供軟式遮罩時,alpha 會以 32 位元 ARGB 表面保留

每次呼叫都會配置新的點陣圖;此屬性不做快取。這讓此屬性可安全地從工作執行緒呼叫,但也表示呼叫端必須一律釋放傳回的物件,通常是在 try .. finally 區塊內

若還需要影像在頁面上的變換矩陣與週框矩形,請改用 Image[Index] — 它會傳回將相同 TBitmap 與位置中繼資料打包在一起的記錄。與形狀無關的兄弟成員 ObjectBitmap[ObjectIndex] 則索引完整的頁面物件陣列(混合文字、路徑、影像),若目標物件恰好是影像,會傳回相同的點陣圖

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