Файл src/jpegio.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "allheaders.h"
#include <setjmp.h>
#include "jpeglib.h"

Макросы

#define DEBUG_INFO   0

Функции

static void jpeg_error_do_not_exit (j_common_ptr cinfo)
static l_uint8 jpeg_getc (j_decompress_ptr cinfo)
static boolean jpeg_comment_callback (j_decompress_ptr cinfo)
static l_int32 locateJpegImageParameters (l_uint8 *, l_int32, l_int32 *)
static l_int32 getNextJpegMarker (l_uint8 *, l_int32, l_int32 *)
static l_int32 getTwoByteParameter (l_uint8 *, l_int32)
PIXpixReadJpeg (const char *filename, l_int32 cmflag, l_int32 reduction, l_int32 *pnwarn)
PIXpixReadStreamJpeg (FILE *fp, l_int32 cmflag, l_int32 reduction, l_int32 *pnwarn, l_int32 hint)
l_int32 pixWriteJpeg (const char *filename, PIX *pix, l_int32 quality, l_int32 progressive)
l_int32 pixWriteStreamJpeg (FILE *fp, PIX *pix, l_int32 quality, l_int32 progressive)
l_int32 extractJpegDataFromFile (const char *filein, l_uint8 **pdata, l_int32 *pnbytes, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp)
l_int32 extractJpegDataFromArray (const void *data, l_int32 nbytes, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp)
PIXpixReadMemJpeg (const l_uint8 *cdata, size_t size, l_int32 cmflag, l_int32 reduction, l_int32 *pnwarn, l_int32 hint)
l_int32 pixWriteMemJpeg (l_uint8 **pdata, size_t *psize, PIX *pix, l_int32 quality, l_int32 progressive)

Переменные

static jmp_buf jpeg_jmpbuf

Макросы

#define DEBUG_INFO   0


Функции

l_int32 extractJpegDataFromArray ( const void *  data,
l_int32  nbytes,
l_int32 pw,
l_int32 ph,
l_int32 pbps,
l_int32 pspp 
)

extractJpegDataFromArray()

Input: data (binary data consisting of the entire jpeg file) nbytes (size of binary data) &w (<optional return>=""> image width) &h (<optional return>=""> image height) &bps (<optional return>=""> bits/sample; should be 8) &spp (<optional return>=""> samples/pixel; should be 1, 3 or 4) Return: 0 if OK, 1 on error

l_int32 extractJpegDataFromFile ( const char *  filein,
l_uint8 **  pdata,
l_int32 pnbytes,
l_int32 pw,
l_int32 ph,
l_int32 pbps,
l_int32 pspp 
)

extractJpegDataFromFile()

Input: filein &data (<return> binary data consisting of the entire jpeg file) &nbytes (<return> size of binary data) &w (<optional return>=""> image width) &h (<optional return>=""> image height) &bps (<optional return>=""> bits/sample; should be 8) &spp (<optional return>=""> samples/pixel; should be 1 or 3) Return: 0 if OK, 1 on error

static l_int32 getNextJpegMarker ( l_uint8 array,
l_int32  size,
l_int32 pindex 
) [static]

static l_int32 getTwoByteParameter ( l_uint8 array,
l_int32  index 
) [static]

static boolean jpeg_comment_callback ( j_decompress_ptr  cinfo  )  [static]

static void jpeg_error_do_not_exit ( j_common_ptr  cinfo  )  [static]

static l_uint8 jpeg_getc ( j_decompress_ptr  cinfo  )  [static]

static l_int32 locateJpegImageParameters ( l_uint8 inarray,
l_int32  size,
l_int32 pindex 
) [static]

PIX* pixReadJpeg ( const char *  filename,
l_int32  cmflag,
l_int32  reduction,
l_int32 pnwarn 
)

pixReadJpeg()

Input: filename colormap flag (0 means return RGB image if color; 1 means create colormap and return 8 bpp palette image if color) reduction (scaling factor: 1, 2, 4 or 8) &pnwarn (<optional return>=""> number of warnings about corrupted data) Return: pix, or null on error

Images reduced by factors of 2, 4 or 8 can be returned significantly faster than full resolution images.

The jpeg library will return warnings (or exit) if the jpeg data is bad. Use this function if you want the jpeg library to create an 8 bpp palette image, or to tell if the jpeg data has been corrupted. For corrupt jpeg data, there are two possible outcomes: (1) a damaged pix will be returned, along with a nonzero number of warnings, or (2) for sufficiently serious problems, the library will attempt to exit (caught by our error handler) and no pix will be returned.

PIX* pixReadMemJpeg ( const l_uint8 cdata,
size_t  size,
l_int32  cmflag,
l_int32  reduction,
l_int32 pnwarn,
l_int32  hint 
)

PIX* pixReadStreamJpeg ( FILE *  fp,
l_int32  cmflag,
l_int32  reduction,
l_int32 pnwarn,
l_int32  hint 
)

pixReadStreamJpeg()

Input: stream colormap flag (0 means return RGB image if color; 1 means create colormap and return 8 bpp palette image if color) reduction (scaling factor: 1, 2, 4 or 8) &pnwarn (<optional return>=""> number of warnings) hint: a bitwise OR of L_HINT_* values Return: pix, or null on error

Usage: see pixReadJpeg()

l_int32 pixWriteJpeg ( const char *  filename,
PIX pix,
l_int32  quality,
l_int32  progressive 
)

pixWriteJpeg()

Input: filename pix quality (1 - 100; 75 is default) progressive (0 for baseline sequential; 1 for progressive) Return: 0 if OK; 1 on error

l_int32 pixWriteMemJpeg ( l_uint8 **  pdata,
size_t *  psize,
PIX pix,
l_int32  quality,
l_int32  progressive 
)

l_int32 pixWriteStreamJpeg ( FILE *  fp,
PIX pix,
l_int32  quality,
l_int32  progressive 
)

pixWriteStreamJpeg()

Input: stream pix (8 or 32 bpp) 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) Under the covers, the library transforms rgb to a luminence-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. (2) Progressive encoding gives better compression, at the expense of slower encoding and decoding. (3) There are three possibilities: * 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. * 8 bpp colormapped image: convert each line to three 8 bpp line images in the color line buffer, and compress as three 8 bpp images. (4) 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. See note in pixWriteStreamPng() for an example.


Переменные

jmp_buf jpeg_jmpbuf [static]


Документация по Leptonica. Последние изменения: Fri Aug 7 20:31:35 2009. Создано системой  doxygen 1.5.9