function RenderPageBandedToStream(Stream: TStream; Width,
Height: Integer; const StreamOptions: TPdfBandedImageStreamOptions;
Rotation: TRotation = ro0; Options: TRenderOptions = [];
Color: TColor = clWhite): TPdfBandedImageReport;
| Stream | TStream。呼叫端擁有的可寫入輸出,位置應位於影像開始處 |
| StreamOptions.Format | pbifPng 表示壓縮的 8 位元 RGB PNG,pbifTiff 表示未壓縮、低位元組序的傳統 TIFF 條帶 |
| StreamOptions.BandHeight | 正的條帶與 TIFF strip 高度;預設為 256 列 |
| StreamOptions.CompressionLevel | PNG zlib 等級,0 到 9;預設為 6,TIFF 會忽略 |
| StreamOptions.MaxOutputBytes | 硬性編碼位元組上限;零表示無限制 |
| Rotation | TRotation。套用到頁面的顯示旋轉 |
| Options | TRenderOptions。算繪旗標 |
| Color | TColor。算繪前套用到每個條帶的背景填色 |
| Result | TPdfBandedImageReport。條帶數、已編碼列數、尖峰條帶位元組數、輸出位元組數、完成旗標與選定的格式 |
此方法會以要求的內建編碼器 TPdfPngBandedImageEncoder 或 TPdfTiffBandedImageEncoder 包裹串流,並驅動 RenderPageBandedToEncoder 共用的分條帶管線。傳回的報告攜帶選定的 Format,而不是 pbifCustom
PNG 編碼器會將每條掃描線直接壓縮成連續的 IDAT 區塊,TIFF 編碼器則為每個算繪條帶寫出一個 RGB strip,並在像素資料之後附加其影像檔案目錄。兩個編碼器都只向前寫入,絕不會移動呼叫端串流的位置
頁面像素的尖峰儲存量是一個 Width x BandHeight 的 BGRA 點陣圖,而不是 Width x Height。報告會公開實測的 PeakBandBytes,讓匯出工具能夠稽核記憶體原則,OutputBytes 則反映實際寫入串流的資料量
在覆寫個別限制之前,請先使用 TPdfBandedImageStreamOptions.Default(pbifPng) 或 Default(pbifTiff);預設值為 BandHeight = 256、CompressionLevel = 6 與 MaxOutputBytes = 0
nil 串流、非正數的 BandHeight 或負數的 MaxOutputBytes 會引發 EPdfError;pbifCustom 會被拒絕,因為必須使用內建的 PNG 或 TIFF 格式
當編碼後的影像會超出 MaxOutputBytes 時,寫入會引發 EPdfError,訊息為 Encoded image exceeds the output byte budget
若需其他容器格式或外部編解碼器,請使用 RenderPageBandedToEncoder 搭配自訂的 TPdfBandedImageEncoder 子代
StreamOptions := TPdfBandedImageStreamOptions.Default(pbifTiff);
StreamOptions.BandHeight := 256;
StreamOptions.MaxOutputBytes := Int64(512) * 1024 * 1024;
Report := Pdf.RenderPageBandedToStream(OutputStream, 4960, 7016,
StreamOptions);
if not Report.Completed then
RaiseBandedExportIncomplete;