THotPDF.AddImageWithSMask Metodo THotPDF.AddImageWithSMask Metodo THotPDF.AddImageWithSMask Metodo THotPDF.AddImageWithSMask Metodo THotPDF.AddImageWithSMask Metodo THotPDF.AddImageWithSMask Metodo THotPDF.AddImageWithSMask Metodo THotPDF.AddImageWithSMask Metodo

 

THotPDF.AddImageWithSMask

THotPDF

 

Top  Previous  Next

Aggiunge un Image XObject a colori insieme a un soft-mask image XObject PDF 1.4 (ISO 32000-1 8.9.5.4) così l'immagine risultante porta trasparenza completa per pixel invece del limite binario on/off del /ImageMask percorso.

 

Sintassi Delphi:

function AddImageWithSMask(Width, Height: Integer; const RGB: del campo di Byte; const Alfa: del campo di Byte): Integer;

function AddImageWithTransparency(Width, Height: Integer; const RGB: del campo di Byte; const Alfa: del campo di Byte): Integer;

function AddImageWithSMask32(Width, Height: Integer; const Pixel: del campo di Byte): Integer;

function AddImageWithTransparency32(Width, Height: Integer; const Pixel: del campo di Byte): Integer;

 

Sintassi C++:

int AddImageWithSMask(int Width, int Height, const TBytes& RGB, const TBytes& Alpha);

int AddImageWithTransparency(int Width, int Height, const TBytes& RGB, const TBytes& Alpha);

int AddImageWithSMask32(int Width, int Height, const TBytes& Pixels);

int AddImageWithTransparency32(int Width, int Height, const TBytes& Pixels);

 

Descrizione

Le immagini SMask portano un canale DeviceGray a 8 bit indipendente la cui luminosità pilota l'alfa dell'immagine a colori al momento della pittura (0 = completamente trasparente, 255 = completamente opaco). HotPDF emette entrambi i piani come Image XObject compressi Flate, collega il /SMask sull'XObject della soft mask, e restituisce un XImages che THPDFPage.ShowImage accetta direttamente - tutto il codice di piazzamento a valle funziona invariato.

AddImageWithTransparency e AddImageWithTransparency32 sono alias di denominazione dello stesso flusso di soft mask PDF 1.4. Sono forniti per i siti di chiamata che ragionano in termini di immagini trasparenti invece che di terminologia dei dizionari PDF

 

AddImageWithSMask(Width, Height, RGB, Alpha)

- Width / Height: dimensioni in pixel, identiche per entrambi i piani.

- RGB: Width * Height * 3 bytes, row-major top-down, R G B interleaved per pixel (no row padding).

- Alpha: Width * Height byte, row-major dall'alto in basso, 8 bit di luminosità per pixel.

 

AddImageWithSMask32(Width, Height, Pixels)

Overload di comodo per input RGBA compresso a 32 bit. Pixels deve contenere Width * Height * 4 byte in ordine R, G, B, A. HotPDF divide il buffer nel piano colore RGB e nel piano alfa a 8 bit prima di delegare a AddImageWithSMask

 

Valore restituito: un indice in XImages identico a quello che AddImage returns; pass it to THPDFPage.ShowImage to place the picture on a page. Returns -1 when StrictVersionLock è attivo e la Version is below PDF 1.4 (otherwise the version is auto-bumped to 1.4).

 

Esempio di codice

// Raw-bytes path: build a 64x64 magenta-on-white plane + horizontal
// alpha gradient and place the result on the page
var
  RGB, Alpha: TBytes;
  W, H, X, Y, Idx, ImIdx: Integer;
begin
  W := 64;
  H := 64;
  SetLength(RGB,   W * H * 3);
  SetLength(Alpha, W * H);
  for Y := 0 to H - 1 do
    for X := 0 to W - 1 do
    begin
      Idx := Y * W + X;
      RGB[Idx * 3 + 0] := 255;    // R
      RGB[Idx * 3 + 1] := 0;      // G
      RGB[Idx * 3 + 2] := 255;    // B
      Alpha[Idx]       := Byte((X * 255) div (W - 1));
    end;

  HPDF.Version    := pdf14;       // SMask requires PDF 1.4
  HPDF.Compression := cmFlateDecode;
  HPDF.BeginDoc;
  ImIdx := HPDF.AddImageWithSMask(W, H, RGB, Alpha);
  HPDF.CurrentPage.ShowImage(ImIdx, 80, 80, 256, 256, 0);
  HPDF.EndDoc;
end;

 

Vedi anche:

AddImage, THPDFPage.ShowImage, Version, Supporto dei filtri PDF