THotPDF.RegisterTensorProductPatchMesh Method

 

THotPDF.RegisterTensorProductPatchMesh

THotPDF

 

למעלה

מצהיר על tensor product patch mesh shading עבור PDF 1.3+ ‏(ISO 32000-1 8.7.4.5.7, ‏/ShadingType 7) ועוטף אותו ב-entry ‏Pattern Type 2 inline במילון Resources/Pattern של העמוד. כל patch הוא רשת מלאה של 4 x 4 נקודות בקרה bicubic Bezier ‏p[i][j] ‏(12 boundary + 4 interior) ועוד צבע אחד לכל פינה. השתמש בכך כאשר RegisterCoonsPatchMesh ‏(Type 6) אינו יכול לבטא את צורת הפנים, למשל round-trips של SVG mesh-gradient או יצירה שצריכה ארבע נקודות בקרה נוספות כדי לכופף את פנים ה-patch

 

Delphi syntax:

function RegisterTensorProductPatchMesh(XMin, YMin, XMax, YMax: Single; NumComponents: Integer; const Patches: array of Extended): AnsiString;

 

C++ syntax:

AnsiString RegisterTensorProductPatchMesh(float XMin, float YMin, float XMax, float YMax, int NumComponents, const Extended* Patches, int PatchesElementCount);

 

תיאור

ה-shading נפלט כ-stream indirect עם /ShadingType 7, ‏/BitsPerCoordinate 16, ‏/BitsPerComponent 8 ו-/BitsPerFlag 8. כל patch נארז כ-flag byte אחד, תמיד 0 עבור patches עצמאיים, ואחריו 16 נקודות בקרה, כל אחת 4 bytes שהם 2 big-endian X + 2 big-endian Y לפי סדר stream של המפרט המתואר להלן, ו-4 צבעי פינה, כל אחד NumComponents bytes. סך הכל 1 + 64 + 4 * NumComponents bytes לכל patch. ‏16 נקודות הבקרה יוצרות רשת 4 x 4 ‏p[i][j], כאשר i הוא row index ‏(0 = top חזותי / YMax, ‏3 = bottom חזותי / YMin) ו-j הוא column index ‏(0 = left / XMin, ‏3 = right / XMax). סדר ה-stream במפרט (Table 88) עובר קודם על 12 נקודות boundary בכיוון השעון, top row LtoR, right column TtoB, bottom row RtoL, left column BtoT, ואז מפרט את 4 נקודות הפנים בכיוון השעון החל מנקודת הפנים העליונה-שמאלית: p[1][1], p[1][2], p[2][2], p[2][1]. מערך Patches שסופק על ידי המשתמש עוקב בדיוק אחר סדר זה

כאשר כל 16 נקודות הבקרה יושבות על lattice רגיל של 1/3 / 2/3, נקודות boundary ב-1/3 / 2/3 לאורך כל קצה ונקודות פנים בצמתי הרשת הפנימיים (1/3, 1/3) / (2/3, 1/3) / (2/3, 2/3) / (1/3, 2/3), משטח bicubic Bezier מתנוון למישור שטוח ואינטרפולציית הצבע מתנוונת ל-bilinear; התוצאה חזותית זהה ל-RegisterCoonsPatchMesh עם קצוות ישרים או RegisterFreeFormGouraudShading עם ארבעה corner vertices

 

 

XMin, YMin, XMax, YMax - מלבן user-space שתוחם את הקואורדינטות המקודדות. ארבעת הערכים האלה הופכים לארבעת entries הראשונים של /Decode. הצב אותם באותן קואורדינטות user-space שבהן תצייר; עבור Rectangle בקואורדינטות מסך של HotPDF ב-(X, Y, W, H), מלבן user-space התואם ב-PDF הוא מ-(X, PageHeight - Y - H) עד (X + W, PageHeight - Y)

NumComponents - מספר רכיבי הצבע לכל פינה. העבר 1 עבור DeviceGray, ‏3 עבור DeviceRGB או 4 עבור DeviceCMYK. כל ערך אחר מעלה חריגה

Patches - מערך שטוח של ערכי Extended. כל patch תורם 32 + 4 * NumComponents ערכים: 32 floats עבור 16 נקודות הבקרה, X, Y, X, Y וכן הלאה, 16 זוגות בסדר stream של המפרט, ולאחריהם 4 * NumComponents floats עבור צבעי הפינות, ב-p[0][0] / p[0][3] / p[3][3] / p[3][0], בהתאמה לסדר המחזורי של Coons. אורך המערך חייב להיות כפולה חיובית של stride זה. כל patches שנפלטים נושאים flag = 0, כלומר patch עצמאי; continuation flags ‏1 / 2 / 3, שיתוף קצה עם patch קודם, אינם נחשפים ב-overload convenience זה

 

