Leptonica 1.68
C Image Processing Library
|
Read/write tiff format from/to file and memory. More...
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include "allheaders.h"
#include "tiff.h"
#include "tiffio.h"
Go to the source code of this file.
Data Structures | |
struct | tiff_transform |
struct | L_Memstream |
Typedefs | |
typedef struct L_Memstream | L_MEMSTREAM |
Functions | |
static PIX * | pixReadFromTiffStream (TIFF *tif) |
static l_int32 | getTiffStreamResolution (TIFF *tif, l_int32 *pxres, l_int32 *pyres) |
static l_int32 | tiffReadHeaderTiff (TIFF *tif, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *pres, l_int32 *pcmap, l_int32 *pformat) |
static l_int32 | writeCustomTiffTags (TIFF *tif, NUMA *natags, SARRAY *savals, SARRAY *satypes, NUMA *nasizes) |
static l_int32 | pixWriteToTiffStream (TIFF *tif, PIX *pix, l_int32 comptype, NUMA *natags, SARRAY *savals, SARRAY *satypes, NUMA *nasizes) |
static TIFF * | fopenTiff (FILE *fp, const char *modestring) |
static TIFF * | openTiff (const char *filename, const char *modestring) |
static l_int32 | getTiffCompressedFormat (l_uint16 tiffcomp) |
static TIFF * | fopenTiffMemstream (const char *filename, const char *operation, l_uint8 **pdata, size_t *pdatasize) |
PIX * | pixReadTiff (const char *filename, l_int32 n) |
PIX * | pixReadStreamTiff (FILE *fp, l_int32 n) |
l_int32 | pixWriteTiff (const char *filename, PIX *pix, l_int32 comptype, const char *modestring) |
l_int32 | pixWriteTiffCustom (const char *filename, PIX *pix, l_int32 comptype, const char *modestring, NUMA *natags, SARRAY *savals, SARRAY *satypes, NUMA *nasizes) |
l_int32 | pixWriteStreamTiff (FILE *fp, PIX *pix, l_int32 comptype) |
PIXA * | pixaReadMultipageTiff (const char *filename) |
l_int32 | writeMultipageTiff (const char *dirin, const char *substr, const char *fileout) |
l_int32 | writeMultipageTiffSA (SARRAY *sa, const char *fileout) |
l_int32 | fprintTiffInfo (FILE *fpout, const char *tiffile) |
l_int32 | tiffGetCount (FILE *fp, l_int32 *pn) |
l_int32 | getTiffResolution (FILE *fp, l_int32 *pxres, l_int32 *pyres) |
l_int32 | readHeaderTiff (const char *filename, l_int32 n, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *pres, l_int32 *pcmap, l_int32 *pformat) |
l_int32 | freadHeaderTiff (FILE *fp, l_int32 n, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *pres, l_int32 *pcmap, l_int32 *pformat) |
l_int32 | readHeaderMemTiff (const l_uint8 *cdata, size_t size, l_int32 n, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *pres, l_int32 *pcmap, l_int32 *pformat) |
l_int32 | findTiffCompression (FILE *fp, l_int32 *pcomptype) |
l_int32 | extractG4DataFromFile (const char *filein, l_uint8 **pdata, size_t *pnbytes, l_int32 *pw, l_int32 *ph, l_int32 *pminisblack) |
static L_MEMSTREAM * | memstreamCreateForRead (l_uint8 *indata, size_t pinsize) |
static L_MEMSTREAM * | memstreamCreateForWrite (l_uint8 **poutdata, size_t *poutsize) |
static tsize_t | tiffReadCallback (thandle_t handle, tdata_t data, tsize_t length) |
static tsize_t | tiffWriteCallback (thandle_t handle, tdata_t data, tsize_t length) |
static toff_t | tiffSeekCallback (thandle_t handle, toff_t offset, l_int32 whence) |
static l_int32 | tiffCloseCallback (thandle_t handle) |
static toff_t | tiffSizeCallback (thandle_t handle) |
static l_int32 | tiffMapCallback (thandle_t handle, tdata_t *data, toff_t *length) |
static void | tiffUnmapCallback (thandle_t handle, tdata_t data, toff_t length) |
PIX * | pixReadMemTiff (const l_uint8 *cdata, size_t size, l_int32 n) |
l_int32 | pixWriteMemTiff (l_uint8 **pdata, size_t *psize, PIX *pix, l_int32 comptype) |
l_int32 | pixWriteMemTiffCustom (l_uint8 **pdata, size_t *psize, PIX *pix, l_int32 comptype, NUMA *natags, SARRAY *savals, SARRAY *satypes, NUMA *nasizes) |
Variables | |
static const l_int32 | DEFAULT_RESOLUTION = 300 |
static const l_int32 | MAX_PAGES_IN_TIFF_FILE = 3000 |
static struct tiff_transform | tiff_orientation_transforms [] |
Read/write tiff format from/to file and memory.
Reading tiff: PIX *pixReadTiff() [ special top level ] PIX *pixReadStreamTiff() static PIX *pixReadFromTiffStream() Writing tiff: l_int32 pixWriteTiff() [ special top level ] l_int32 pixWriteTiffCustom() [ special top level ] l_int32 pixWriteStreamTiff() static l_int32 pixWriteToTiffStream() static l_int32 writeCustomTiffTags() Reading and writing multipage tiff PIXA pixaReadMultipageTiff() l_int32 writeMultipageTiff() [ special top level ] l_int32 writeMultipageTiffSA() Information about tiff file l_int32 fprintTiffInfo() l_int32 tiffGetCount() l_int32 getTiffResolution() static l_int32 getTiffStreamResolution() l_int32 readHeaderTiff() l_int32 freadHeaderTiff() l_int32 readHeaderMemTiff() static l_int32 tiffReadHeaderTiff() l_int32 findTiffCompression() static l_int32 getTiffCompressedFormat() Extraction of tiff g4 data: l_int32 extractG4DataFromFile() Open tiff stream from file stream static TIFF *fopenTiff() Wrapper for TIFFOpen: static TIFF *openTiff() Memory I/O: reading memory --> pix and writing pix --> memory [10 static helper functions] l_int32 pixReadMemTiff(); l_int32 pixWriteMemTiff(); l_int32 pixWriteMemTiffCustom(); Note: You should be using version 3.7.4 of libtiff to be certain that all the necessary functions are included.
Definition in file tiffio.c.
typedef struct L_Memstream L_MEMSTREAM |
static PIX * pixReadFromTiffStream | ( | TIFF * | tif | ) | [static] |
Input: stream Return: pix, or null on error
Quoting the libtiff documenation at http://libtiff.maptools.org/libtiff.html
libtiff provides a high-level interface for reading image data from a TIFF file. This interface handles the details of data organization and format for a wide variety of TIFF files; at least the large majority of those files that one would normally encounter. Image data is, by default, returned as ABGR pixels packed into 32-bit words (8 bits per sample). Rectangular rasters can be read or data can be intercepted at an intermediate level and packed into memory in a format more suitable to the application. The library handles all the details of the format of data stored on disk and, in most cases, if any colorspace conversions are required: bilevel to RGB, greyscale to RGB, CMYK to RGB, YCbCr to RGB, 16-bit samples to 8-bit samples, associated/unassociated alpha, etc.
Definition at line 258 of file tiffio.c.
References CALLOC, composeRGBPixel(), ERROR_PTR, FREE, getTiffCompressedFormat(), getTiffStreamResolution(), tiff_transform::hflip, NULL, pixcmapAddColor(), pixcmapCreate(), pixCreate(), pixDestroy(), pixEndianByteSwap(), pixEndianTwoByteSwap(), pixFlipLR(), pixFlipTB(), pixGetData(), pixGetWpl(), pixInvert(), pixRotate90(), pixSetColormap(), pixSetInputFormat(), pixSetXRes(), pixSetYRes(), PROCNAME, tiff_transform::rotate, and tiff_transform::vflip.
Referenced by pixReadMemTiff(), and pixReadStreamTiff().
Definition at line 1161 of file tiffio.c.
References ERROR_INT, and PROCNAME.
Referenced by getTiffResolution(), pixReadFromTiffStream(), and tiffReadHeaderTiff().
static l_int32 tiffReadHeaderTiff | ( | TIFF * | tif, |
l_int32 * | pwidth, | ||
l_int32 * | pheight, | ||
l_int32 * | pbps, | ||
l_int32 * | pspp, | ||
l_int32 * | pres, | ||
l_int32 * | pcmap, | ||
l_int32 * | pformat | ||
) | [static] |
Input: tif &width (<return>) &height (<return>) &bps (<return> bits per sample -- 1, 2, 4 or 8) &spp (<return>; samples per pixel -- 1 or 3) &res (<optional return>="">; resolution in x dir; NULL to ignore) &cmap (<optional return>="">; cmap exists; input NULL to ignore) &format (<optional return>="">; tiff format; input NULL to ignore) Return: 0 if OK, 1 on error
Definition at line 1398 of file tiffio.c.
References ERROR_INT, getTiffCompressedFormat(), getTiffStreamResolution(), and PROCNAME.
Referenced by freadHeaderTiff(), and readHeaderMemTiff().
static l_int32 writeCustomTiffTags | ( | TIFF * | tif, |
NUMA * | natags, | ||
SARRAY * | savals, | ||
SARRAY * | satypes, | ||
NUMA * | nasizes | ||
) | [static] |
Input: tif natags (<optional> NUMA of custom tiff tags) savals (<optional> SARRAY of values) satypes (<optional> SARRAY of types) nasizes (<optional> NUMA of sizes) Return: 0 if OK, 1 on error
Notes: (1) This static function should be called indirectly through higher level functions, such as pixWriteTiffCustom(), which call pixWriteToTiffStream(). See details in pixWriteTiffCustom() for using the 4 input arrays. (2) This is a no-op if the first 3 arrays are all NULL. (3) Otherwise, the first 3 arrays must be defined and all of equal size. (4) The fourth array is always optional. (5) The most commonly used types are "char*" and "u_int16". See tiff.h for a full listing of the tiff tags. Note that many of these tags, in particular the bit tags, are intended to be private, and cannot be set by this function. Examples are the STRIPOFFSETS and STRIPBYTECOUNTS tags, which are bit tags that are automatically set in the header, and can be extracted using tiffdump.
Definition at line 792 of file tiffio.c.
References ERROR_INT, L_WARNING, numaGetCount(), numaGetIValue(), PROCNAME, sarrayGetCount(), sarrayGetString(), and size.
Referenced by pixWriteToTiffStream().
static l_int32 pixWriteToTiffStream | ( | TIFF * | tif, |
PIX * | pix, | ||
l_int32 | comptype, | ||
NUMA * | natags, | ||
SARRAY * | savals, | ||
SARRAY * | satypes, | ||
NUMA * | nasizes | ||
) | [static] |
Input: tif (data structure, opened to a file) pix comptype (IFF_TIFF: for any image; no compression IFF_TIFF_RLE, IFF_TIFF_PACKBITS: for 1 bpp only IFF_TIFF_G4 and IFF_TIFF_G3: for 1 bpp only IFF_TIFF_LZW, IFF_TIFF_ZIP: for any image natags (<optional> NUMA of custom tiff tags) savals (<optional> SARRAY of values) satypes (<optional> SARRAY of types) nasizes (<optional> NUMA of sizes) Return: 0 if OK, 1 on error
Notes: (1) This static function should only be called through higher level functions in this file; namely, pixWriteTiffCustom(), pixWriteTiff(), pixWriteStreamTiff(), pixWriteMemTiff() and pixWriteMemTiffCustom(). (2) We only allow PACKBITS for bpp = 1, because for bpp > 1 it typically expands images that are not synthetically generated. (3) See pixWriteTiffCustom() for details on how to use the last four parameters for customized tiff tags. (4) The only valid pixel depths in leptonica are 1, 2, 4, 8, 16 and 32. However, it is possible, and in some cases desirable, to write out a tiff 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.
Definition at line 603 of file tiffio.c.
References CALLOC, COLOR_BLUE, COLOR_GREEN, COLOR_RED, DEFAULT_RESOLUTION, ERROR_INT, FREE, GET_DATA_BYTE, IFF_TIFF, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_PACKBITS, IFF_TIFF_RLE, IFF_TIFF_ZIP, L_MIN, L_WARNING, NULL, pixcmapGetCount(), pixcmapToArrays(), pixDestroy(), pixEndianByteSwapNew(), pixEndianTwoByteSwapNew(), pixGetColormap(), pixGetData(), pixGetDimensions(), pixGetText(), pixGetWpl(), pixGetXRes(), pixGetYRes(), PROCNAME, and writeCustomTiffTags().
Referenced by pixWriteMemTiffCustom(), pixWriteStreamTiff(), and pixWriteTiffCustom().
static TIFF * fopenTiff | ( | FILE * | fp, |
const char * | modestring | ||
) | [static] |
Input: stream modestring ("r", "w", ...) Return: tiff (data structure, opened for a file descriptor)
Notes: (1) Why is this here? Leffler did not provide a function that takes a stream and gives a TIFF. He only gave one that generates a TIFF starting with a file descriptor. So we need to make it here, because it is useful to have functions that take a stream as input. (2) Requires lseek to rewind to BOF; fseek won't hack it. (3) When linking with windows, suggest you use tif_unix.c instead of tif_win32.c, because it has been reported that the file descriptor returned from fileno() does not work with TIFFFdOpen() in tif_win32.c. (win32 requires a "handle", which is an integer returned by _get_osfhandle(fd).)
Definition at line 1662 of file tiffio.c.
References ERROR_PTR, NULL, and PROCNAME.
Referenced by findTiffCompression(), freadHeaderTiff(), getTiffResolution(), pixReadStreamTiff(), pixWriteStreamTiff(), and tiffGetCount().
static TIFF * openTiff | ( | const char * | filename, |
const char * | modestring | ||
) | [static] |
Input: filename modestring ("r", "w", ...) Return: tiff (data structure)
Notes: (1) This handles multi-platform file naming.
Definition at line 1696 of file tiffio.c.
References ERROR_PTR, FREE, genPathname(), NULL, and PROCNAME.
Referenced by extractG4DataFromFile(), fprintTiffInfo(), and pixWriteTiffCustom().
Input: tiffcomp (defined in tiff.h) Return: compression format (defined in imageio.h)
Notes: (1) The input must be the actual tiff compression type returned by a tiff library call. It should always be a valid tiff type. (2) The return type is defined in the enum in imageio.h.
Definition at line 1501 of file tiffio.c.
References IFF_TIFF, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_PACKBITS, IFF_TIFF_RLE, and IFF_TIFF_ZIP.
Referenced by findTiffCompression(), pixReadFromTiffStream(), and tiffReadHeaderTiff().
static TIFF * fopenTiffMemstream | ( | const char * | filename, |
const char * | operation, | ||
l_uint8 ** | pdata, | ||
size_t * | pdatasize | ||
) | [static] |
Input: filename (for error output; can be "") operation ("w" for write, "r" for read) &data (<return> written data) &datasize (<return> size of written data) Return: tiff (data structure, opened for write to memory)
Notes: (1) This wraps up a number of callbacks for either: * reading from tiff in memory buffer --> pix * writing from pix --> tiff in memory buffer (2) After use, the memstream is automatically destroyed when TIFFClose() is called. TIFFCleanup() doesn't free the memstream.
Definition at line 1947 of file tiffio.c.
References ERROR_PTR, memstreamCreateForRead(), memstreamCreateForWrite(), NULL, PROCNAME, tiffCloseCallback(), tiffMapCallback(), tiffReadCallback(), tiffSeekCallback(), tiffSizeCallback(), tiffUnmapCallback(), and tiffWriteCallback().
Referenced by pixReadMemTiff(), pixWriteMemTiffCustom(), and readHeaderMemTiff().
Input: filename page number (0 based) Return: pix, or null on error
Notes: (1) This is a version of pixRead(), specialized for tiff files, that allows specification of the page to be returned
Definition at line 160 of file tiffio.c.
References ERROR_PTR, fopenReadStream(), NULL, pixReadStreamTiff(), and PROCNAME.
Referenced by convertTiffMultipageToPS(), main(), and pixaReadMultipageTiff().
Input: stream n (page number: 0 based) Return: pix, or null on error (e.g., if the page number is invalid)
Definition at line 194 of file tiffio.c.
References ERROR_PTR, FALSE, fopenTiff(), L_WARNING_INT, MAX_PAGES_IN_TIFF_FILE, NULL, pixReadFromTiffStream(), PROCNAME, and TRUE.
Referenced by pixReadStream(), and pixReadTiff().
l_int32 pixWriteTiff | ( | const char * | filename, |
PIX * | pix, | ||
l_int32 | comptype, | ||
const char * | modestring | ||
) |
Input: filename (to write to) pix comptype (IFF_TIFF, IFF_TIFF_RLE, IFF_TIFF_PACKBITS, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_ZIP) modestring ("a" or "w") Return: 0 if OK, 1 on error
Notes: (1) For multi-page tiff, write the first pix with mode "w" and all subsequent pix with mode "a".
Definition at line 425 of file tiffio.c.
References NULL, and pixWriteTiffCustom().
Referenced by main(), and writeMultipageTiffSA().
l_int32 pixWriteTiffCustom | ( | const char * | filename, |
PIX * | pix, | ||
l_int32 | comptype, | ||
const char * | modestring, | ||
NUMA * | natags, | ||
SARRAY * | savals, | ||
SARRAY * | satypes, | ||
NUMA * | nasizes | ||
) |
Input: filename (to write to) pix comptype (IFF_TIFF, IFF_TIFF_RLE, IFF_TIFF_PACKBITS, IFF_TIFF_G3, IFF_TIFF_G4) IFF_TIFF_LZW, IFF_TIFF_ZIP) modestring ("a" or "w") natags (<optional> NUMA of custom tiff tags) savals (<optional> SARRAY of values) satypes (<optional> SARRAY of types) nasizes (<optional> NUMA of sizes) Return: 0 if OK, 1 on error
Usage: (1) This writes a page image to a tiff file, with optional extra tags defined in tiff.h (2) For multi-page tiff, write the first pix with mode "w" and all subsequent pix with mode "a". (3) For the custom tiff tags: (a) The three arrays {natags, savals, satypes} must all be either NULL or defined and of equal size. (b) If they are defined, the tags are an array of integers, the vals are an array of values in string format, and the types are an array of types in string format. (c) All valid tags are definined in tiff.h. (d) The types allowed are the set of strings: "char*" "l_uint8*" "l_uint16" "l_uint32" "l_int32" "l_float64" "l_uint16-l_uint16" (note the dash; use it between the two l_uint16 vals in the val string) Of these, "char*" and "l_uint16" are the most commonly used. (e) The last array, nasizes, is also optional. It is for tags that take an array of bytes for a value, a number of elements in the array, and a type that is either "char*" or "l_uint8*" (probably either will work). Use NULL if there are no such tags. (f) VERY IMPORTANT: if there are any tags that require the extra size value, stored in nasizes, they must be written first!
Definition at line 482 of file tiffio.c.
References ERROR_INT, NULL, openTiff(), pixWriteToTiffStream(), and PROCNAME.
Referenced by main(), and pixWriteTiff().
Input: stream (opened for append or write) pix comptype (IFF_TIFF, IFF_TIFF_RLE, IFF_TIFF_PACKBITS, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_ZIP) Return: 0 if OK, 1 on error
Notes: (1) For images with bpp > 1, this resets the comptype, if necessary, to write uncompressed data. (2) G3 and G4 are only defined for 1 bpp. (3) We only allow PACKBITS for bpp = 1, because for bpp > 1 it typically expands images that are not synthetically generated. (4) G4 compression is typically about twice as good as G3. G4 is excellent for binary compression of text/line-art, but terrible for halftones and dithered patterns. (In fact, G4 on halftones can give a file that is larger than uncompressed!) If a binary image has dithered regions, it is usually better to compress with png.
Definition at line 538 of file tiffio.c.
References ERROR_INT, fopenTiff(), IFF_TIFF, IFF_TIFF_LZW, IFF_TIFF_ZIP, L_WARNING, NULL, pixGetDepth(), pixWriteToTiffStream(), and PROCNAME.
Referenced by pixWriteStream().
PIXA* pixaReadMultipageTiff | ( | const char * | filename | ) |
Definition at line 903 of file tiffio.c.
References ERROR_PTR, fileFormatIsTiff(), fopenReadStream(), L_INFO_INT, L_INSERT, L_WARNING_INT, NULL, pixaAddPix(), pixaCreate(), pixReadTiff(), PROCNAME, and tiffGetCount().
Referenced by main().
l_int32 writeMultipageTiff | ( | const char * | dirin, |
const char * | substr, | ||
const char * | fileout | ||
) |
Definition at line 959 of file tiffio.c.
References ERROR_INT, getSortedPathnamesInDirectory(), PROCNAME, sarrayDestroy(), and writeMultipageTiffSA().
Referenced by main().
Definition at line 993 of file tiffio.c.
References ERROR_INT, FALSE, findFileFormat(), IFF_TIFF_G4, IFF_TIFF_ZIP, IFF_UNKNOWN, L_INFO_STRING, L_NOCOPY, L_WARNING_STRING, nfiles, NULL, pixClone(), pixDestroy(), pixGetColormap(), pixGetDepth(), pixRead(), pixRemoveColormap(), pixWriteTiff(), PROCNAME, REMOVE_CMAP_BASED_ON_SRC, sarrayGetCount(), sarrayGetString(), and TRUE.
Referenced by writeMultipageTiff().
l_int32 fprintTiffInfo | ( | FILE * | fpout, |
const char * | tiffile | ||
) |
Definition at line 1085 of file tiffio.c.
References ERROR_INT, fopenTiff(), MAX_PAGES_IN_TIFF_FILE, NULL, and PROCNAME.
Referenced by convertTiffMultipageToPS(), main(), and pixaReadMultipageTiff().
Definition at line 1127 of file tiffio.c.
References ERROR_INT, fopenTiff(), getTiffStreamResolution(), NULL, and PROCNAME.
Referenced by l_generateG4Data().
l_int32 readHeaderTiff | ( | const char * | filename, |
l_int32 | n, | ||
l_int32 * | pwidth, | ||
l_int32 * | pheight, | ||
l_int32 * | pbps, | ||
l_int32 * | pspp, | ||
l_int32 * | pres, | ||
l_int32 * | pcmap, | ||
l_int32 * | pformat | ||
) |
Input: filename n (page image number: 0-based) &width (<return>) &height (<return>) &bps (<return> bits per sample -- 1, 2, 4 or 8) &spp (<return>; samples per pixel -- 1 or 3) &res (<optional return>="">; resolution in x dir; NULL to ignore) &cmap (<optional return>="">; colormap exists; input NULL to ignore) &format (<optional return>="">; tiff format; input NULL to ignore) Return: 0 if OK, 1 on error
Notes: (1) If there is a colormap, cmap is returned as 1; else 0. (2) If
is equal to or greater than the number of images, returns 1.
Definition at line 1221 of file tiffio.c.
References ERROR_INT, fopenReadStream(), freadHeaderTiff(), NULL, and PROCNAME.
Referenced by main(), and pixReadHeader().
l_int32 freadHeaderTiff | ( | FILE * | fp, |
l_int32 | n, | ||
l_int32 * | pwidth, | ||
l_int32 * | pheight, | ||
l_int32 * | pbps, | ||
l_int32 * | pspp, | ||
l_int32 * | pres, | ||
l_int32 * | pcmap, | ||
l_int32 * | pformat | ||
) |
Input: stream n (page image number: 0-based) &width (<return>) &height (<return>) &bps (<return> bits per sample -- 1, 2, 4 or 8) &spp (<return>; samples per pixel -- 1 or 3) &res (<optional return>="">; resolution in x dir; NULL to ignore) &cmap (<optional return>="">; colormap exists; input NULL to ignore) &format (<optional return>="">; tiff format; input NULL to ignore) Return: 0 if OK, 1 on error
Notes: (1) If there is a colormap, cmap is returned as 1; else 0. (2) If
is equal to or greater than the number of images, returns 1.
Definition at line 1272 of file tiffio.c.
References ERROR_INT, findFileFormatStream(), fopenTiff(), IFF_TIFF, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_PACKBITS, IFF_TIFF_RLE, IFF_TIFF_ZIP, NULL, PROCNAME, and tiffReadHeaderTiff().
Referenced by readHeaderTiff().
l_int32 readHeaderMemTiff | ( | const l_uint8 * | cdata, |
size_t | size, | ||
l_int32 | n, | ||
l_int32 * | pwidth, | ||
l_int32 * | pheight, | ||
l_int32 * | pbps, | ||
l_int32 * | pspp, | ||
l_int32 * | pres, | ||
l_int32 * | pcmap, | ||
l_int32 * | pformat | ||
) |
Input: cdata (const; tiff-encoded) size (size of data) n (page image number: 0-based) &width (<return>) &height (<return>) &bps (<return> bits per sample -- 1, 2, 4 or 8) &spp (<return>; samples per pixel -- 1 or 3) &res (<optional return>="">; resolution in x dir; NULL to ignore) &cmap (<optional return>="">; colormap exists; input NULL to ignore) &format (<optional return>="">; tiff format; input NULL to ignore) Return: 0 if OK, 1 on error
Notes: (1) Use TIFFClose(); TIFFCleanup() doesn't free internal memstream.
Definition at line 1339 of file tiffio.c.
References ERROR_INT, fopenTiffMemstream(), NULL, PROCNAME, and tiffReadHeaderTiff().
Referenced by main(), and pixReadHeaderMem().
Input: stream (must be rewound to BOF) &comptype (<return> compression type) Return: 0 if OK, 1 on error
Notes: (1) The returned compression type is that defined in the enum in imageio.h. It is not the tiff flag value. (2) The compression type is initialized to IFF_UNKNOWN. If it is not one of the specified types, the returned type is IFF_TIFF, which indicates no compression. (3) When this function is called, the stream must be at BOF. If the opened stream is to be used again to read the file, it must be rewound to BOF after calling this function.
Definition at line 1465 of file tiffio.c.
References ERROR_INT, fopenTiff(), getTiffCompressedFormat(), IFF_UNKNOWN, NULL, and PROCNAME.
Referenced by findFileFormatStream().
l_int32 extractG4DataFromFile | ( | const char * | filein, |
l_uint8 ** | pdata, | ||
size_t * | pnbytes, | ||
l_int32 * | pw, | ||
l_int32 * | ph, | ||
l_int32 * | pminisblack | ||
) |
Input: filein &data (<return> binary data of ccitt g4 encoded stream) &nbytes (<return> size of binary data) &w (<return optional>=""> image width) &h (<return optional>=""> image height) &minisblack (<return optional>=""> boolean) Return: 0 if OK, 1 on error
Definition at line 1548 of file tiffio.c.
References CALLOC, ERROR_INT, fileFormatIsTiff(), fopenReadStream(), FREE, l_binaryRead(), L_WARNING, NULL, openTiff(), and PROCNAME.
Referenced by l_generateG4Data().
static L_MEMSTREAM * memstreamCreateForRead | ( | l_uint8 * | indata, |
size_t | pinsize | ||
) | [static] |
Definition at line 1777 of file tiffio.c.
References L_Memstream::buffer, L_Memstream::bufsize, CALLOC, L_Memstream::hw, and L_Memstream::offset.
Referenced by fopenTiffMemstream().
static L_MEMSTREAM * memstreamCreateForWrite | ( | l_uint8 ** | poutdata, |
size_t * | poutsize | ||
) | [static] |
Definition at line 1792 of file tiffio.c.
References L_Memstream::buffer, L_Memstream::bufsize, CALLOC, L_Memstream::hw, L_Memstream::offset, L_Memstream::poutdata, and L_Memstream::poutsize.
Referenced by fopenTiffMemstream().
static tsize_t tiffReadCallback | ( | thandle_t | handle, |
tdata_t | data, | ||
tsize_t | length | ||
) | [static] |
Definition at line 1808 of file tiffio.c.
References L_Memstream::buffer, L_Memstream::hw, L_MIN, and L_Memstream::offset.
Referenced by fopenTiffMemstream().
static tsize_t tiffWriteCallback | ( | thandle_t | handle, |
tdata_t | data, | ||
tsize_t | length | ||
) | [static] |
Definition at line 1824 of file tiffio.c.
References L_Memstream::buffer, L_Memstream::bufsize, L_Memstream::hw, L_MAX, L_Memstream::offset, and reallocNew().
Referenced by fopenTiffMemstream().
static toff_t tiffSeekCallback | ( | thandle_t | handle, |
toff_t | offset, | ||
l_int32 | whence | ||
) | [static] |
Definition at line 1851 of file tiffio.c.
References ERROR_INT, L_Memstream::hw, L_Memstream::offset, and PROCNAME.
Referenced by fopenTiffMemstream().
static l_int32 tiffCloseCallback | ( | thandle_t | handle | ) | [static] |
Definition at line 1883 of file tiffio.c.
References L_Memstream::buffer, FREE, L_Memstream::hw, L_Memstream::poutdata, and L_Memstream::poutsize.
Referenced by fopenTiffMemstream().
static toff_t tiffSizeCallback | ( | thandle_t | handle | ) | [static] |
Definition at line 1898 of file tiffio.c.
References L_Memstream::hw.
Referenced by fopenTiffMemstream().
static l_int32 tiffMapCallback | ( | thandle_t | handle, |
tdata_t * | data, | ||
toff_t * | length | ||
) | [static] |
Definition at line 1908 of file tiffio.c.
References L_Memstream::buffer, and L_Memstream::hw.
Referenced by fopenTiffMemstream().
static void tiffUnmapCallback | ( | thandle_t | handle, |
tdata_t | data, | ||
toff_t | length | ||
) | [static] |
Definition at line 1922 of file tiffio.c.
Referenced by fopenTiffMemstream().
Input: data (const; tiff-encoded) datasize (size of data) n (page image number: 0-based) Return: pix, or null on error
Notes: (1) This is a version of pixReadTiff(), where the data is read from a memory buffer and uncompressed. (2) Use TIFFClose(); TIFFCleanup() doesn't free internal memstream.
Definition at line 1994 of file tiffio.c.
References ERROR_PTR, FALSE, fopenTiffMemstream(), IFF_TIFF, L_WARNING_INT, MAX_PAGES_IN_TIFF_FILE, NULL, pixReadFromTiffStream(), pixSetInputFormat(), PROCNAME, and TRUE.
Referenced by main(), and pixReadMem().
Input: &data (<return> data of tiff compressed image) &size (<return> size of returned data) pix comptype (IFF_TIFF, IFF_TIFF_RLE, IFF_TIFF_PACKBITS, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_ZIP) Return: 0 if OK, 1 on error
Usage: (1) See pixWriteTiff(). This version writes to memory instead of to a file.
Definition at line 2052 of file tiffio.c.
References NULL, and pixWriteMemTiffCustom().
Referenced by main(), and pixWriteMem().
l_int32 pixWriteMemTiffCustom | ( | l_uint8 ** | pdata, |
size_t * | psize, | ||
PIX * | pix, | ||
l_int32 | comptype, | ||
NUMA * | natags, | ||
SARRAY * | savals, | ||
SARRAY * | satypes, | ||
NUMA * | nasizes | ||
) |
Input: &data (<return> data of tiff compressed image) &size (<return> size of returned data) pix comptype (IFF_TIFF, IFF_TIFF_RLE, IFF_TIFF_PACKBITS, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_ZIP) natags (<optional> NUMA of custom tiff tags) savals (<optional> SARRAY of values) satypes (<optional> SARRAY of types) nasizes (<optional> NUMA of sizes) Return: 0 if OK, 1 on error
Usage: (1) See pixWriteTiffCustom(). This version writes to memory instead of to a file. (2) Use TIFFClose(); TIFFCleanup() doesn't free internal memstream.
Definition at line 2083 of file tiffio.c.
References ERROR_INT, fopenTiffMemstream(), IFF_TIFF, IFF_TIFF_LZW, IFF_TIFF_ZIP, L_WARNING, NULL, pixGetDepth(), pixWriteToTiffStream(), and PROCNAME.
Referenced by pixWriteMemTiff().
const l_int32 DEFAULT_RESOLUTION = 300 [static] |
Definition at line 89 of file tiffio.c.
Referenced by pixWriteToTiffStream().
const l_int32 MAX_PAGES_IN_TIFF_FILE = 3000 [static] |
Definition at line 90 of file tiffio.c.
Referenced by pixReadMemTiff(), pixReadStreamTiff(), and tiffGetCount().
struct tiff_transform tiff_orientation_transforms[] [static] |