THotPDF.AddImageWithSMask Metodo

Overload di comodita per il workflow comune "ho un PNG con alpha". TBitmap deve avere PixelFormat = pf32bit; HotPDF legge direttamente le righe BGRA ScanLine, le riordina in R G B per il piano colore e copia il byte A nel piano alpha prima di delegare al punto di ingresso raw AddImageWithSMask

 

Valore restituito: un indice in XImages identico a quello restituito da AddImage; passarlo a THPDFPage.ShowImage per posizionare l'immagine su una pagina. Restituisce -1 quando StrictVersionLock e attivo e la Version attiva e inferiore a PDF 1.4 (altrimenti la versione viene aggiornata automaticamente a 1.4)

 

Example 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