img = doc:LoadRawImage(filename, width, height, colorspace)
doc:LoadRawImage()
loads an image from raw pixel data stored in an externa file.
This function loads the data without any conversion. So it is usually faster than the other functions.
Pixels are stored line by line from top to bottom in the color format specified
by the colorspace
parameter which must be set to one of the following constants:
#HPDF_CS_DEVICE_GRAY:
width * height
bytes.
#HPDF_CS_DEVICE_RGB:
width * height * 3
bytes.
#HPDF_CS_DEVICE_CMYK
width * height * 4
bytes.
For each byte, 0 is maximum dark, 255 maximum light.
When doc:LoadRawImage()
succeeds, it returns the handle of an image object. Otherwise, it returns Nil
and the error handler is called.
#HPDF_CS_DEVICE_GRAY
, #HPDF_CS_DEVICE_RGB
or #HPDF_CS_DEVICE_CMYK
(see above)#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.
#HPDF_FILE_IO_ERROR
- Cannot read data from the file.