|
Leptonica
1.54
|
Функции | |
| PIXA * | pixaReadFiles (const char *dirname, const char *substr) |
| PIXA * | pixaReadFilesSA (SARRAY *sa) |
| PIX * | pixRead (const char *filename) |
| PIX * | pixReadWithHint (const char *filename, l_int32 hint) |
| PIX * | pixReadIndexed (SARRAY *sa, l_int32 index) |
| PIX * | pixReadStream (FILE *fp, l_int32 hint) |
| l_int32 | pixReadHeader (const char *filename, l_int32 *pformat, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap) |
| l_int32 | findFileFormat (const char *filename, l_int32 *pformat) |
| l_int32 | findFileFormatStream (FILE *fp, l_int32 *pformat) |
| l_int32 | findFileFormatBuffer (const l_uint8 *buf, l_int32 *pformat) |
| l_int32 | fileFormatIsTiff (FILE *fp) |
| PIX * | pixReadMem (const l_uint8 *data, size_t size) |
| l_int32 | pixReadHeaderMem (const l_uint8 *data, size_t size, l_int32 *pformat, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap) |
| l_int32 | ioFormatTest (const char *filename) |
Переменные | |
| static const char * | FILE_BMP = "/tmp/lept/format/file.bmp" |
| static const char * | FILE_PNG = "/tmp/lept/format/file.png" |
| static const char * | FILE_PNM = "/tmp/lept/format/file.pnm" |
| static const char * | FILE_G3 = "/tmp/lept/format/file_g3.tif" |
| static const char * | FILE_G4 = "/tmp/lept/format/file_g4.tif" |
| static const char * | FILE_RLE = "/tmp/lept/format/file_rle.tif" |
| static const char * | FILE_PB = "/tmp/lept/format/file_packbits.tif" |
| static const char * | FILE_LZW = "/tmp/lept/format/file_lzw.tif" |
| static const char * | FILE_ZIP = "/tmp/lept/format/file_zip.tif" |
| static const char * | FILE_TIFF = "/tmp/lept/format/file.tif" |
| static const char * | FILE_JPG = "/tmp/lept/format/file.jpg" |
| static const char * | FILE_GIF = "/tmp/lept/format/file.gif" |
| static const char * | FILE_WEBP = "/tmp/lept/format/file.webp" |
| static const char * | FILE_JP2K = "/tmp/lept/format/file.jp2" |
| static const unsigned char | JP2K_CODESTREAM [4] = { 0xff, 0x4f, 0xff, 0x51 } |
| static const unsigned char | JP2K_IMAGE_DATA [12] |
| l_int32 fileFormatIsTiff | ( | FILE * | fp | ) |
Input: fp (file stream) Return: 1 if file is tiff; 0 otherwise or on error
Input: filename
&format (<return>)
Return: 0 if OK, 1 on error or if format is not recognized
Input: byte buffer (at least 12 bytes in size; we can't check)
&format (<return>)
Return: 0 if OK, 1 on error or if format is not recognized
Notes: (1) This determines the file format from the first 12 bytes in the compressed data stream, which are stored in memory. (2) For tiff files, this returns IFF_TIFF. The specific tiff compression is then determined using findTiffCompression().
Input: fp (file stream)
&format (<return>)
Return: 0 if OK, 1 on error or if format is not recognized
Notes: (1) Important: Side effect – this resets fp to BOF.
| l_int32 ioFormatTest | ( | const char * | filename | ) |
Input: filename (input file) Return: 0 if OK; 1 on error or if the test fails
Notes: (1) This writes and reads a set of output files losslessly in different formats to /tmp/format/, and tests that the result before and after is unchanged. (2) This should work properly on input images of any depth, with and without colormaps. (3) All supported formats are tested for bmp, png, tiff and non-ascii pnm. Ascii pnm also works (but who'd ever want to use it?) We allow 2 bpp bmp, although it's not supported elsewhere. And we don't support reading 16 bpp png, although this can be turned on in pngio.c. (4) This silently skips png or tiff testing if HAVE_LIBPNG or HAVE_LIBTIFF are 0, respectively.
| PIXA* pixaReadFiles | ( | const char * | dirname, |
| const char * | substr | ||
| ) |
Input: dirname
substr (<optional> substring filter on filenames; can be null)
Return: pixa, or null on error
Notes: (1) @dirname is the full path for the directory. (2) @substr is the part of the file name (excluding the directory) that is to be matched. All matching filenames are read into the Pixa. If substr is NULL, all filenames are read into the Pixa.
Input: sarray (full pathnames for all files) Return: pixa, or null on error
| PIX* pixRead | ( | const char * | filename | ) |
Input: filename (with full pathname or in local directory) Return: pix if OK; null on error
Notes: (1) See at top of file for supported formats.
| l_int32 pixReadHeader | ( | const char * | filename, |
| l_int32 * | pformat, | ||
| l_int32 * | pw, | ||
| l_int32 * | ph, | ||
| l_int32 * | pbps, | ||
| l_int32 * | pspp, | ||
| l_int32 * | piscmap | ||
| ) |
Input: filename (with full pathname or in local directory)
&format (<optional return> file format)
&w, &h (<optional returns> width and height)
&bps <optional return> bits/sample
&spp <optional return> samples/pixel (1, 3 or 4)
&iscmap (<optional return> 1 if cmap exists; 0 otherwise)
Return: 0 if OK, 1 on error
Notes: (1) This reads the actual headers for jpeg, png, tiff and pnm. For bmp and gif, we cheat and read the entire file into a pix, from which we extract the "header" information.
| l_int32 pixReadHeaderMem | ( | const l_uint8 * | data, |
| size_t | size, | ||
| l_int32 * | pformat, | ||
| l_int32 * | pw, | ||
| l_int32 * | ph, | ||
| l_int32 * | pbps, | ||
| l_int32 * | pspp, | ||
| l_int32 * | piscmap | ||
| ) |
Input: data (const; encoded)
datasize (size of data)
&format (<optional returns> image format)
&w, &h (<optional returns> width and height)
&bps <optional return> bits/sample
&spp <optional return> samples/pixel (1, 3 or 4)
&iscmap (<optional return> 1 if cmap exists; 0 otherwise)
Return: 0 if OK, 1 on error
Notes: (1) This reads the actual headers for jpeg, png, tiff, jp2k and pnm. For bmp and gif, we cheat and read all the data into a pix, from which we extract the "header" information. (2) The amount of data required depends on the format. For png, it requires less than 30 bytes, but for jpeg it can require most of the compressed file. In practice, the data is typically the entire compressed file in memory. (3) findFileFormatBuffer() requires up to 8 bytes to decide on the format, which we require.
Input: sarray (of full pathnames)
index (into pathname array)
Return: pix if OK; null if not found
Notes: (1) This function is useful for selecting image files from a directory, where the integer @index is embedded into the file name. (2) This is typically done by generating the sarray using getNumberedPathnamesInDirectory(), so that the @index pathname would have the number @index in it. The size of the sarray should be the largest number (plus 1) appearing in the file names, respecting the constraints in the call to getNumberedPathnamesInDirectory(). (3) Consequently, for some indices into the sarray, there may be no pathnames in the directory containing that number. By convention, we place empty C strings ("") in those locations in the sarray, and it is not an error if such a string is encountered and no pix is returned. Therefore, the caller must verify that a pix is returned. (4) See convertSegmentedPagesToPS() in src/psio1.c for an example of usage.
Input: data (const; encoded)
datasize (size of data)
Return: pix, or null on error
Notes: (1) This is a variation of pixReadStream(), where the data is read from a memory buffer rather than a file. (2) On windows, this only reads tiff formatted files directly from memory. For other formats, it write to a temp file and decompress from file. (3) findFileFormatBuffer() requires up to 12 bytes to decide on the format. That determines the constraint here. But in fact the data must contain the entire compressed string for the image.
Input: fp (file stream)
hint (bitwise OR of L_HINT_* values for jpeg; use 0 for no hint)
Return: pix if OK; null on error
Notes: (1) The hint only applies to jpeg.
Input: filename (with full pathname or in local directory)
hint (bitwise OR of L_HINT_* values for jpeg; use 0 for no hint)
Return: pix if OK; null on error
Notes: (1) The hint is not binding, but may be used to optimize jpeg decoding. Use 0 for no hinting.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |