1 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffio.h,v 1.77 1994/09/19 23:52:15 sam Exp $ */ 2 3 /* 4 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler 5 * Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. 6 * 7 * Permission to use, copy, modify, distribute, and sell this software and 8 * its documentation for any purpose is hereby granted without fee, provided 9 * that (i) the above copyright notices and this permission notice appear in 10 * all copies of the software and related documentation, and (ii) the names of 11 * Sam Leffler and Silicon Graphics may not be used in any advertising or 12 * publicity relating to the software without the specific, prior written 13 * permission of Sam Leffler and Silicon Graphics. 14 * 15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 18 * 19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 24 * OF THIS SOFTWARE. 25 */ 26 27 #ifndef _TIFFIO_ 28 #define _TIFFIO_ 29 30 /* 31 * TIFF I/O Library Definitions. 32 */ 33 #include "tiff.h" 34 35 /* 36 * TIFF is defined as an incomplete type to hide the 37 * library's internal data structures from clients. 38 */ 39 typedef struct tiff TIFF; 40 41 /* 42 * The following typedefs define the intrinsic size of 43 * data types used in the *exported* interfaces. These 44 * definitions depend on the proper definition of types 45 * in tiff.h. Note also that the varargs interface used 46 * pass tag types and values uses the types defined in 47 * tiff.h directly. 48 * 49 * NB: ttag_t is unsigned int and not unsigned short because 50 * ANSI C requires that the type before the ellipsis be a 51 * promoted type (i.e. one of int, unsigned int, pointer, 52 * or double). 53 * NB: tsize_t is int32 and not uint32 because some functions 54 * return -1. 55 * NB: toff_t is not off_t for many reasons; TIFFs max out at 56 * 32-bit file offsets being the most important 57 */ 58 typedef unsigned int ttag_t; /* directory tag */ 59 typedef uint16 tdir_t; /* directory index */ 60 typedef uint16 tsample_t; /* sample number */ 61 typedef uint32 tstrip_t; /* strip number */ 62 typedef uint32 ttile_t; /* tile number */ 63 typedef int32 tsize_t; /* i/o size in bytes */ 64 #ifdef _WINDOWS 65 #include <windows.h> 66 typedef void __far* tdata_t; /* image data ref */ 67 typedef HFILE thandle_t; /* client data handle */ 68 #else 69 typedef void* tdata_t; /* image data ref */ 70 typedef void* thandle_t; /* client data handle */ 71 #endif 72 typedef int32 toff_t; /* file offset */ 73 74 #ifndef NULL 75 #define NULL 0 76 #endif 77 78 /* 79 * Flags to pass to TIFFPrintDirectory to control 80 * printing of data structures that are potentially 81 * very large. Bit-or these flags to enable printing 82 * multiple items. 83 */ 84 #define TIFFPRINT_NONE 0x0 /* no extra info */ 85 #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ 86 #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ 87 #define TIFFPRINT_COLORMAP 0x4 /* colormap */ 88 #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ 89 #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ 90 #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ 91 92 /* 93 * Macros for extracting components from the 94 * packed ABGR form returned by TIFFReadRGBAImage. 95 */ 96 #define TIFFGetR(abgr) ((abgr) & 0xff) 97 #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) 98 #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) 99 #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) 100 101 #include <stdio.h> 102 #include <stdarg.h> 103 104 #if defined(__cplusplus) 105 extern "C" { 106 #endif 107 typedef void (*TIFFErrorHandler)(const char* module, const char* fmt, va_list); 108 typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t); 109 typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); 110 typedef int (*TIFFCloseProc)(thandle_t); 111 typedef toff_t (*TIFFSizeProc)(thandle_t); 112 typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*); 113 typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t); 114 115 extern const char* TIFFGetVersion(void); 116 117 extern void TIFFClose(TIFF*); 118 extern int TIFFFlush(TIFF*); 119 extern int TIFFFlushData(TIFF*); 120 extern int TIFFGetField(TIFF*, ttag_t, ...); 121 extern int TIFFVGetField(TIFF*, ttag_t, va_list); 122 extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...); 123 extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list); 124 extern int TIFFReadDirectory(TIFF*); 125 extern tsize_t TIFFScanlineSize(TIFF*); 126 extern tsize_t TIFFStripSize(TIFF*); 127 extern tsize_t TIFFVStripSize(TIFF*, uint32); 128 extern tsize_t TIFFTileRowSize(TIFF*); 129 extern tsize_t TIFFTileSize(TIFF*); 130 extern tsize_t TIFFVTileSize(TIFF*, uint32); 131 extern int TIFFFileno(TIFF*); 132 extern int TIFFGetMode(TIFF*); 133 extern int TIFFIsTiled(TIFF*); 134 extern int TIFFIsByteSwapped(TIFF*); 135 extern uint32 TIFFCurrentRow(TIFF*); 136 extern tdir_t TIFFCurrentDirectory(TIFF*); 137 extern tstrip_t TIFFCurrentStrip(TIFF*); 138 extern ttile_t TIFFCurrentTile(TIFF*); 139 extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t); 140 extern int TIFFLastDirectory(TIFF*); 141 extern int TIFFSetDirectory(TIFF*, tdir_t); 142 extern int TIFFSetSubDirectory(TIFF*, uint32); 143 extern int TIFFUnlinkDirectory(TIFF*, tdir_t); 144 extern int TIFFSetField(TIFF*, ttag_t, ...); 145 extern int TIFFVSetField(TIFF*, ttag_t, va_list); 146 extern int TIFFWriteDirectory(TIFF *); 147 #if defined(c_plusplus) || defined(__cplusplus) 148 extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); 149 extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0); 150 extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0); 151 extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int stop = 0); 152 #else 153 extern void TIFFPrintDirectory(TIFF*, FILE*, long); 154 extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t); 155 extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t); 156 extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int stop); 157 #endif 158 extern TIFF* TIFFOpen(const char*, const char*); 159 extern TIFF* TIFFFdOpen(int, const char*, const char*); 160 extern TIFF* TIFFClientOpen(const char* name, const char* mode, 161 thandle_t clientdata, 162 TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, 163 TIFFSeekProc seekproc, TIFFCloseProc closeproc, 164 TIFFSizeProc sizeproc, 165 TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc); 166 extern const char* TIFFFileName(TIFF*); 167 extern void TIFFError(const char*, const char*, ...); 168 extern void TIFFWarning(const char*, const char*, ...); 169 extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler); 170 extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler handler); 171 extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t); 172 extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t); 173 extern ttile_t TIFFNumberOfTiles(TIFF*); 174 extern tsize_t TIFFReadTile(TIFF*, 175 tdata_t, uint32, uint32, uint32, tsample_t); 176 extern tsize_t TIFFWriteTile(TIFF*, 177 tdata_t, uint32, uint32, uint32, tsample_t); 178 extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t); 179 extern tstrip_t TIFFNumberOfStrips(TIFF*); 180 extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); 181 extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); 182 extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); 183 extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t); 184 extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); 185 extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); 186 extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); 187 extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t); 188 extern void TIFFSetWriteOffset(TIFF*, toff_t); 189 extern void TIFFSwabShort(uint16 *); 190 extern void TIFFSwabLong(uint32 *); 191 extern void TIFFSwabArrayOfShort(uint16 *, unsigned long); 192 extern void TIFFSwabArrayOfLong(uint32 *, unsigned long); 193 extern void TIFFReverseBits(unsigned char *, unsigned long); 194 extern const unsigned char* TIFFGetBitRevTable(int); 195 196 extern void TIFFModeCCITTFax3(TIFF* tif, int isClassF); /* XXX */ 197 #if defined(__cplusplus) 198 } 199 #endif 200 #endif /* _TIFFIO_ */ 201