|
| static void | jpeg_error_catch_all_1 (j_common_ptr cinfo) |
| |
| static void | jpeg_error_catch_all_2 (j_common_ptr cinfo) |
| |
| static l_uint8 | jpeg_getc (j_decompress_ptr cinfo) |
| |
| static boolean | jpeg_comment_callback (j_decompress_ptr cinfo) |
| |
| PIX * | pixReadJpeg (const char *filename, l_int32 cmapflag, l_int32 reduction, l_int32 *pnwarn, l_int32 hint) |
| |
| PIX * | pixReadStreamJpeg (FILE *fp, l_int32 cmapflag, l_int32 reduction, l_int32 *pnwarn, l_int32 hint) |
| |
| l_int32 | readHeaderJpeg (const char *filename, l_int32 *pw, l_int32 *ph, l_int32 *pspp, l_int32 *pycck, l_int32 *pcmyk) |
| |
| l_int32 | freadHeaderJpeg (FILE *fp, l_int32 *pw, l_int32 *ph, l_int32 *pspp, l_int32 *pycck, l_int32 *pcmyk) |
| |
| l_int32 | fgetJpegResolution (FILE *fp, l_int32 *pxres, l_int32 *pyres) |
| |
| l_int32 | fgetJpegComment (FILE *fp, l_uint8 **pcomment) |
| |
| l_int32 | pixWriteJpeg (const char *filename, PIX *pix, l_int32 quality, l_int32 progressive) |
| |
| l_int32 | pixWriteStreamJpeg (FILE *fp, PIX *pixs, l_int32 quality, l_int32 progressive) |
| |
| FILE * | open_memstream (char **data, size_t *size) |
| |
| FILE * | fmemopen (void *data, size_t size, const char *mode) |
| |
| PIX * | pixReadMemJpeg (const l_uint8 *data, size_t size, l_int32 cmflag, l_int32 reduction, l_int32 *pnwarn, l_int32 hint) |
| |
| l_int32 | readHeaderMemJpeg (const l_uint8 *data, size_t size, l_int32 *pw, l_int32 *ph, l_int32 *pspp, l_int32 *pycck, l_int32 *pcmyk) |
| |
| l_int32 | pixWriteMemJpeg (l_uint8 **pdata, size_t *psize, PIX *pix, l_int32 quality, l_int32 progressive) |
| |
| l_int32 | pixSetChromaSampling (PIX *pix, l_int32 sampling) |
| |
pixReadJpeg()
Input: filename
cmapflag (0 for no colormap in returned pix;
1 to return an 8 bpp cmapped pix if spp = 3 or 4)
reduction (scaling factor: 1, 2, 4 or 8)
&nwarn (<optional return> number of warnings about
corrupted data)
hint (a bitwise OR of L_JPEG_* values; 0 for default)
Return: pix, or null on error
Notes: (1) This is a special function for reading jpeg files. (2) Use this if you want the jpeg library to create an 8 bpp colormapped image. (3) Images reduced by factors of 2, 4 or 8 can be returned significantly faster than full resolution images. (4) If the jpeg data is bad, the jpeg library will continue silently, or return warnings, or attempt to exit. Depending on the severity of the data corruption, there are two possible outcomes: (a) a possibly damaged pix can be generated, along with zero or more warnings, or (b) the library will attempt to exit (caught by our error handler) and no pix will be returned. If a pix is generated with at least one warning of data corruption, and if L_JPEG_FAIL_ON_BAD_DATA is included in @hint, no pix will be returned. (5) The possible hint values are given in the enum in imageio.h:
- L_JPEG_READ_LUMINANCE
- L_JPEG_FAIL_ON_BAD_DATA Default (0) is to do neither.
pixReadMemJpeg()
Input: data (const; jpeg-encoded)
size (of data)
colormap flag (0 means return RGB image if color;
1 means create a colormap and return
an 8 bpp colormapped image if color)
reduction (scaling factor: 1, 2, 4 or 8)
&nwarn (<optional return> number of warnings)
hint (a bitwise OR of L_JPEG_* values; 0 for default)
Return: pix, or null on error
Notes: (1) The @size byte of @data must be a null character. (2) The only hint flag so far is L_JPEG_READ_LUMINANCE, given in the enum in imageio.h. (3) See pixReadJpeg() for usage.
pixWriteStreamJpeg()
Input: stream
pixs (any depth; cmap is OK)
quality (1 - 100; 75 is default value; 0 is also default)
progressive (0 for baseline sequential; 1 for progressive)
Return: 0 if OK, 1 on error
Notes: (1) Progressive encoding gives better compression, at the expense of slower encoding and decoding. (2) Standard chroma subsampling is 2x2 on both the U and V channels. For highest quality, use no subsampling; this option is set by pixSetChromaSampling(pix, 0). (3) The only valid pixel depths in leptonica are 1, 2, 4, 8, 16 and 32 bpp. However, it is possible, and in some cases desirable, to write out a jpeg file using an rgb pix that has 24 bpp. This can be created by appending the raster data for a 24 bpp image (with proper scanline padding) directly to a 24 bpp pix that was created without a data array. (4) There are two compression paths in this function:
- Grayscale image, no colormap: compress as 8 bpp image.
- rgb full color image: copy each line into the color line buffer, and compress as three 8 bpp images. (5) Under the covers, the jpeg library transforms rgb to a luminance-chromaticity triple, each component of which is also 8 bits, and compresses that. It uses 2 Huffman tables, a higher resolution one (with more quantization levels) for luminosity and a lower resolution one for the chromas.