Name
  doc:LoadRawImage -- load raw image from file
Synopsis

      img = doc:LoadRawImage(filename, width, height, colorspace)

Function
  `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:`
    8 bit gray scale image. The gray scale color space describes each pixel with one byte. For each byte, 0 is maximum dark, and 255 is maximum light. The size of the image data is `width * height` bytes.

  `#HPDF_CS_DEVICE_RGB:`
    24 bit RGB color image. The 24 bit RGB color space describes each pixel with three bytes (red, green, blue). For each byte, 0 is maximum dark, 255 maximum light. The size of the image data is `width * height * 3` bytes.

  `#HPDF_CS_DEVICE_CMYK`
    32 bit CMYK color image. The 32 bit CMYK color space describes each pixel with four bytes (cyan, magenta, yellow, black). The size of the image data is `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.

Inputs
  filename
    a path to an image file
  width
    the width of the raw pixel data
  height
    the height of the raw pixel data
  colorspace
    `#HPDF_CS_DEVICE_GRAY`, `#HPDF_CS_DEVICE_RGB` or `#HPDF_CS_DEVICE_CMYK` (see above)
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.

  `#HPDF_FILE_IO_ERROR` - Cannot read data from the file.

Show TOC