pdfInsertRawImage
Insert an image directly from already-decoded raw pixel data
int32_t __stdcall pdfInsertRawImage(PPDF IPDF, void* Buffer, uint32_t BitsPerPixel, uint32_t ColorCount, uint32_t ImgWidth, uint32_t ImgHeight, double PosX, double PosY, double ScaleWidth, double ScaleHeight);
int32_t __stdcall pdfInsertRawImageEx(PPDF IPDF, double PosX, double PosY, double ScaleWidth, double ScaleHeight, TPDFRawImage* Image);
function pdfInsertRawImage(const IPDF: PPDF; Buffer: Pointer; BitsPerPixel, ColorCount, ImgWidth, ImgHeight: Cardinal; PosX, PosY, ScaleWidth, ScaleHeight: Double): Integer; stdcall;
function pdfInsertRawImageEx(const IPDF: PPDF; PosX, PosY, ScaleWidth, ScaleHeight: Double; Image: PPDFRawImage): Integer; stdcall;
Purpose. Insert an image directly from already-decoded raw pixel data (no file/buffer format decoding involved).
Description. pdfInsertRawImage takes pixel data plus BitsPerPixel/ ColorCount; internally derives bits-per-component as BitsPerPixel div ColorCount (defaulting to 8 if that computes to 0) and ColorCount itself defaults to 3 (RGB) if 0/negative is passed — ColorCount here is actually the number of color components, not a palette-entry count despite the name suggesting an indexed-color table size. The raw byte size is computed as Width * Height * NumComps * (BPC div 8); a computed size of 0 (e.g. BPC < 8, sub-byte packing) is rejected outright — sub-byte-per-component raw formats (1-bit/4-bit) are not supported through this entry point, only whole-byte-per-component layouts. pdfInsertRawImageEx is a struct-based equivalent computing BitsPerPixel internally as Image.BitsPerComp * Image.NumComps from the TPDFRawImage struct's own fields, otherwise identical.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Buffer/Image.Data | Raw pixel bytes, row-major, no padding assumed beyond whole-byte-per-component. |
BitsPerPixel/ColorCount | *(plain)* Total bits per pixel and component count — BitsPerPixel div ColorCount must be >= 8 (whole bytes) or the call fails. |
ImgWidth, ImgHeight | Pixel dimensions. |
PosX, PosY, ScaleWidth, ScaleHeight | Placement box. |
Return value. The new image handle on success; 0 if IPDF is invalid, there is no current page, dimensions are non-positive, or the computed byte size is 0 (sub-byte-per-component input).
See also. pdfInsertImage.
C# (P/Invoke)
public static extern int pdfInsertRawImage(IntPtr IPDF, IntPtr Buffer, uint BitsPerPixel, uint ColorCount, uint ImgWidth, uint ImgHeight, double PosX, double PosY, double ScaleWidth, double ScaleHeight);
Core
pdfInsertRawImage
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.