Name
doc:CreateImageFromMem -- create new image from memory data
Synopsis
img = doc:CreateImageFromMem(data, width, height, colorspace, bpc)
Function
doc:CreateImageFromMem() creates an image from raw pixel data in memory. The data argument must be a memory pointer obtained via Hollywood's GetMemPointer() function. This function loads the data without any conversion so it is usually faster than the other functions. bpc specifies the bit size of each color component and can be either 1, 2, 4, or 8.

The colorspace argument must be one of #HPDF_CS_DEVICE_GRAY, #HPDF_CS_DEVICE_RGB, or #HPDF_CS_DEVICE_CMYK. See doc:LoadRawImage for details.

When doc:CreateImageFromMem() succeeds, it returns the handle of an image object. Otherwise, it returns Nil and the error handler is called.

Inputs
data
the pointer to the image data
width
the width of an image file
height
the height of an image file
colorspace
#HPDF_CS_DEVICE_GRAY or #HPDF_CS_DEVICE_RGB or #HPDF_CS_DEVICE_CMYK is allowed
bpc
the bit size of each color component; valid values are either 1, 2, 4, 8
Results
img
handle to an image
Errors
#HPDF_INVALID_DOCUMENT - An invalid document handle was set.

#HPDF_FAILED_TO_ALLOC_MEM - Memory allocation failed.

#HPDF_INVALID_COLOR_SPACE - An invalid color_space value is specified.

#HPDF_INVALID_IMAGE - The size of an image data is invalid.


Show TOC