API referenceImages

pdfInsertRawImageEx

Insert an image directly from already-decoded raw pixel data

C
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);
Delphi
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.

ParameterDescription
IPDFDocument handle.
Buffer/Image.DataRaw 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, ImgHeightPixel dimensions.
PosX, PosY, ScaleWidth, ScaleHeightPlacement 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)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfInsertRawImageEx(IntPtr IPDF, double PosX, double PosY, double ScaleWidth, double ScaleHeight, ref TPDFRawImage Image);
Area
Images
Category

Core

Exported names

pdfInsertRawImageEx

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.