הערך המוחזר: שם pattern שנוצר אוטומטית, כגון Sh1, Sh2 וכן הלאה, ונרשם במילון Resources/Pattern של העמוד הנוכחי. מוחזרת מחרוזת ריקה כאשר StrictVersionLock מופעל וה-Version הפעילה נמוכה מ-PDF 1.3; אחרת גרסת המסמך עולה אוטומטית ל-1.3

 

Code Example

// Single bilinear-equivalent tensor-product patch covering a 200x200
// quad. All 16 control points sit on the 1/3 / 2/3 lattice =>
// bicubic surface degenerates to bilinear; four corner colours
// red / green / yellow / blue
var
  Doc: THotPDF;
  PatName: AnsiString;
  Patches: array[0..43] of Extended;   // 16 ctrl pts * 2 + 4 corners * 3 = 44
  H, XMin, YMin, XMax, YMax: Single;
  XThird, X2Third, YThird, Y2Third: Single;
begin
  Doc := THotPDF.Create(nil);
  try
    Doc.Version := pdf14;
    Doc.BeginDoc;
    H := Doc.CurrentPage.Height;
    XMin := 0; YMin := H - 200; XMax := 200; YMax := H;
    XThird  := XMin + 200 / 3;     X2Third := XMin + 2 * 200 / 3;
    YThird  := YMin + 200 / 3;     Y2Third := YMin + 2 * 200 / 3;
    // Spec stream order: top row LtoR, right column TtoB, bottom row RtoL,
    // left column BtoT, then interior 4 clockwise starting at p[1][1]
    Patches[ 0] := XMin;     Patches[ 1] := YMax;       // p[0][0] TL
    Patches[ 2] := XThird;   Patches[ 3] := YMax;       // p[0][1]
    Patches[ 4] := X2Third;  Patches[ 5] := YMax;       // p[0][2]
    Patches[ 6] := XMax;     Patches[ 7] := YMax;       // p[0][3] TR
    Patches[ 8] := XMax;     Patches[ 9] := Y2Third;    // p[1][3]
    Patches[10] := XMax;     Patches[11] := YThird;     // p[2][3]
    Patches[12] := XMax;     Patches[13] := YMin;       // p[3][3] BR
    Patches[14] := X2Third;  Patches[15] := YMin;       // p[3][2]
    Patches[16] := XThird;   Patches[17] := YMin;       // p[3][1]
    Patches[18] := XMin;     Patches[19] := YMin;       // p[3][0] BL
    Patches[20] := XMin;     Patches[21] := YThird;     // p[2][0]
    Patches[22] := XMin;     Patches[23] := Y2Third;    // p[1][0]
    Patches[24] := XThird;   Patches[25] := Y2Third;    // p[1][1]
    Patches[26] := X2Third;  Patches[27] := Y2Third;    // p[1][2]
    Patches[28] := X2Third;  Patches[29] := YThird;     // p[2][2]
    Patches[30] := XThird;   Patches[31] := YThird;     // p[2][1]
    // 4 corner colours at p[0][0] / p[0][3] / p[3][3] / p[3][0]
    Patches[32] := 1.0; Patches[33] := 0.0; Patches[34] := 0.0;  // red
    Patches[35] := 0.0; Patches[36] := 1.0; Patches[37] := 0.0;  // green
    Patches[38] := 1.0; Patches[39] := 1.0; Patches[40] := 0.0;  // yellow
    Patches[41] := 0.0; Patches[42] := 0.0; Patches[43] := 1.0;  // blue
    PatName := Doc.RegisterTensorProductPatchMesh(
      XMin, YMin, XMax, YMax, 3, Patches);
    Doc.CurrentPage.SetFillPattern(PatName);
    Doc.CurrentPage.Rectangle(0, 0, 200, 200);
    Doc.CurrentPage.Fill;
    Doc.EndDoc;
  finally
    Doc.Free;
  end;
end;

 

See Also

RegisterCoonsPatchMesh, RegisterFreeFormGouraudShading, RegisterLatticeFormGouraudShading, Version, PDF Filter Support