8.4.1. jpeg decompression
(packages/jpeg/jpeg.lsh)


This set of functions provides a simple way to decode JPEG images in memory. It is based on Jean-Luc Saillard's tinyjpegdecoder library which can be found at: http://www.saillard.org/programs_and_patches/tinyjpegdecoder . These functions are useful to decode JPEG streams from memory.

8.4.1.0. (jpeg-decode buffer image)
(packages/jpeg/jpeg.lsh)


decode a JPEG stream in buffer (which must be an idx1 of ubytes into an RGB image, image (which must be an idx3 of ubyte). The image is automatically resized to the size of the JPEG image. If the JPEG image is grayscale, only the first component is filled.
 (let ((buf (ubyte-matrix 1))
       (m (ubyte-matrix 1 1 3)))
   (read-file-to-idx "myimage.jpg" buf)
   (jpeg-decode buf m))


8.4.1.1. (read-file-to-idx f m)
(packages/jpeg/jpeg.lsh)


read the content of a file f into an idx1 of ubyte m . m is automatically resized to the proper size. Returns 0 on success, -1 if the file could not be open.

8.4.1.2. (jpeg-decode-file f)
(packages/jpeg/jpeg.lsh)


return an RGB image (idx1 of ubyte height by width by 3) with the decoded image in JPEG file f .