يضيف كائن صورة ملونة XObject مع كائن صورة قناع لين وفق PDF 1.4 (ISO 32000-1 بند 8.9.5.4) حتى تحمل الصورة الناتجة شفافية كاملة لكل بكسل بدلًا من حد التشغيل/الإيقاف الثنائي في مسار /ImageMask القديم.
يضيف صورة colour XObject مع صورة PDF 1.4 soft-mask XObject (ISO 32000-1 8.9.5.4)، بحيث تحمل الصورة الناتجة شفافية كاملة لكل pixel بدل حد on/off الثنائي لمسار /ImageMask القديم
Delphi syntax:
function AddImageWithSMask(Width, Height: Integer; const RGB: TBytes; const Alpha: TBytes): Integer;
function AddImageWithSMask32(Bitmap32: TBitmap): Integer;
C++ syntax:
__property int AddImageWithSMask(int Width, int Height, const TBytes& RGB, const TBytes& Alpha);
__property int AddImageWithSMask32(TBitmap* Bitmap32);
الوصف
تحمل صور SMask قناة DeviceGray مستقلة بعمق 8-bit تقود alpha للصورة الملونة وقت الرسم. يصدر HotPDF كلا المستويين كـ image XObjects مضغوطة بـ Flate، ويربط مدخل /SMask في قاموس الصورة الملونة بـ soft-mask XObject، ويعيد XImages index تقبله THPDFPage.ShowImage مباشرة
AddImageWithSMask(Width, Height, RGB, Alpha)
- Width / Height: pixel dimensions, identical for both planes.
AddImageWithSMask(Width, Height, RGB, Alpha)
- Width / Height: الأبعاد بالبكسل، متطابقة في المستويين معًا.
- RGB: Width * Height * 3 bytes, row-major top-down, R G B interleaved per pixel (no row padding).
- Alpha: Width * Height bytes, row-major top-down, 8-bit luminosity per pixel.
AddImageWithSMask32(Bitmap32)
Pixels يجب أن يحتوي Width * Height * 4 بايتًا بترتيب R وG وB وA. يقسم HotPDF المخزن المؤقت إلى مستوى اللون RGB ومستوى ألفا 8 بت قبل التفويض إلى AddImageWithSMaskoverload مريح لمسار عمل شائع هو PNG مع alpha. يجب أن يكون TBitmap ذا PixelFormat = pf32bit؛ يقرأ HotPDF صفوف BGRA ScanLine مباشرة، ويعيد ترتيبها إلى R G B لمستوى اللون، وينسخ byte A إلى مستوى alpha قبل التفويض إلى AddImageWithSMask الخام
XImages مطابقًا لما يعيده AddImage؛ مرره إلى THPDFPage.ShowImage لوضع الصورة على صفحة. ويعيد -1 عندما تكون StrictVersionLockالقيمة المعادة: index في XImages مطابق لما يعيده AddImage؛ مرره إلى THPDFPage.ShowImage لوضع الصورة على صفحة. يعيد -1 عندما يكون StrictVersionLock مفعّلًا وVersion النشطة أقل من PDF 1.4؛ وإلا ترفع version تلقائيًا إلى 1.4
Code Example
// 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;
انظر أيضا
AddImage, THPDFPage.ShowImage, Version, PDF Filter Support
|