img = doc:CreateImageFromMem(data, width, height, colorspace, bpc)
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.
#HPDF_CS_DEVICE_GRAY
or #HPDF_CS_DEVICE_RGB
or #HPDF_CS_DEVICE_CMYK
is allowed#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.