THotPDF.RegisterSeparationLUT Method

 

THotPDF.RegisterSeparationLUT

THotPDF

 

傳回頂部

宣告 PDF 1.3+ Separation color space(ISO 32000-1 8.6.6.4),其 tint transform 是 Function Type 0 sampled lookup table(ISO 32000-1 7.10.2)。當 spot-ink color curve 為非線性時使用此方法,例如 PANTONE Hexachrome-style tint ramps、gamma-corrected density curves、符合印刷特性的手繪 tone curves,以及不使用完整 ICC profile machinery 的 sRGB-to-spot conversion ICC LUTs。對於從 zero 到單一 full-strength color endpoint 的 simple linear ramp,仍使用 v2.45.0 RegisterSeparation entry point

 

Delphi 語法:

function RegisterSeparationLUT(const ColorantName: AnsiString; const AlternateCS: AnsiString; const Samples: array of byte): AnsiString;

 

C++ 語法:

AnsiString RegisterSeparationLUT(const AnsiString& ColorantName, const AnsiString& AlternateCS, const unsigned char* Samples, int SamplesCount);

 

說明

宣告 PDF 1.3+ Separation color space (ISO 32000-1 8.6.6.4),其 tint transform 是 Function Type 0 sampled lookup table (ISO 32000-1 7.10.2)。當 spot-ink color curve 為 non-linear 時使用此方法,例如 PANTONE Hexachrome-style tint ramps、gamma-corrected density curves、符合 press characterisation 的 hand-drawn tone curves,或沒有完整 ICC profile machinery 的 sRGB-to-spot conversion ICC LUTs。對於從零到單一 full-strength color endpoint 的簡單 linear ramp,仍可使用 v2.45.0 RegisterSeparation entry point/Domain [0 1]、涵蓋每個 alt-CS 通道於 [0, 1] 的 /Range、S = Length(Samples) / M 的 /Size [S]、/BitsPerSample 8 與 /Order 1(線性插值)。該函式會接進跨頁面共用的全新 [/Separation /ColorantName /AltCS <FuncRef>] 色彩空間陣列,布局與 RegisterSeparation 產生的一致 — 下游接 SetFillColorSpace + SetFillColor

 

ColorantName - PDF Name of the ink (e.g. 'PANTONE 185 C', 'CutContour', 'White'). Spaces are escaped to #20 per PDF 1.7 7.3.5 by the existing name-writer path.

AlternateCS - 'DeviceGray' (M = 1), 'DeviceRGB' (M = 3), or 'DeviceCMYK' (M = 4). The sample stream supplies M output bytes per grid point. Any other value raises an exception.

Samples - raw 8-bit sample bytes ordered (c0_0, c1_0, ..., cM-1_0, c0_1, ..., cM-1_S-1) for S grid points. Length(Samples) must be a positive multiple of M; S is inferred as Length(Samples) / M and must be at least 2 so the function has interpolable range. Linear interpolation between grid points is the default (PDF 1.7 /Order 1).

 

傳回值: 自動產生的 color-space name(Sep1、Sep2、...)。Separation entry 會與 v2.45.0 RegisterSeparation registry 共用,因此 names 會跨兩個 variants 單調遞增。當 StrictVersionLock 啟用且目前 Version 低於 PDF 1.3 時會傳回空字串;否則檔案版本會自動提升到 1.3Sep1、Sep2 ...)。Separation 項目與 v2.45.0 的 RegisterSeparation 登錄共用,名稱在兩個變體之間單調遞增。StrictVersionLock 生效時回傳空字串

 

Code Example

// Register a 'HeatLUT' Separation over DeviceRGB whose tint -> RGB
// curve is a 256-sample blue -> green -> red heatmap
var
  CSName: AnsiString;
  Samples: array[0..767] of byte;     // 256 * 3 RGB
  I: Integer;
  T: Single;
begin
  HPDF.BeginDoc;
  for I := 0 to 255 do
  begin
    T := I / 255.0;
    if T < 0.5 then
    begin
      Samples[I*3 + 0] := 0;
      Samples[I*3 + 1] := byte(Round(2.0 * T * 255.0));
      Samples[I*3 + 2] := byte(Round((1.0 - 2.0*T) * 255.0));
    end
    else
    begin
      Samples[I*3 + 0] := byte(Round(2.0 * (T - 0.5) * 255.0));
      Samples[I*3 + 1] := byte(Round((1.0 - 2.0*(T - 0.5)) * 255.0));
      Samples[I*3 + 2] := 0;
    end;
  end;
  CSName := HPDF.RegisterSeparationLUT('HeatLUT', 'DeviceRGB', Samples);
  HPDF.CurrentPage.SetFillColorSpace(CSName);
  HPDF.CurrentPage.SetFillColor([0.5]);    // midpoint -> pure green
  HPDF.CurrentPage.Rectangle(100, 100, 40, 40);
  HPDF.CurrentPage.Fill;
  HPDF.EndDoc;
end;

 

請參閱

RegisterSeparation, RegisterSampledFunction, RegisterDeviceN, Version, PDF 篩選器支援