AddImageDirectFromString
影像處理
描述
直接以已編碼的影像取樣位元組建立影像 XObject,不必偵測 PNG、TIFF 或 JPEG 之類的容器格式
PDF 版本行為:JBIG2Decode 影像 filter 需要 PDF 1.4;JPXDecode、Crypt 與 BitsPerComponent = 16 的影像取樣則需要 PDF 1.5。文件版本低於所需版本且儲存版本未鎖定時,AddImageDirectFromString 會自動提升文件版本,並在 AutoBumpedFeatures 記下 JBIG2Decode filter、JPXDecode filter、Crypt filter 或 16-bit image samples;呼叫端鎖定了較低的儲存版本時,相容性閘門會以 LastErrorCode 602 拒絕儲存。
語法
Delphi
Function TPDFlib.AddImageDirectFromString(Const Source: AnsiString; Width, Height, BitsPerComponent: Integer; Const ColorSpace, Filter, Decode: WideString; Interpolate: Integer): Integer;
參數
| Source | 要存入影像串流的原始或已編碼影像資料。 |
|---|---|
| Width | Image width in pixels. |
| Height | Image height in pixels. |
| BitsPerComponent | 每取樣成分的位元數。較早版本的 PDF 影像字典允許 1、2、4 與 8;16 位元取樣屬 PDF 1.5。 |
| ColorSpace | 影像字典用的 PDF 色彩空間名稱或陣列文字,例如 /DeviceGray、/DeviceRGB 或索引式色彩空間陣列。 |
| Filter | PDF 串流 filter 名稱,例如 FlateDecode、DCTDecode 或 JPXDecode。未過濾資料請用空字串。 |
| Decode | 選配的 PDF Decode 陣列文字。不需要 Decode 項目時傳入空字串。 |
| Interpolate | 非零寫出 /Interpolate true 旗標。 |
傳回值
| 0 | 無法建立影像,或目前 PDF/A 模式禁止所要求的 filter。 |
|---|---|
| Non-zero | 新的 ImageID。建立的影像會被選取,供後續影像操作使用。 |
備註
PDF/A 模式在所有部分都拒絕 LZWDecode,PDF/A-1 還拒絕 JBIG2Decode / JPXDecode。把 Source 位元組與宣告的 ColorSpace、Filter、Decode、尺寸與取樣深度對上,是呼叫端的責任。
另見
AddImageFromString, AddImageFromFile, AddImageFromStream, DrawImage