function RenderPageBandedToEncoder(Width, Height, BandHeight: Integer;
Encoder: TPdfBandedImageEncoder; Rotation: TRotation = ro0;
Options: TRenderOptions = []; Color: TColor = clWhite): TPdfBandedImageReport;
| Width, Height | Integer。整頁影像的像素尺寸,如同一次算繪完成時的尺寸 |
| BandHeight | Integer。每個條帶的像素高度;當 Height 不是它的倍數時,最後一個條帶會較短 |
| Encoder | TPdfBandedImageEncoder。呼叫端擁有的編碼器執行個體,接收條帶串流 |
| Rotation | TRotation。套用到頁面的顯示旋轉:ro0、ro90、ro180 或 ro270 |
| Options | TRenderOptions。算繪旗標 |
| Color | TColor。算繪前套用到每個條帶的背景填色 |
| Result | TPdfBandedImageReport。條帶數、已編碼列數、尖峰條帶位元組數、輸出位元組數與完成旗標 |
此方法驅動與 RenderPageBanded 相同的分條帶迴圈,但不是使用應用程式回呼,而是把每個剛算繪好的 Width x 條帶高度點陣圖,透過內部橋接推入呼叫端提供之編碼器的三個虛擬方法:BeginImage(Width, Height) 最先執行,WriteBand(BandIndex, BandTopY, Bitmap) 自上而下為每個條帶呼叫一次,EndImage(Completed) 則關閉影像
BandIndex 以零為基底,BandTopY 是條帶頂端在整頁像素中的 y 位移,這正是 strip 寫出器把各列放進輸出檔案所需的資訊。點陣圖屬於算繪迴圈,會在 WriteBand 傳回後立即釋放,因此需要保留像素的編碼器必須自行複製
WriteBand 傳回 True 繼續,或傳回 False 乾淨地取消其餘條帶。只有當每個要求的列都已編碼時才會呼叫 EndImage(True);已取消或失敗的執行會收到 EndImage(False),且該失敗路徑上的例外會被抑制
傳回的報告攜帶 Format = pbifCustom、在 BandsRendered 與 BandsEncoded 中的已算繪與已接受條帶數、在 RowsEncoded 中的已接受列數、在 PeakBandBytes 中以 Width x 條帶高度 x 4 位元組計的最大條帶點陣圖、在 OutputBytes 中的 Encoder.GetBytesWritten 值,並且只在 RowsEncoded = Height 時 Completed = True
頁面像素的尖峰儲存量維持在單一條帶點陣圖,因此海報與工程圖能以列印解析度匯出,而不需要配置完整的目的地影像
傳入 nil 編碼器、非正數的尺寸或非正數的條帶高度,會引發 EPdfError
Width 與 Min(BandHeight, Height) 的乘積必須保持在可定址 Integer 範圍的四分之一以內,否則 EPdfError 會回報條帶緩衝區超出可定址大小
在編碼器子代中覆寫 GetBytesWritten,以將編碼器特定的輸出遙測資訊回報到 OutputBytes;基礎實作傳回 0
type
TRawStripEncoder = class(TPdfBandedImageEncoder)
public
procedure BeginImage(Width, Height: Integer); override;
function WriteBand(BandIndex, BandTopY: Integer;
Bitmap: TBitmap): Boolean; override;
procedure EndImage(Completed: Boolean); override;
end;
Encoder := TRawStripEncoder.Create;
try
Report := Pdf.RenderPageBandedToEncoder(4960, 7016, 512, Encoder);
LogBandedExport(Report.BandsEncoded, Report.PeakBandBytes);
finally
Encoder.Free;
end;