THotPDF.RegisterDeviceN Method

 

THotPDF.RegisterDeviceN

THotPDF

 

傳回頂部

宣告一個 PDF 1.3+ 的 DeviceN 色彩空間,由 N 個由呼叫端提供的特別色油墨支撐(ISO 32000-1 8.6.6.5)。它把 RegisterSeparation 從單一色料推廣到任意多個:六色印刷、金屬 / 螢光油墨、自訂 PDF/X 油墨配方,以及任意 N 通道油墨組。

Delphi 語法:

function RegisterDeviceN(const ColorantNames: array of AnsiString; const AlternateCS: AnsiString; const TintC1Matrix: array of Extended): AnsiString;

 

C++ 語法:

AnsiString RegisterDeviceN(const AnsiString* ColorantNames, int ColorantNameCount, const AnsiString& AlternateCS, const Extended* TintC1Matrix, int TintC1MatrixCount);

 

說明

DeviceN 接收 N 個落在 [0..1] 的 tint 運算元,每個色料一個,並以 HotPDF 內部建構、作為 PostScript 計算器 Function Type 4 的線性加權混合 tint 轉換,在 AlternateCS 中算出 M 個輸出分量。通道 m 的輸出是所有色料 n 的 tint[n] * TintC1Matrix[n*M + m] 之和,由轉譯管線限制在 [0..1]。轉譯端對 N 的上限就是 HPDFRenderColorSpace 裡的共用常數 HPDFMaxColorants,即 ISO 32000-1 附錄 C 規定的 32 個色料,已載入頁面轉譯、連續調與 Indexed 影像解碼、色彩鍵遮罩以及 shading 都照這個上限端到端處理

ColorantNames - N 個油墨名稱的陣列。每個項目都寫成 PDF 名稱;空格依 PDF 1.7 7.3.5 轉義為 #20。特殊名稱 'None' 標記未使用的色料槽。名稱清單定義了結果色彩空間的 N 個輸入維度。

AlternateCS - 'DeviceGray'(M = 1)、'DeviceRGB'(M = 3)或 'DeviceCMYK'(M = 4)。其他取值都會擲回例外。

TintC1Matrix - 以列優先排列的 N * M Extended 陣列。第 n 列第 m 行是色料 n 在滿強度(tint[n] = 1.0)、其餘 tint 全為零時,對 AlternateCS 通道 m 的貢獻。長度必須正好等於 Length(ColorantNames) * M。

傳回值: 自動產生的名稱(DevN1、DevN2 ...)。當 StrictVersionLock 開啟且目前的 Version 低於 PDF 1.3 時傳回空字串,否則文件版本會自動升到 1.3。

 

程式碼範例

// Two-colorant DeviceN over DeviceRGB. Colorant 0 ('Red') is pure
// red at full strength, colorant 1 ('Blue') is pure blue. Mixing
// (0.5, 0.5) yields a 50/50 blend; (1, 1) saturates to magenta
var
  CSName: AnsiString;
  Mat: array[0..5] of Extended;
begin
  HPDF.Version := pdf14;
  HPDF.BeginDoc;
  Mat[0] := 1.0; Mat[1] := 0.0; Mat[2] := 0.0;  // Red row     -> (1, 0, 0)
  Mat[3] := 0.0; Mat[4] := 0.0; Mat[5] := 1.0;  // Blue row    -> (0, 0, 1)
  CSName := HPDF.RegisterDeviceN(
    ['Red', 'Blue'], 'DeviceRGB', Mat);
  HPDF.CurrentPage.SetFillColorSpace(CSName);
  HPDF.CurrentPage.SetFillColor([0.5, 0.5]);   // mid-purple
  HPDF.CurrentPage.Rectangle(60, 60, 200, 100);
  HPDF.CurrentPage.Fill;
  HPDF.EndDoc;
end;

 

請參閱

RegisterSeparation, RegisterLabColorSpace, Version, PDF 篩選器支援