CompressImages

影像處理、文件屬性

描述

設定此呼叫之後加入文件的原始點陣影像資料預設套用的壓縮模式。此設定影響以未壓縮方式上傳像素的影像(BMP、原始像素陣列);已壓縮的影像(JPEG、JPEG 2000、CCITT、JBIG2)保持原編碼原樣儲存,因為重新壓縮只會讓檔案變大、品質下降

語法

Delphi

Function TPDFlib.CompressImages(Compress: Integer): Integer;

ActiveX

Function PDFlib::CompressImages(Compress As Long) As Long

DLL

int DLCompressImages(int InstanceID, int Compress);

參數

Compress0 — store raw raster images uncompressed.
1 — flate-compress raw raster images (/FlateDecode filter).

傳回值

0Compress 參數超出範圍。
1影像壓縮設定已更新。

備註

此設定只影響呼叫之後加入的影像。預設為壓縮。下游描繪器不支援 flate 解碼影像串流時,關閉壓縮偶爾有用;一般使用請保持壓縮開啟。

Flate 壓縮是無損的。要對原始點陣影像做有損的 JPEG 壓縮,請在加入前先把來源編碼成 JPEG,改用 AddImageFromFile 或 AddImageFromStream — JPEG 位元組串流會直接以 /DCTDecode 過濾器內嵌。

範例

// Compress raw bitmaps but leave the pre-encoded JPEG as-is
PDF.CompressImages(1);
PDF.AddImageFromFile('logo.bmp');        // BMP -> flate compressed
PDF.AddImageFromFile('photo.jpg');       // JPEG bytes embedded directly (DCT)
PDF.AddImageFromFile('chart.png');       // PNG decoded -> flate compressed

另見

CompressContent, CompressFonts, AddImageFromFile, AddImageFromStream