Файл src/readfile.c

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

Перечисления

enum  { READ_24_BIT_COLOR = 0, CONVERT_TO_PALETTE = 1, READ_GRAY = 2 }

Функции

PIXApixaReadFiles (const char *dirname, const char *substr)
PIXApixaReadFilesSA (SARRAY *sa)
PIXpixRead (const char *filename)
PIXpixReadWithHint (const char *filename, l_int32 hint)
PIXpixReadStream (FILE *fp, l_int32 hint)
l_int32 findFileFormat (FILE *fp)
l_int32 findFileFormatBuffer (const l_uint8 *buf)
l_int32 fileFormatIsTiff (FILE *fp)
PIXpixReadMem (const l_uint8 *data, size_t size)
l_int32 ioFormatTest (const char *filename)

Переменные

static const char * FILE_BMP = "/tmp/junkout.bmp"
static const char * FILE_PNG = "/tmp/junkout.png"
static const char * FILE_PNM = "/tmp/junkout.pnm"
static const char * FILE_G3 = "/tmp/junkout_g3.tif"
static const char * FILE_G4 = "/tmp/junkout_g4.tif"
static const char * FILE_RLE = "/tmp/junkout_rle.tif"
static const char * FILE_PB = "/tmp/junkout_packbits.tif"
static const char * FILE_LZW = "/tmp/junkout_lzw.tif"
static const char * FILE_ZIP = "/tmp/junkout_zip.tif"
static const char * FILE_TIFF = "/tmp/junkout.tif"
static const char * FILE_JPG = "/tmp/junkout.jpg"

Перечисления

anonymous enum

Элементы перечислений:
READ_24_BIT_COLOR 
CONVERT_TO_PALETTE 
READ_GRAY 


Функции

l_int32 fileFormatIsTiff ( FILE *  fp  ) 

fileFormatIsTiff()

Input: fp (file stream) Return: 1 if file is tiff; 0 otherwise or on error

l_int32 findFileFormat ( FILE *  fp  ) 

findFileFormat()

Input: fp (file stream) Return: format integer; 0 on error or if format not recognized

N.B.: this resets fp to BOF

l_int32 findFileFormatBuffer ( const l_uint8 buf  ) 

findFileFormatBuffer()

Input: byte buffer (at least 8 bytes in size; we can't check) Return: format integer; 0 on error or if format not recognized

Notes: (1) This determines the file format from the first 8 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().

l_int32 ioFormatTest ( const char *  filename  ) 

ioFormatTest()

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, 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.

PIXA* pixaReadFiles ( const char *  dirname,
const char *  substr 
)

pixaReadFiles()

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. (3) This is unix only; it does not work on Windows.

PIXA* pixaReadFilesSA ( SARRAY sa  ) 

pixaReadFilesSA()

Input: sarray (full pathnames for all files) Return: pixa, or null on error

PIX* pixRead ( const char *  filename  ) 

pixRead()

Input: filename (with full pathname or in local directory) Return: pix if OK; null on error

PIX* pixReadMem ( const l_uint8 data,
size_t  size 
)

pixReadMem()

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 will only read tiff formatted files from memory. For other formats, it requires fmemopen(3). Attempts to read those formats will fail at runtime. (3) findFileFormatBuffer() requires up to 8 bytes to decide on the format. That determines the constraint here.

PIX* pixReadStream ( FILE *  fp,
l_int32  hint 
)

pixReadStream()

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.

PIX* pixReadWithHint ( const char *  filename,
l_int32  hint 
)

pixReadWithHint()

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.


Переменные

const char* FILE_BMP = "/tmp/junkout.bmp" [static]

const char* FILE_G3 = "/tmp/junkout_g3.tif" [static]

const char* FILE_G4 = "/tmp/junkout_g4.tif" [static]

const char* FILE_JPG = "/tmp/junkout.jpg" [static]

const char* FILE_LZW = "/tmp/junkout_lzw.tif" [static]

const char* FILE_PB = "/tmp/junkout_packbits.tif" [static]

const char* FILE_PNG = "/tmp/junkout.png" [static]

const char* FILE_PNM = "/tmp/junkout.pnm" [static]

const char* FILE_RLE = "/tmp/junkout_rle.tif" [static]

const char* FILE_TIFF = "/tmp/junkout.tif" [static]

const char* FILE_ZIP = "/tmp/junkout_zip.tif" [static]


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