ReactOS 0.4.15-dev-7961-gdcf9eb0
tiffio.h File Reference
#include "tiff.h"
#include "tiffvers.h"
#include <stdio.h>
#include <stdarg.h>
Include dependency graph for tiffio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  TIFFDisplay
 
struct  TIFFYCbCrToRGB
 
struct  TIFFCIELabToRGB
 
struct  _TIFFRGBAImage
 
struct  TIFFCodec
 
struct  TIFFTagMethods
 
struct  TIFFFieldInfo
 

Macros

#define TIFFPRINT_NONE   0x0 /* no extra info */
 
#define TIFFPRINT_STRIPS   0x1 /* strips/tiles info */
 
#define TIFFPRINT_CURVES   0x2 /* color/gray response curves */
 
#define TIFFPRINT_COLORMAP   0x4 /* colormap */
 
#define TIFFPRINT_JPEGQTABLES   0x100 /* JPEG Q matrices */
 
#define TIFFPRINT_JPEGACTABLES   0x200 /* JPEG AC tables */
 
#define TIFFPRINT_JPEGDCTABLES   0x200 /* JPEG DC tables */
 
#define D65_X0   (95.0470F)
 
#define D65_Y0   (100.0F)
 
#define D65_Z0   (108.8827F)
 
#define D50_X0   (96.4250F)
 
#define D50_Y0   (100.0F)
 
#define D50_Z0   (82.4680F)
 
#define CIELABTORGB_TABLE_RANGE   1500
 
#define TIFFGetR(abgr)   ((abgr) & 0xff)
 
#define TIFFGetG(abgr)   (((abgr) >> 8) & 0xff)
 
#define TIFFGetB(abgr)   (((abgr) >> 16) & 0xff)
 
#define TIFFGetA(abgr)   (((abgr) >> 24) & 0xff)
 
#define LOGLUV_PUBLIC   1
 
#define __attribute__(x)   /*nothing*/
 
#define TIFF_ANY   TIFF_NOTYPE /* for field descriptor searching */
 
#define TIFF_VARIABLE   -1 /* marker for variable length tags */
 
#define TIFF_SPP   -2 /* marker for SamplesPerPixel tags */
 
#define TIFF_VARIABLE2   -3 /* marker for uint32 var-length tags */
 
#define FIELD_CUSTOM   65
 
#define U_NEU   0.210526316
 
#define V_NEU   0.473684211
 
#define UVSCALE   410.
 

Typedefs

typedef struct tiff TIFF
 
typedef TIFF_SSIZE_T tmsize_t
 
typedef uint64 toff_t
 
typedef uint32 ttag_t
 
typedef uint16 tdir_t
 
typedef uint16 tsample_t
 
typedef uint32 tstrile_t
 
typedef tstrile_t tstrip_t
 
typedef tstrile_t ttile_t
 
typedef tmsize_t tsize_t
 
typedef voidtdata_t
 
typedef voidthandle_t
 
typedef unsigned char TIFFRGBValue
 
typedef struct _TIFFRGBAImage TIFFRGBAImage
 
typedef void(* tileContigRoutine) (TIFFRGBAImage *, uint32 *, uint32, uint32, uint32, uint32, int32, int32, unsigned char *)
 
typedef void(* tileSeparateRoutine) (TIFFRGBAImage *, uint32 *, uint32, uint32, uint32, uint32, int32, int32, unsigned char *, unsigned char *, unsigned char *, unsigned char *)
 
typedef int(* TIFFInitMethod) (TIFF *, int)
 
typedef void(* TIFFErrorHandler) (const char *, const char *, va_list)
 
typedef void(* TIFFErrorHandlerExt) (thandle_t, const char *, const char *, va_list)
 
typedef tmsize_t(* TIFFReadWriteProc) (thandle_t, void *, tmsize_t)
 
typedef toff_t(* TIFFSeekProc) (thandle_t, toff_t, int)
 
typedef int(* TIFFCloseProc) (thandle_t)
 
typedef toff_t(* TIFFSizeProc) (thandle_t)
 
typedef int(* TIFFMapFileProc) (thandle_t, void **base, toff_t *size)
 
typedef void(* TIFFUnmapFileProc) (thandle_t, void *base, toff_t size)
 
typedef void(* TIFFExtendProc) (TIFF *)
 
typedef struct _TIFFField TIFFField
 
typedef struct _TIFFFieldArray TIFFFieldArray
 
typedef int(* TIFFVSetMethod) (TIFF *, uint32, va_list)
 
typedef int(* TIFFVGetMethod) (TIFF *, uint32, va_list)
 
typedef void(* TIFFPrintMethod) (TIFF *, FILE *, long)
 

Functions

const charTIFFGetVersion (void)
 
const TIFFCodecTIFFFindCODEC (uint16)
 
TIFFCodecTIFFRegisterCODEC (uint16, const char *, TIFFInitMethod)
 
void TIFFUnRegisterCODEC (TIFFCodec *)
 
int TIFFIsCODECConfigured (uint16)
 
TIFFCodecTIFFGetConfiguredCODECs (void)
 
void_TIFFmalloc (tmsize_t s)
 
void_TIFFcalloc (tmsize_t nmemb, tmsize_t siz)
 
void_TIFFrealloc (void *p, tmsize_t s)
 
void _TIFFmemset (void *p, int v, tmsize_t c)
 
void _TIFFmemcpy (void *d, const void *s, tmsize_t c)
 
int _TIFFmemcmp (const void *p1, const void *p2, tmsize_t c)
 
void _TIFFfree (void *p)
 
int TIFFGetTagListCount (TIFF *)
 
uint32 TIFFGetTagListEntry (TIFF *, int tag_index)
 
const TIFFFieldTIFFFindField (TIFF *, uint32, TIFFDataType)
 
const TIFFFieldTIFFFieldWithTag (TIFF *, uint32)
 
const TIFFFieldTIFFFieldWithName (TIFF *, const char *)
 
uint32 TIFFFieldTag (const TIFFField *)
 
const charTIFFFieldName (const TIFFField *)
 
TIFFDataType TIFFFieldDataType (const TIFFField *)
 
int TIFFFieldPassCount (const TIFFField *)
 
int TIFFFieldReadCount (const TIFFField *)
 
int TIFFFieldWriteCount (const TIFFField *)
 
TIFFTagMethodsTIFFAccessTagMethods (TIFF *)
 
voidTIFFGetClientInfo (TIFF *, const char *)
 
void TIFFSetClientInfo (TIFF *, void *, const char *)
 
void TIFFCleanup (TIFF *tif)
 
void TIFFClose (TIFF *tif)
 
int TIFFFlush (TIFF *tif)
 
int TIFFFlushData (TIFF *tif)
 
int TIFFGetField (TIFF *tif, uint32 tag,...)
 
int TIFFVGetField (TIFF *tif, uint32 tag, va_list ap)
 
int TIFFGetFieldDefaulted (TIFF *tif, uint32 tag,...)
 
int TIFFVGetFieldDefaulted (TIFF *tif, uint32 tag, va_list ap)
 
int TIFFReadDirectory (TIFF *tif)
 
int TIFFReadCustomDirectory (TIFF *tif, toff_t diroff, const TIFFFieldArray *infoarray)
 
int TIFFReadEXIFDirectory (TIFF *tif, toff_t diroff)
 
uint64 TIFFScanlineSize64 (TIFF *tif)
 
tmsize_t TIFFScanlineSize (TIFF *tif)
 
uint64 TIFFRasterScanlineSize64 (TIFF *tif)
 
tmsize_t TIFFRasterScanlineSize (TIFF *tif)
 
uint64 TIFFStripSize64 (TIFF *tif)
 
tmsize_t TIFFStripSize (TIFF *tif)
 
uint64 TIFFRawStripSize64 (TIFF *tif, uint32 strip)
 
tmsize_t TIFFRawStripSize (TIFF *tif, uint32 strip)
 
uint64 TIFFVStripSize64 (TIFF *tif, uint32 nrows)
 
tmsize_t TIFFVStripSize (TIFF *tif, uint32 nrows)
 
uint64 TIFFTileRowSize64 (TIFF *tif)
 
tmsize_t TIFFTileRowSize (TIFF *tif)
 
uint64 TIFFTileSize64 (TIFF *tif)
 
tmsize_t TIFFTileSize (TIFF *tif)
 
uint64 TIFFVTileSize64 (TIFF *tif, uint32 nrows)
 
tmsize_t TIFFVTileSize (TIFF *tif, uint32 nrows)
 
uint32 TIFFDefaultStripSize (TIFF *tif, uint32 request)
 
void TIFFDefaultTileSize (TIFF *, uint32 *, uint32 *)
 
int TIFFFileno (TIFF *)
 
int TIFFSetFileno (TIFF *, int)
 
thandle_t TIFFClientdata (TIFF *)
 
thandle_t TIFFSetClientdata (TIFF *, thandle_t)
 
int TIFFGetMode (TIFF *)
 
int TIFFSetMode (TIFF *, int)
 
int TIFFIsTiled (TIFF *)
 
int TIFFIsByteSwapped (TIFF *)
 
int TIFFIsUpSampled (TIFF *)
 
int TIFFIsMSB2LSB (TIFF *)
 
int TIFFIsBigEndian (TIFF *)
 
TIFFReadWriteProc TIFFGetReadProc (TIFF *)
 
TIFFReadWriteProc TIFFGetWriteProc (TIFF *)
 
TIFFSeekProc TIFFGetSeekProc (TIFF *)
 
TIFFCloseProc TIFFGetCloseProc (TIFF *)
 
TIFFSizeProc TIFFGetSizeProc (TIFF *)
 
TIFFMapFileProc TIFFGetMapFileProc (TIFF *)
 
TIFFUnmapFileProc TIFFGetUnmapFileProc (TIFF *)
 
uint32 TIFFCurrentRow (TIFF *)
 
uint16 TIFFCurrentDirectory (TIFF *)
 
uint16 TIFFNumberOfDirectories (TIFF *)
 
uint64 TIFFCurrentDirOffset (TIFF *)
 
uint32 TIFFCurrentStrip (TIFF *)
 
uint32 TIFFCurrentTile (TIFF *tif)
 
int TIFFReadBufferSetup (TIFF *tif, void *bp, tmsize_t size)
 
int TIFFWriteBufferSetup (TIFF *tif, void *bp, tmsize_t size)
 
int TIFFSetupStrips (TIFF *)
 
int TIFFWriteCheck (TIFF *, int, const char *)
 
void TIFFFreeDirectory (TIFF *)
 
int TIFFCreateDirectory (TIFF *)
 
int TIFFCreateCustomDirectory (TIFF *, const TIFFFieldArray *)
 
int TIFFCreateEXIFDirectory (TIFF *)
 
int TIFFLastDirectory (TIFF *)
 
int TIFFSetDirectory (TIFF *, uint16)
 
int TIFFSetSubDirectory (TIFF *, uint64)
 
int TIFFUnlinkDirectory (TIFF *, uint16)
 
int TIFFSetField (TIFF *, uint32,...)
 
int TIFFVSetField (TIFF *, uint32, va_list)
 
int TIFFUnsetField (TIFF *, uint32)
 
int TIFFWriteDirectory (TIFF *)
 
int TIFFWriteCustomDirectory (TIFF *, uint64 *)
 
int TIFFCheckpointDirectory (TIFF *)
 
int TIFFRewriteDirectory (TIFF *)
 
int TIFFDeferStrileArrayWriting (TIFF *)
 
int TIFFForceStrileArrayWriting (TIFF *)
 
void TIFFPrintDirectory (TIFF *, FILE *, long)
 
int TIFFReadScanline (TIFF *tif, void *buf, uint32 row, uint16 sample)
 
int TIFFWriteScanline (TIFF *tif, void *buf, uint32 row, uint16 sample)
 
int TIFFReadRGBAImage (TIFF *, uint32, uint32, uint32 *, int)
 
int TIFFReadRGBAImageOriented (TIFF *, uint32, uint32, uint32 *, int, int)
 
int TIFFReadRGBAStrip (TIFF *, uint32, uint32 *)
 
int TIFFReadRGBATile (TIFF *, uint32, uint32, uint32 *)
 
int TIFFReadRGBAStripExt (TIFF *, uint32, uint32 *, int stop_on_error)
 
int TIFFReadRGBATileExt (TIFF *, uint32, uint32, uint32 *, int stop_on_error)
 
int TIFFRGBAImageOK (TIFF *, char[1024])
 
int TIFFRGBAImageBegin (TIFFRGBAImage *, TIFF *, int, char[1024])
 
int TIFFRGBAImageGet (TIFFRGBAImage *, uint32 *, uint32, uint32)
 
void TIFFRGBAImageEnd (TIFFRGBAImage *)
 
TIFFTIFFOpen (const char *, const char *)
 
TIFFTIFFFdOpen (int, const char *, const char *)
 
TIFFTIFFClientOpen (const char *, const char *, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc)
 
const charTIFFFileName (TIFF *)
 
const charTIFFSetFileName (TIFF *, const char *)
 
void TIFFError (const char *, const char *,...) __attribute__((__format__(__printf__
 
void void TIFFErrorExt (thandle_t, const char *, const char *,...) __attribute__((__format__(__printf__
 
void void void TIFFWarning (const char *, const char *,...) __attribute__((__format__(__printf__
 
void void void void TIFFWarningExt (thandle_t, const char *, const char *,...) __attribute__((__format__(__printf__
 
void void void void TIFFErrorHandler TIFFSetErrorHandler (TIFFErrorHandler)
 
TIFFErrorHandlerExt TIFFSetErrorHandlerExt (TIFFErrorHandlerExt)
 
TIFFErrorHandler TIFFSetWarningHandler (TIFFErrorHandler)
 
TIFFErrorHandlerExt TIFFSetWarningHandlerExt (TIFFErrorHandlerExt)
 
TIFFExtendProc TIFFSetTagExtender (TIFFExtendProc)
 
uint32 TIFFComputeTile (TIFF *tif, uint32 x, uint32 y, uint32 z, uint16 s)
 
int TIFFCheckTile (TIFF *tif, uint32 x, uint32 y, uint32 z, uint16 s)
 
uint32 TIFFNumberOfTiles (TIFF *)
 
tmsize_t TIFFReadTile (TIFF *tif, void *buf, uint32 x, uint32 y, uint32 z, uint16 s)
 
tmsize_t TIFFWriteTile (TIFF *tif, void *buf, uint32 x, uint32 y, uint32 z, uint16 s)
 
uint32 TIFFComputeStrip (TIFF *, uint32, uint16)
 
uint32 TIFFNumberOfStrips (TIFF *)
 
tmsize_t TIFFReadEncodedStrip (TIFF *tif, uint32 strip, void *buf, tmsize_t size)
 
tmsize_t TIFFReadRawStrip (TIFF *tif, uint32 strip, void *buf, tmsize_t size)
 
tmsize_t TIFFReadEncodedTile (TIFF *tif, uint32 tile, void *buf, tmsize_t size)
 
tmsize_t TIFFReadRawTile (TIFF *tif, uint32 tile, void *buf, tmsize_t size)
 
int TIFFReadFromUserBuffer (TIFF *tif, uint32 strile, void *inbuf, tmsize_t insize, void *outbuf, tmsize_t outsize)
 
tmsize_t TIFFWriteEncodedStrip (TIFF *tif, uint32 strip, void *data, tmsize_t cc)
 
tmsize_t TIFFWriteRawStrip (TIFF *tif, uint32 strip, void *data, tmsize_t cc)
 
tmsize_t TIFFWriteEncodedTile (TIFF *tif, uint32 tile, void *data, tmsize_t cc)
 
tmsize_t TIFFWriteRawTile (TIFF *tif, uint32 tile, void *data, tmsize_t cc)
 
int TIFFDataWidth (TIFFDataType)
 
void TIFFSetWriteOffset (TIFF *tif, toff_t off)
 
void TIFFSwabShort (uint16 *)
 
void TIFFSwabLong (uint32 *)
 
void TIFFSwabLong8 (uint64 *)
 
void TIFFSwabFloat (float *)
 
void TIFFSwabDouble (double *)
 
void TIFFSwabArrayOfShort (uint16 *wp, tmsize_t n)
 
void TIFFSwabArrayOfTriples (uint8 *tp, tmsize_t n)
 
void TIFFSwabArrayOfLong (uint32 *lp, tmsize_t n)
 
void TIFFSwabArrayOfLong8 (uint64 *lp, tmsize_t n)
 
void TIFFSwabArrayOfFloat (float *fp, tmsize_t n)
 
void TIFFSwabArrayOfDouble (double *dp, tmsize_t n)
 
void TIFFReverseBits (uint8 *cp, tmsize_t n)
 
const unsigned charTIFFGetBitRevTable (int)
 
uint64 TIFFGetStrileOffset (TIFF *tif, uint32 strile)
 
uint64 TIFFGetStrileByteCount (TIFF *tif, uint32 strile)
 
uint64 TIFFGetStrileOffsetWithErr (TIFF *tif, uint32 strile, int *pbErr)
 
uint64 TIFFGetStrileByteCountWithErr (TIFF *tif, uint32 strile, int *pbErr)
 
double LogL16toY (int)
 
double LogL10toY (int)
 
void XYZtoRGB24 (float *, uint8 *)
 
int uv_decode (double *, double *, int)
 
void LogLuv24toXYZ (uint32, float *)
 
void LogLuv32toXYZ (uint32, float *)
 
int LogL16fromY (double, int)
 
int LogL10fromY (double, int)
 
int uv_encode (double, double, int)
 
uint32 LogLuv24fromXYZ (float *, int)
 
uint32 LogLuv32fromXYZ (float *, int)
 
int TIFFCIELabToRGBInit (TIFFCIELabToRGB *, const TIFFDisplay *, float *)
 
void TIFFCIELabToXYZ (TIFFCIELabToRGB *, uint32, int32, int32, float *, float *, float *)
 
void TIFFXYZToRGB (TIFFCIELabToRGB *, float, float, float, uint32 *, uint32 *, uint32 *)
 
int TIFFYCbCrToRGBInit (TIFFYCbCrToRGB *, float *, float *)
 
void TIFFYCbCrtoRGB (TIFFYCbCrToRGB *, uint32, int32, int32, uint32 *, uint32 *, uint32 *)
 
int TIFFMergeFieldInfo (TIFF *, const TIFFFieldInfo[], uint32)
 

Macro Definition Documentation

◆ __attribute__

#define __attribute__ (   x)    /*nothing*/

Definition at line 265 of file tiffio.h.

◆ CIELABTORGB_TABLE_RANGE

#define CIELABTORGB_TABLE_RANGE   1500

Definition at line 165 of file tiffio.h.

◆ D50_X0

#define D50_X0   (96.4250F)

Definition at line 130 of file tiffio.h.

◆ D50_Y0

#define D50_Y0   (100.0F)

Definition at line 131 of file tiffio.h.

◆ D50_Z0

#define D50_Z0   (82.4680F)

Definition at line 132 of file tiffio.h.

◆ D65_X0

#define D65_X0   (95.0470F)

Definition at line 126 of file tiffio.h.

◆ D65_Y0

#define D65_Y0   (100.0F)

Definition at line 127 of file tiffio.h.

◆ D65_Z0

#define D65_Z0   (108.8827F)

Definition at line 128 of file tiffio.h.

◆ FIELD_CUSTOM

#define FIELD_CUSTOM   65

Definition at line 312 of file tiffio.h.

◆ LOGLUV_PUBLIC

#define LOGLUV_PUBLIC   1

Definition at line 261 of file tiffio.h.

◆ TIFF_ANY

#define TIFF_ANY   TIFF_NOTYPE /* for field descriptor searching */

Definition at line 307 of file tiffio.h.

◆ TIFF_SPP

#define TIFF_SPP   -2 /* marker for SamplesPerPixel tags */

Definition at line 309 of file tiffio.h.

◆ TIFF_VARIABLE

#define TIFF_VARIABLE   -1 /* marker for variable length tags */

Definition at line 308 of file tiffio.h.

◆ TIFF_VARIABLE2

#define TIFF_VARIABLE2   -3 /* marker for uint32 var-length tags */

Definition at line 310 of file tiffio.h.

◆ TIFFGetA

#define TIFFGetA (   abgr)    (((abgr) >> 24) & 0xff)

Definition at line 240 of file tiffio.h.

◆ TIFFGetB

#define TIFFGetB (   abgr)    (((abgr) >> 16) & 0xff)

Definition at line 239 of file tiffio.h.

◆ TIFFGetG

#define TIFFGetG (   abgr)    (((abgr) >> 8) & 0xff)

Definition at line 238 of file tiffio.h.

◆ TIFFGetR

#define TIFFGetR (   abgr)    ((abgr) & 0xff)

Definition at line 237 of file tiffio.h.

◆ TIFFPRINT_COLORMAP

#define TIFFPRINT_COLORMAP   0x4 /* colormap */

Definition at line 116 of file tiffio.h.

◆ TIFFPRINT_CURVES

#define TIFFPRINT_CURVES   0x2 /* color/gray response curves */

Definition at line 115 of file tiffio.h.

◆ TIFFPRINT_JPEGACTABLES

#define TIFFPRINT_JPEGACTABLES   0x200 /* JPEG AC tables */

Definition at line 118 of file tiffio.h.

◆ TIFFPRINT_JPEGDCTABLES

#define TIFFPRINT_JPEGDCTABLES   0x200 /* JPEG DC tables */

Definition at line 119 of file tiffio.h.

◆ TIFFPRINT_JPEGQTABLES

#define TIFFPRINT_JPEGQTABLES   0x100 /* JPEG Q matrices */

Definition at line 117 of file tiffio.h.

◆ TIFFPRINT_NONE

#define TIFFPRINT_NONE   0x0 /* no extra info */

Definition at line 113 of file tiffio.h.

◆ TIFFPRINT_STRIPS

#define TIFFPRINT_STRIPS   0x1 /* strips/tiles info */

Definition at line 114 of file tiffio.h.

◆ U_NEU

#define U_NEU   0.210526316

Definition at line 502 of file tiffio.h.

◆ UVSCALE

#define UVSCALE   410.

Definition at line 504 of file tiffio.h.

◆ V_NEU

#define V_NEU   0.473684211

Definition at line 503 of file tiffio.h.

Typedef Documentation

◆ tdata_t

typedef void* tdata_t

Definition at line 76 of file tiffio.h.

◆ tdir_t

typedef uint16 tdir_t

Definition at line 70 of file tiffio.h.

◆ thandle_t

typedef void* thandle_t

Definition at line 104 of file tiffio.h.

◆ TIFF

typedef struct tiff TIFF

Definition at line 38 of file tiffio.h.

◆ TIFFCloseProc

typedef int(* TIFFCloseProc) (thandle_t)

Definition at line 275 of file tiffio.h.

◆ TIFFErrorHandler

typedef void(* TIFFErrorHandler) (const char *, const char *, va_list)

Definition at line 271 of file tiffio.h.

◆ TIFFErrorHandlerExt

typedef void(* TIFFErrorHandlerExt) (thandle_t, const char *, const char *, va_list)

Definition at line 272 of file tiffio.h.

◆ TIFFExtendProc

typedef void(* TIFFExtendProc) (TIFF *)

Definition at line 279 of file tiffio.h.

◆ TIFFField

Definition at line 314 of file tiffio.h.

◆ TIFFFieldArray

Definition at line 315 of file tiffio.h.

◆ TIFFInitMethod

typedef int(* TIFFInitMethod) (TIFF *, int)

Definition at line 249 of file tiffio.h.

◆ TIFFMapFileProc

typedef int(* TIFFMapFileProc) (thandle_t, void **base, toff_t *size)

Definition at line 277 of file tiffio.h.

◆ TIFFPrintMethod

typedef void(* TIFFPrintMethod) (TIFF *, FILE *, long)

Definition at line 330 of file tiffio.h.

◆ TIFFReadWriteProc

typedef tmsize_t(* TIFFReadWriteProc) (thandle_t, void *, tmsize_t)

Definition at line 273 of file tiffio.h.

◆ TIFFRGBAImage

Definition at line 177 of file tiffio.h.

◆ TIFFRGBValue

Definition at line 136 of file tiffio.h.

◆ TIFFSeekProc

typedef toff_t(* TIFFSeekProc) (thandle_t, toff_t, int)

Definition at line 274 of file tiffio.h.

◆ TIFFSizeProc

typedef toff_t(* TIFFSizeProc) (thandle_t)

Definition at line 276 of file tiffio.h.

◆ TIFFUnmapFileProc

typedef void(* TIFFUnmapFileProc) (thandle_t, void *base, toff_t size)

Definition at line 278 of file tiffio.h.

◆ TIFFVGetMethod

typedef int(* TIFFVGetMethod) (TIFF *, uint32, va_list)

Definition at line 329 of file tiffio.h.

◆ TIFFVSetMethod

typedef int(* TIFFVSetMethod) (TIFF *, uint32, va_list)

Definition at line 328 of file tiffio.h.

◆ tileContigRoutine

typedef void(* tileContigRoutine) (TIFFRGBAImage *, uint32 *, uint32, uint32, uint32, uint32, int32, int32, unsigned char *)

Definition at line 188 of file tiffio.h.

◆ tileSeparateRoutine

typedef void(* tileSeparateRoutine) (TIFFRGBAImage *, uint32 *, uint32, uint32, uint32, uint32, int32, int32, unsigned char *, unsigned char *, unsigned char *, unsigned char *)

Definition at line 191 of file tiffio.h.

◆ tmsize_t

Definition at line 65 of file tiffio.h.

◆ toff_t

typedef uint64 toff_t

Definition at line 66 of file tiffio.h.

◆ tsample_t

typedef uint16 tsample_t

Definition at line 71 of file tiffio.h.

◆ tsize_t

typedef tmsize_t tsize_t

Definition at line 75 of file tiffio.h.

◆ tstrile_t

typedef uint32 tstrile_t

Definition at line 72 of file tiffio.h.

◆ tstrip_t

Definition at line 73 of file tiffio.h.

◆ ttag_t

typedef uint32 ttag_t

Definition at line 69 of file tiffio.h.

◆ ttile_t

typedef tstrile_t ttile_t

Definition at line 74 of file tiffio.h.

Function Documentation

◆ _TIFFcalloc()

void * _TIFFcalloc ( tmsize_t  nmemb,
tmsize_t  siz 
)

Definition at line 317 of file tif_unix.c.

318{
319 if( nmemb == 0 || siz == 0 )
320 return ((void *) NULL);
321
322 return calloc((size_t) nmemb, (size_t)siz);
323}
#define NULL
Definition: types.h:112
#define calloc
Definition: rosglue.h:14

Referenced by TIFFReadBufferSetup(), and TIFFReadDirectory().

◆ _TIFFfree()

void _TIFFfree ( void p)

Definition at line 326 of file tif_unix.c.

327{
328 free(p);
329}
#define free
Definition: debug_ros.c:5
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by _TIFFCreateAnonField(), _TIFFFetchStrileValue(), _TIFFFillStrilesInternal(), _TIFFRewriteField(), _TIFFSetupFields(), _TIFFVSetField(), allocChoppedUpStripArrays(), EstimateStripByteCounts(), fpAcc(), fpDiff(), gtStripContig(), gtStripSeparate(), gtTileContig(), gtTileSeparate(), initCIELabConversion(), PredictorEncodeTile(), setByteArray(), setDoubleArrayOneValue(), setExtraSamples(), setupMap(), TIFFCleanup(), TIFFClientOpen(), TIFFDefaultDirectory(), TIFFDefaultTransferFunction(), TIFFFetchDirectory(), TIFFFetchNormalTag(), TIFFFetchStripThing(), TIFFFillStrip(), TIFFFillTile(), TIFFFreeDirectory(), TIFFGetConfiguredCODECs(), TIFFGrowStrips(), TIFFOpenW(), TIFFPrintDirectory(), TIFFReadAndRealloc(), TIFFReadBufferSetup(), TIFFReadCustomDirectory(), TIFFReadDirectory(), TIFFReadDirEntryArrayWithLimit(), TIFFReadDirEntryByteArray(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntryFloatArray(), TIFFReadDirEntryIfd8Array(), TIFFReadDirEntryLong8ArrayWithLimit(), TIFFReadDirEntryLongArray(), TIFFReadDirEntryPersampleShort(), TIFFReadDirEntrySbyteArray(), TIFFReadDirEntryShortArray(), TIFFReadDirEntrySlong8Array(), TIFFReadDirEntrySlongArray(), TIFFReadDirEntrySshortArray(), TIFFRGBAImageEnd(), TIFFUnlinkDirectory(), TIFFUnRegisterCODEC(), TIFFUnsetField(), TIFFWriteBufferSetup(), TIFFWriteDirectorySec(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagIfdIfd8Array(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagSampleformatArray(), TIFFWriteDirectoryTagShortPerSample(), TIFFWriteDirectoryTagSubifd(), and TIFFWriteDirectoryTagTransferfunction().

◆ _TIFFmalloc()

void * _TIFFmalloc ( tmsize_t  s)

◆ _TIFFmemcmp()

int _TIFFmemcmp ( const void p1,
const void p2,
tmsize_t  c 
)

Definition at line 350 of file tif_unix.c.

351{
352 return (memcmp(p1, p2, (size_t) c));
353}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
const GLubyte * c
Definition: glext.h:8905

Referenced by TIFFWriteDirectoryTagTransferfunction().

◆ _TIFFmemcpy()

◆ _TIFFmemset()

◆ _TIFFrealloc()

void * _TIFFrealloc ( void p,
tmsize_t  s 
)

Definition at line 332 of file tif_unix.c.

333{
334 return (realloc(p, (size_t) s));
335}
#define realloc
Definition: debug_ros.c:6

Referenced by _TIFFCheckRealloc(), _TIFFFetchStrileValue(), _TIFFVSetField(), TIFFGetConfiguredCODECs(), TIFFGrowStrips(), TIFFReadAndRealloc(), and TIFFReadDirEntryDataAndRealloc().

◆ LogL10fromY()

int LogL10fromY ( double  ,
int   
)

◆ LogL10toY()

double LogL10toY ( int  )

◆ LogL16fromY()

int LogL16fromY ( double  ,
int   
)

◆ LogL16toY()

double LogL16toY ( int  )

◆ LogLuv24fromXYZ()

uint32 LogLuv24fromXYZ ( float ,
int   
)

◆ LogLuv24toXYZ()

void LogLuv24toXYZ ( uint32  ,
float  
)

◆ LogLuv32fromXYZ()

uint32 LogLuv32fromXYZ ( float ,
int   
)

◆ LogLuv32toXYZ()

void LogLuv32toXYZ ( uint32  ,
float  
)

◆ TIFFAccessTagMethods()

TIFFTagMethods * TIFFAccessTagMethods ( TIFF tif)

Definition at line 58 of file tif_extension.c.

60{
61 return &(tif->tif_tagmethods);
62}
TIFFTagMethods tif_tagmethods
Definition: tiffiop.h:219

◆ TIFFCheckpointDirectory()

int TIFFCheckpointDirectory ( TIFF tif)

Definition at line 237 of file tif_dirwrite.c.

238{
239 int rc;
240 /* Setup the strips arrays, if they haven't already been. */
241 if (tif->tif_dir.td_stripoffset_p == NULL)
242 (void) TIFFSetupStrips(tif);
245 return rc;
246}
#define SEEK_END
Definition: cabinet.c:29
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
uint64 * td_stripoffset_p
Definition: tif_dir.h:101
TIFFDirectory tif_dir
Definition: tiffiop.h:151
static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, uint64 *pdiroff)
Definition: tif_dirwrite.c:407
void TIFFSetWriteOffset(TIFF *tif, toff_t off)
Definition: tif_write.c:834
int TIFFSetupStrips(TIFF *tif)
Definition: tif_write.c:523
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:237

◆ TIFFCheckTile()

int TIFFCheckTile ( TIFF tif,
uint32  x,
uint32  y,
uint32  z,
uint16  s 
)

Definition at line 73 of file tif_tile.c.

74{
75 TIFFDirectory *td = &tif->tif_dir;
76
77 if (x >= td->td_imagewidth) {
79 "%lu: Col out of range, max %lu",
80 (unsigned long) x,
81 (unsigned long) (td->td_imagewidth - 1));
82 return (0);
83 }
84 if (y >= td->td_imagelength) {
86 "%lu: Row out of range, max %lu",
87 (unsigned long) y,
88 (unsigned long) (td->td_imagelength - 1));
89 return (0);
90 }
91 if (z >= td->td_imagedepth) {
93 "%lu: Depth out of range, max %lu",
94 (unsigned long) z,
95 (unsigned long) (td->td_imagedepth - 1));
96 return (0);
97 }
99 s >= td->td_samplesperpixel) {
101 "%lu: Sample out of range, max %lu",
102 (unsigned long) s,
103 (unsigned long) (td->td_samplesperpixel - 1));
104 return (0);
105 }
106 return (1);
107}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874
uint16 td_samplesperpixel
Definition: tif_dir.h:82
uint32 td_imagedepth
Definition: tif_dir.h:72
uint32 td_imagewidth
Definition: tif_dir.h:72
uint16 td_planarconfig
Definition: tif_dir.h:89
uint32 td_imagelength
Definition: tif_dir.h:72
thandle_t tif_clientdata
Definition: tiffiop.h:207
char * tif_name
Definition: tiffiop.h:116
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
#define PLANARCONFIG_SEPARATE
Definition: tiff.h:240

Referenced by _TIFFReadTileAndAllocBuffer(), TIFFReadTile(), and TIFFWriteTile().

◆ TIFFCIELabToRGBInit()

int TIFFCIELabToRGBInit ( TIFFCIELabToRGB cielab,
const TIFFDisplay display,
float refWhite 
)

Definition at line 123 of file tif_color.c.

125{
126 int i;
127 double dfGamma;
128
130
131 _TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay));
132
133 /* Red */
134 dfGamma = 1.0 / cielab->display.d_gammaR ;
135 cielab->rstep =
136 (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
137 for(i = 0; i <= cielab->range; i++) {
138 cielab->Yr2r[i] = cielab->display.d_Vrwr
139 * ((float)pow((double)i / cielab->range, dfGamma));
140 }
141
142 /* Green */
143 dfGamma = 1.0 / cielab->display.d_gammaG ;
144 cielab->gstep =
145 (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
146 for(i = 0; i <= cielab->range; i++) {
147 cielab->Yg2g[i] = cielab->display.d_Vrwg
148 * ((float)pow((double)i / cielab->range, dfGamma));
149 }
150
151 /* Blue */
152 dfGamma = 1.0 / cielab->display.d_gammaB ;
153 cielab->bstep =
154 (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
155 for(i = 0; i <= cielab->range; i++) {
156 cielab->Yb2b[i] = cielab->display.d_Vrwb
157 * ((float)pow((double)i / cielab->range, dfGamma));
158 }
159
160 /* Init reference white point */
161 cielab->X0 = refWhite[0];
162 cielab->Y0 = refWhite[1];
163 cielab->Z0 = refWhite[2];
164
165 return 0;
166}
double pow(double x, double y)
Definition: freeldr.c:112
GLenum GLint * range
Definition: glext.h:7539
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static float(__cdecl *square_half_float)(float x
float Yb2b[CIELABTORGB_TABLE_RANGE+1]
Definition: tiffio.h:171
float bstep
Definition: tiffio.h:166
TIFFDisplay display
Definition: tiffio.h:168
float rstep
Definition: tiffio.h:166
float gstep
Definition: tiffio.h:166
float Yr2r[CIELABTORGB_TABLE_RANGE+1]
Definition: tiffio.h:169
float Yg2g[CIELABTORGB_TABLE_RANGE+1]
Definition: tiffio.h:170
uint32 d_Vrwr
Definition: tiffio.h:143
float d_gammaG
Definition: tiffio.h:150
uint32 d_Vrwb
Definition: tiffio.h:145
float d_Y0R
Definition: tiffio.h:146
float d_gammaR
Definition: tiffio.h:149
float d_YCR
Definition: tiffio.h:140
float d_gammaB
Definition: tiffio.h:151
uint32 d_Vrwg
Definition: tiffio.h:144
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344
#define CIELABTORGB_TABLE_RANGE
Definition: tiffio.h:165
int * display
Definition: x11stubs.c:12

Referenced by initCIELabConversion().

◆ TIFFCIELabToXYZ()

void TIFFCIELabToXYZ ( TIFFCIELabToRGB cielab,
uint32  l,
int32  a,
int32  b,
float X,
float Y,
float Z 
)

Definition at line 44 of file tif_color.c.

46{
47 float L = (float)l * 100.0F / 255.0F;
48 float cby, tmp;
49
50 if( L < 8.856F ) {
51 *Y = (L * cielab->Y0) / 903.292F;
52 cby = 7.787F * (*Y / cielab->Y0) + 16.0F / 116.0F;
53 } else {
54 cby = (L + 16.0F) / 116.0F;
55 *Y = cielab->Y0 * cby * cby * cby;
56 }
57
58 tmp = (float)a / 500.0F + cby;
59 if( tmp < 0.2069F )
60 *X = cielab->X0 * (tmp - 0.13793F) / 7.787F;
61 else
62 *X = cielab->X0 * tmp * tmp * tmp;
63
64 tmp = cby - (float)b / 200.0F;
65 if( tmp < 0.2069F )
66 *Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F;
67 else
68 *Z = cielab->Z0 * tmp * tmp * tmp;
69}
r l[0]
Definition: byte_order.h:168
#define Z(I)
#define Y(I)
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define L(x)
Definition: ntvdm.h:50

Referenced by DECLAREContigPutFunc().

◆ TIFFCleanup()

void TIFFCleanup ( TIFF tif)

Auxiliary function to free the TIFF structure. Given structure will be completely freed, so you should save opened file handle and pointer to the close procedure in external variables before calling _TIFFCleanup(), if you will need these ones to close the file.

Parameters
tifA TIFF pointer.

Definition at line 46 of file tif_close.c.

47{
48 /*
49 * Flush buffered data and directory (if dirty).
50 */
51 if (tif->tif_mode != O_RDONLY)
52 TIFFFlush(tif);
53 (*tif->tif_cleanup)(tif);
55
56 if (tif->tif_dirlist)
58
59 /*
60 * Clean up client info links.
61 */
62 while( tif->tif_clientinfo )
63 {
65
66 tif->tif_clientinfo = psLink->next;
67 _TIFFfree( psLink->name );
68 _TIFFfree( psLink );
69 }
70
71 if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
73 if (isMapped(tif))
75
76 /*
77 * Clean up custom fields.
78 */
79 if (tif->tif_fields && tif->tif_nfields > 0) {
80 uint32 i;
81
82 for (i = 0; i < tif->tif_nfields; i++) {
83 TIFFField *fld = tif->tif_fields[i];
84 if (fld->field_bit == FIELD_CUSTOM &&
85 strncmp("Tag ", fld->field_name, 4) == 0) {
87 _TIFFfree(fld);
88 }
89 }
90
92 }
93
94 if (tif->tif_nfieldscompat > 0) {
95 uint32 i;
96
97 for (i = 0; i < tif->tif_nfieldscompat; i++) {
100 }
102 }
103
104 _TIFFfree(tif);
105}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define O_RDONLY
Definition: acwin.h:108
unsigned int uint32
Definition: types.h:32
TIFFField * fields
Definition: tif_dir.h:279
uint32 allocated_size
Definition: tif_dir.h:277
char * field_name
Definition: tif_dir.h:293
unsigned short field_bit
Definition: tif_dir.h:290
struct client_info * next
Definition: tiffiop.h:94
char * name
Definition: tiffiop.h:96
uint64 * tif_dirlist
Definition: tiffiop.h:148
size_t tif_nfields
Definition: tiffiop.h:217
TIFFClientInfoLink * tif_clientinfo
Definition: tiffiop.h:220
TIFFField ** tif_fields
Definition: tiffiop.h:216
uint8 * tif_base
Definition: tiffiop.h:202
uint32 tif_flags
Definition: tiffiop.h:119
tmsize_t tif_size
Definition: tiffiop.h:203
TIFFVoidMethod tif_cleanup
Definition: tiffiop.h:188
size_t tif_nfieldscompat
Definition: tiffiop.h:224
int tif_mode
Definition: tiffiop.h:118
TIFFFieldArray * tif_fieldscompat
Definition: tiffiop.h:223
uint8 * tif_rawdata
Definition: tiffiop.h:195
void TIFFFreeDirectory(TIFF *tif)
Definition: tif_dir.c:1268
int TIFFFlush(TIFF *tif)
Definition: tif_flush.c:32
void _TIFFfree(void *p)
Definition: tif_unix.c:326
uint64 toff_t
Definition: tiffio.h:66
#define FIELD_CUSTOM
Definition: tiffio.h:312
#define TIFF_MYBUFFER
Definition: tiffiop.h:128
#define TIFFUnmapFileContents(tif, addr, size)
Definition: tiffiop.h:245
#define isMapped(tif)
Definition: tiffiop.h:230

Referenced by TIFFClientOpen(), and TIFFClose().

◆ TIFFClientdata()

thandle_t TIFFClientdata ( TIFF tif)

Definition at line 553 of file tif_open.c.

554{
555 return (tif->tif_clientdata);
556}

◆ TIFFClientOpen()

TIFF * TIFFClientOpen ( const char name,
const char mode,
thandle_t  clientdata,
TIFFReadWriteProc  readproc,
TIFFReadWriteProc  writeproc,
TIFFSeekProc  seekproc,
TIFFCloseProc  closeproc,
TIFFSizeProc  sizeproc,
TIFFMapFileProc  mapproc,
TIFFUnmapFileProc  unmapproc 
)

Definition at line 71 of file tif_open.c.

82{
83 static const char module[] = "TIFFClientOpen";
84 TIFF *tif;
85 int m;
86 const char* cp;
87
88 /* The following are configuration checks. They should be redundant, but should not
89 * compile to any actual code in an optimised release build anyway. If any of them
90 * fail, (makefile-based or other) configuration is not correct */
91 assert(sizeof(uint8)==1);
92 assert(sizeof(int8)==1);
93 assert(sizeof(uint16)==2);
94 assert(sizeof(int16)==2);
95 assert(sizeof(uint32)==4);
96 assert(sizeof(int32)==4);
97 assert(sizeof(uint64)==8);
98 assert(sizeof(int64)==8);
99 assert(sizeof(tmsize_t)==sizeof(void*));
100 {
101 union{
102 uint8 a8[2];
103 uint16 a16;
104 } n;
105 n.a8[0]=1;
106 n.a8[1]=0;
107 #ifdef WORDS_BIGENDIAN
108 assert(n.a16==256);
109 #else
110 assert(n.a16==1);
111 #endif
112 }
113
115 if (m == -1)
116 goto bad2;
117 tif = (TIFF *)_TIFFmalloc((tmsize_t)(sizeof (TIFF) + strlen(name) + 1));
118 if (tif == NULL) {
119 TIFFErrorExt(clientdata, module, "%s: Out of memory (TIFF structure)", name);
120 goto bad2;
121 }
122 _TIFFmemset(tif, 0, sizeof (*tif));
123 tif->tif_name = (char *)tif + sizeof (TIFF);
124 strcpy(tif->tif_name, name);
125 tif->tif_mode = m &~ (O_CREAT|O_TRUNC);
126 tif->tif_curdir = (uint16) -1; /* non-existent directory */
127 tif->tif_curoff = 0;
128 tif->tif_curstrip = (uint32) -1; /* invalid strip */
129 tif->tif_row = (uint32) -1; /* read/write pre-increment */
130 tif->tif_clientdata = clientdata;
131 if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) {
132 TIFFErrorExt(clientdata, module,
133 "One of the client procedures is NULL pointer.");
134 _TIFFfree(tif);
135 goto bad2;
136 }
137 tif->tif_readproc = readproc;
138 tif->tif_writeproc = writeproc;
139 tif->tif_seekproc = seekproc;
140 tif->tif_closeproc = closeproc;
141 tif->tif_sizeproc = sizeproc;
142 if (mapproc)
143 tif->tif_mapproc = mapproc;
144 else
146 if (unmapproc)
147 tif->tif_unmapproc = unmapproc;
148 else
150 _TIFFSetDefaultCompressionState(tif); /* setup default state */
151 /*
152 * Default is to return data MSB2LSB and enable the
153 * use of memory-mapped files and strip chopping when
154 * a file is opened read-only.
155 */
157 if (m == O_RDONLY )
158 tif->tif_flags |= TIFF_MAPPED;
159
160 #ifdef STRIPCHOP_DEFAULT
161 if (m == O_RDONLY || m == O_RDWR)
163 #endif
164
165 /*
166 * Process library-specific flags in the open mode string.
167 * The following flags may be used to control intrinsic library
168 * behaviour that may or may not be desirable (usually for
169 * compatibility with some application that claims to support
170 * TIFF but only supports some brain dead idea of what the
171 * vendor thinks TIFF is):
172 *
173 * 'l' use little-endian byte order for creating a file
174 * 'b' use big-endian byte order for creating a file
175 * 'L' read/write information using LSB2MSB bit order
176 * 'B' read/write information using MSB2LSB bit order
177 * 'H' read/write information using host bit order
178 * 'M' enable use of memory-mapped files when supported
179 * 'm' disable use of memory-mapped files
180 * 'C' enable strip chopping support when reading
181 * 'c' disable strip chopping support
182 * 'h' read TIFF header only, do not load the first IFD
183 * '4' ClassicTIFF for creating a file (default)
184 * '8' BigTIFF for creating a file
185 * 'D' enable use of deferred strip/tile offset/bytecount array loading.
186 * 'O' on-demand loading of values instead of whole array loading (implies D)
187 *
188 * The use of the 'l' and 'b' flags is strongly discouraged.
189 * These flags are provided solely because numerous vendors,
190 * typically on the PC, do not correctly support TIFF; they
191 * only support the Intel little-endian byte order. This
192 * support is not configured by default because it supports
193 * the violation of the TIFF spec that says that readers *MUST*
194 * support both byte orders. It is strongly recommended that
195 * you not use this feature except to deal with busted apps
196 * that write invalid TIFF. And even in those cases you should
197 * bang on the vendors to fix their software.
198 *
199 * The 'L', 'B', and 'H' flags are intended for applications
200 * that can optimize operations on data by using a particular
201 * bit order. By default the library returns data in MSB2LSB
202 * bit order for compatibility with older versions of this
203 * library. Returning data in the bit order of the native CPU
204 * makes the most sense but also requires applications to check
205 * the value of the FillOrder tag; something they probably do
206 * not do right now.
207 *
208 * The 'M' and 'm' flags are provided because some virtual memory
209 * systems exhibit poor behaviour when large images are mapped.
210 * These options permit clients to control the use of memory-mapped
211 * files on a per-file basis.
212 *
213 * The 'C' and 'c' flags are provided because the library support
214 * for chopping up large strips into multiple smaller strips is not
215 * application-transparent and as such can cause problems. The 'c'
216 * option permits applications that only want to look at the tags,
217 * for example, to get the unadulterated TIFF tag information.
218 */
219 for (cp = mode; *cp; cp++)
220 switch (*cp) {
221 case 'b':
222 #ifndef WORDS_BIGENDIAN
223 if (m&O_CREAT)
224 tif->tif_flags |= TIFF_SWAB;
225 #endif
226 break;
227 case 'l':
228 #ifdef WORDS_BIGENDIAN
229 if ((m&O_CREAT))
230 tif->tif_flags |= TIFF_SWAB;
231 #endif
232 break;
233 case 'B':
234 tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) |
236 break;
237 case 'L':
238 tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) |
240 break;
241 case 'H':
242 tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) |
244 break;
245 case 'M':
246 if (m == O_RDONLY)
247 tif->tif_flags |= TIFF_MAPPED;
248 break;
249 case 'm':
250 if (m == O_RDONLY)
251 tif->tif_flags &= ~TIFF_MAPPED;
252 break;
253 case 'C':
254 if (m == O_RDONLY)
256 break;
257 case 'c':
258 if (m == O_RDONLY)
259 tif->tif_flags &= ~TIFF_STRIPCHOP;
260 break;
261 case 'h':
263 break;
264 case '8':
265 if (m&O_CREAT)
266 tif->tif_flags |= TIFF_BIGTIFF;
267 break;
268 case 'D':
270 break;
271 case 'O':
272 if( m == O_RDONLY )
274 break;
275 }
276
277#ifdef DEFER_STRILE_LOAD
278 /* Compatibility with old DEFER_STRILE_LOAD compilation flag */
279 /* Probably unneeded, since to the best of my knowledge (E. Rouault) */
280 /* GDAL was the only user of this, and will now use the new 'D' flag */
282#endif
283
284 /*
285 * Read in TIFF header.
286 */
287 if ((m & O_TRUNC) ||
288 !ReadOK(tif, &tif->tif_header, sizeof (TIFFHeaderClassic))) {
289 if (tif->tif_mode == O_RDONLY) {
291 "Cannot read TIFF header");
292 goto bad;
293 }
294 /*
295 * Setup header and write.
296 */
297 #ifdef WORDS_BIGENDIAN
300 #else
303 #endif
304 if (!(tif->tif_flags&TIFF_BIGTIFF))
305 {
308 if (tif->tif_flags & TIFF_SWAB)
310 tif->tif_header_size = sizeof(TIFFHeaderClassic);
311 }
312 else
313 {
316 tif->tif_header.big.tiff_unused = 0;
317 tif->tif_header.big.tiff_diroff = 0;
318 if (tif->tif_flags & TIFF_SWAB)
319 {
322 }
323 tif->tif_header_size = sizeof (TIFFHeaderBig);
324 }
325 /*
326 * The doc for "fopen" for some STD_C_LIBs says that if you
327 * open a file for modify ("+"), then you must fseek (or
328 * fflush?) between any freads and fwrites. This is not
329 * necessary on most systems, but has been shown to be needed
330 * on Solaris.
331 */
332 TIFFSeekFile( tif, 0, SEEK_SET );
333 if (!WriteOK(tif, &tif->tif_header, (tmsize_t)(tif->tif_header_size))) {
335 "Error writing TIFF header");
336 goto bad;
337 }
338 /*
339 * Setup the byte order handling.
340 */
342 #ifndef WORDS_BIGENDIAN
343 tif->tif_flags |= TIFF_SWAB;
344 #endif
345 } else {
346 #ifdef WORDS_BIGENDIAN
347 tif->tif_flags |= TIFF_SWAB;
348 #endif
349 }
350 /*
351 * Setup default directory.
352 */
353 if (!TIFFDefaultDirectory(tif))
354 goto bad;
355 tif->tif_diroff = 0;
356 tif->tif_dirlist = NULL;
357 tif->tif_dirlistsize = 0;
358 tif->tif_dirnumber = 0;
359 return (tif);
360 }
361 /*
362 * Setup the byte order handling.
363 */
366 #if MDI_SUPPORT
367 &&
370 #else
372 #endif
373 ) {
375 "Not a TIFF or MDI file, bad magic number %d (0x%x)",
376 #else
377 ) {
379 "Not a TIFF file, bad magic number %d (0x%x)",
380 #endif
383 goto bad;
384 }
386 #ifndef WORDS_BIGENDIAN
387 tif->tif_flags |= TIFF_SWAB;
388 #endif
389 } else {
390 #ifdef WORDS_BIGENDIAN
391 tif->tif_flags |= TIFF_SWAB;
392 #endif
393 }
394 if (tif->tif_flags & TIFF_SWAB)
399 "Not a TIFF file, bad version number %d (0x%x)",
402 goto bad;
403 }
405 {
406 if (tif->tif_flags & TIFF_SWAB)
408 tif->tif_header_size = sizeof(TIFFHeaderClassic);
409 }
410 else
411 {
412 if (!ReadOK(tif, ((uint8*)(&tif->tif_header) + sizeof(TIFFHeaderClassic)), (sizeof(TIFFHeaderBig)-sizeof(TIFFHeaderClassic))))
413 {
415 "Cannot read TIFF header");
416 goto bad;
417 }
418 if (tif->tif_flags & TIFF_SWAB)
419 {
422 }
423 if (tif->tif_header.big.tiff_offsetsize != 8)
424 {
426 "Not a TIFF file, bad BigTIFF offsetsize %d (0x%x)",
429 goto bad;
430 }
431 if (tif->tif_header.big.tiff_unused != 0)
432 {
434 "Not a TIFF file, bad BigTIFF unused %d (0x%x)",
437 goto bad;
438 }
439 tif->tif_header_size = sizeof(TIFFHeaderBig);
440 tif->tif_flags |= TIFF_BIGTIFF;
441 }
442 tif->tif_flags |= TIFF_MYBUFFER;
443 tif->tif_rawcp = tif->tif_rawdata = 0;
444 tif->tif_rawdatasize = 0;
445 tif->tif_rawdataoff = 0;
446 tif->tif_rawdataloaded = 0;
447
448 switch (mode[0]) {
449 case 'r':
450 if (!(tif->tif_flags&TIFF_BIGTIFF))
452 else
454 /*
455 * Try to use a memory-mapped file if the client
456 * has not explicitly suppressed usage with the
457 * 'm' flag in the open mode (see above).
458 */
459 if (tif->tif_flags & TIFF_MAPPED)
460 {
461 toff_t n;
462 if (TIFFMapFileContents(tif,(void**)(&tif->tif_base),&n))
463 {
464 tif->tif_size=(tmsize_t)n;
465 assert((toff_t)tif->tif_size==n);
466 }
467 else
468 tif->tif_flags &= ~TIFF_MAPPED;
469 }
470 /*
471 * Sometimes we do not want to read the first directory (for example,
472 * it may be broken) and want to proceed to other directories. I this
473 * case we use the TIFF_HEADERONLY flag to open file and return
474 * immediately after reading TIFF header.
475 */
476 if (tif->tif_flags & TIFF_HEADERONLY)
477 return (tif);
478
479 /*
480 * Setup initial directory.
481 */
482 if (TIFFReadDirectory(tif)) {
483 tif->tif_rawcc = (tmsize_t)-1;
485 return (tif);
486 }
487 break;
488 case 'a':
489 /*
490 * New directories are automatically append
491 * to the end of the directory chain when they
492 * are written out (see TIFFWriteDirectory).
493 */
494 if (!TIFFDefaultDirectory(tif))
495 goto bad;
496 return (tif);
497 }
498bad:
499 tif->tif_mode = O_RDONLY; /* XXX avoid flush */
500 TIFFCleanup(tif);
501bad2:
502 return ((TIFF*)0);
503}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define O_CREAT
Definition: acwin.h:110
#define O_TRUNC
Definition: acwin.h:112
unsigned short uint16
Definition: types.h:30
unsigned char uint8
Definition: types.h:28
#define assert(x)
Definition: debug.h:53
unsigned long long uint64
Definition: platform.h:18
short int16
Definition: platform.h:11
long int32
Definition: platform.h:12
char int8
Definition: platform.h:10
long long int64
Definition: platform.h:13
GLdouble n
Definition: glext.h:7729
GLenum mode
Definition: glext.h:6217
const GLfloat * m
Definition: glext.h:10848
#define O_RDWR
Definition: fcntl.h:36
#define SEEK_SET
Definition: jmemansi.c:26
if(dx< 0)
Definition: linetemp.h:194
POINT cp
Definition: magnifier.c:59
static BOOL readproc(HANDLE proc, LPVOID address, PVOID target, DWORD size)
Definition: env.c:191
uint64 tiff_diroff
Definition: tiff.h:105
uint16 tiff_offsetsize
Definition: tiff.h:103
uint16 tiff_unused
Definition: tiff.h:104
uint32 tiff_diroff
Definition: tiff.h:98
uint16 tiff_version
Definition: tiff.h:93
uint16 tiff_magic
Definition: tiff.h:92
Definition: name.c:39
Definition: tiffiop.h:115
TIFFReadWriteProc tif_readproc
Definition: tiffiop.h:208
TIFFReadWriteProc tif_writeproc
Definition: tiffiop.h:209
uint16 tif_dirnumber
Definition: tiffiop.h:150
TIFFUnmapFileProc tif_unmapproc
Definition: tiffiop.h:205
TIFFHeaderClassic classic
Definition: tiffiop.h:155
TIFFSeekProc tif_seekproc
Definition: tiffiop.h:210
TIFFHeaderBig big
Definition: tiffiop.h:156
tmsize_t tif_rawdataloaded
Definition: tiffiop.h:198
tmsize_t tif_rawcc
Definition: tiffiop.h:200
TIFFCloseProc tif_closeproc
Definition: tiffiop.h:211
uint16 tif_curdir
Definition: tiffiop.h:160
uint64 tif_nextdiroff
Definition: tiffiop.h:147
uint32 tif_curstrip
Definition: tiffiop.h:161
uint32 tif_row
Definition: tiffiop.h:159
TIFFMapFileProc tif_mapproc
Definition: tiffiop.h:204
uint64 tif_diroff
Definition: tiffiop.h:146
tmsize_t tif_rawdatasize
Definition: tiffiop.h:196
union tiff::@3468 tif_header
tmsize_t tif_rawdataoff
Definition: tiffiop.h:197
uint8 * tif_rawcp
Definition: tiffiop.h:199
uint16 tif_header_size
Definition: tiffiop.h:158
uint64 tif_curoff
Definition: tiffiop.h:162
TIFFSizeProc tif_sizeproc
Definition: tiffiop.h:212
uint16 tif_dirlistsize
Definition: tiffiop.h:149
TIFFHeaderCommon common
Definition: tiffiop.h:154
void TIFFCleanup(TIFF *tif)
Definition: tif_close.c:46
void _TIFFSetDefaultCompressionState(TIFF *tif)
Definition: tif_compress.c:135
#define HOST_FILLORDER
Definition: tif_config.h:113
int TIFFDefaultDirectory(TIFF *tif)
Definition: tif_dir.c:1372
int TIFFReadDirectory(TIFF *tif)
Definition: tif_dirread.c:3574
static void _tiffDummyUnmapProc(thandle_t fd, void *base, toff_t size)
Definition: tif_open.c:41
int _TIFFgetMode(const char *mode, const char *module)
Definition: tif_open.c:47
static int _tiffDummyMapProc(thandle_t fd, void **pbase, toff_t *psize)
Definition: tif_open.c:34
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57
void _TIFFmemset(void *p, int v, tmsize_t c)
Definition: tif_unix.c:338
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
#define FILLORDER_LSB2MSB
Definition: tiff.h:216
#define TIFF_LITTLEENDIAN
Definition: tiff.h:52
#define MDI_LITTLEENDIAN
Definition: tiff.h:53
#define FILLORDER_MSB2LSB
Definition: tiff.h:215
#define MDI_BIGENDIAN
Definition: tiff.h:54
#define TIFF_VERSION_BIG
Definition: tiff.h:49
#define TIFF_VERSION_CLASSIC
Definition: tiff.h:48
#define TIFF_BIGENDIAN
Definition: tiff.h:51
#define HOST_BIGENDIAN
Definition: tiffconf.h:86
#define STRIPCHOP_DEFAULT
Definition: tiffconf.h:124
#define MDI_SUPPORT
Definition: tiffconf.h:139
struct tiff TIFF
Definition: tiffio.h:38
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
#define TIFF_LAZYSTRILELOAD
Definition: tiffiop.h:144
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:259
#define TIFF_BUFFERSETUP
Definition: tiffiop.h:123
#define ReadOK(tif, buf, size)
Definition: tiffiop.h:252
#define TIFF_HEADERONLY
Definition: tiffiop.h:135
#define TIFFMapFileContents(tif, paddr, psize)
Definition: tiffiop.h:243
#define TIFF_STRIPCHOP
Definition: tiffiop.h:134
#define TIFF_DEFERSTRILELOAD
Definition: tiffiop.h:143
#define TIFF_MAPPED
Definition: tiffiop.h:130
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:126
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by _tiffStreamOpen(), and TIFFFdOpen().

◆ TIFFClose()

void TIFFClose ( TIFF tif)

Close a previously opened TIFF file.

TIFFClose closes a file that was previously opened with TIFFOpen(). Any buffered data are flushed to the file, including the contents of the current directory (if modified); and all resources are reclaimed.

Parameters
tifA TIFF pointer.

Definition at line 122 of file tif_close.c.

123{
124 TIFFCloseProc closeproc = tif->tif_closeproc;
126
127 TIFFCleanup(tif);
128 (void) (*closeproc)(fd);
129}
static int fd
Definition: io.c:51
int(* TIFFCloseProc)(thandle_t)
Definition: tiffio.h:275

◆ TIFFComputeStrip()

uint32 TIFFComputeStrip ( TIFF tif,
uint32  row,
uint16  sample 
)

Definition at line 36 of file tif_strip.c.

37{
38 static const char module[] = "TIFFComputeStrip";
39 TIFFDirectory *td = &tif->tif_dir;
40 uint32 strip;
41
42 strip = row / td->td_rowsperstrip;
44 if (sample >= td->td_samplesperpixel) {
46 "%lu: Sample out of range, max %lu",
47 (unsigned long) sample, (unsigned long) td->td_samplesperpixel);
48 return (0);
49 }
50 strip += (uint32)sample*td->td_stripsperimage;
51 }
52 return (strip);
53}
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
uint32 td_rowsperstrip
Definition: tif_dir.h:83
uint32 td_stripsperimage
Definition: tif_dir.h:99

Referenced by gtStripContig(), and gtStripSeparate().

◆ TIFFComputeTile()

uint32 TIFFComputeTile ( TIFF tif,
uint32  x,
uint32  y,
uint32  z,
uint16  s 
)

Definition at line 36 of file tif_tile.c.

37{
38 TIFFDirectory *td = &tif->tif_dir;
41 uint32 dz = td->td_tiledepth;
42 uint32 tile = 1;
43
44 if (td->td_imagedepth == 1)
45 z = 0;
46 if (dx == (uint32) -1)
47 dx = td->td_imagewidth;
48 if (dy == (uint32) -1)
49 dy = td->td_imagelength;
50 if (dz == (uint32) -1)
51 dz = td->td_imagedepth;
52 if (dx != 0 && dy != 0 && dz != 0) {
55 uint32 zpt = TIFFhowmany_32(td->td_imagedepth, dz);
56
58 tile = (xpt*ypt*zpt)*s +
59 (xpt*ypt)*(z/dz) +
60 xpt*(y/dy) +
61 x/dx;
62 else
63 tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx;
64 }
65 return (tile);
66}
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
uint32 td_tiledepth
Definition: tif_dir.h:73
uint32 td_tilelength
Definition: tif_dir.h:73
uint32 td_tilewidth
Definition: tif_dir.h:73
#define TIFFhowmany_32(x, y)
Definition: tiffiop.h:264

Referenced by _TIFFReadTileAndAllocBuffer(), TIFFReadTile(), and TIFFWriteTile().

◆ TIFFCreateCustomDirectory()

int TIFFCreateCustomDirectory ( TIFF tif,
const TIFFFieldArray infoarray 
)

Definition at line 1340 of file tif_dir.c.

1341{
1343
1344 /*
1345 * Reset the field definitions to match the application provided list.
1346 * Hopefully TIFFDefaultDirectory() won't have done anything irreversable
1347 * based on it's assumption this is an image directory.
1348 */
1349 _TIFFSetupFields(tif, infoarray);
1350
1351 tif->tif_diroff = 0;
1352 tif->tif_nextdiroff = 0;
1353 tif->tif_curoff = 0;
1354 tif->tif_row = (uint32) -1;
1355 tif->tif_curstrip = (uint32) -1;
1356
1357 return 0;
1358}
void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *fieldarray)
Definition: tif_dirinfo.c:317

Referenced by TIFFCreateEXIFDirectory().

◆ TIFFCreateDirectory()

int TIFFCreateDirectory ( TIFF tif)

Definition at line 1327 of file tif_dir.c.

1328{
1330 tif->tif_diroff = 0;
1331 tif->tif_nextdiroff = 0;
1332 tif->tif_curoff = 0;
1333 tif->tif_row = (uint32) -1;
1334 tif->tif_curstrip = (uint32) -1;
1335
1336 return 0;
1337}

Referenced by TIFFWriteDirectorySec().

◆ TIFFCreateEXIFDirectory()

int TIFFCreateEXIFDirectory ( TIFF tif)

Definition at line 1361 of file tif_dir.c.

1362{
1366}
int TIFFCreateCustomDirectory(TIFF *tif, const TIFFFieldArray *infoarray)
Definition: tif_dir.c:1340
static const TIFFFieldArray exifFieldArray
Definition: tif_dirinfo.c:49
const TIFFFieldArray * _TIFFGetExifFields(void)
Definition: tif_dirinfo.c:311

◆ TIFFCurrentDirectory()

uint16 TIFFCurrentDirectory ( TIFF tif)

Definition at line 612 of file tif_open.c.

613{
614 return (tif->tif_curdir);
615}

◆ TIFFCurrentDirOffset()

uint64 TIFFCurrentDirOffset ( TIFF tif)

Definition at line 1666 of file tif_dir.c.

1667{
1668 return (tif->tif_diroff);
1669}

◆ TIFFCurrentRow()

uint32 TIFFCurrentRow ( TIFF tif)

Definition at line 603 of file tif_open.c.

604{
605 return (tif->tif_row);
606}

◆ TIFFCurrentStrip()

uint32 TIFFCurrentStrip ( TIFF tif)

Definition at line 621 of file tif_open.c.

622{
623 return (tif->tif_curstrip);
624}

◆ TIFFCurrentTile()

uint32 TIFFCurrentTile ( TIFF tif)

Definition at line 630 of file tif_open.c.

631{
632 return (tif->tif_curtile);
633}
uint32 tif_curtile
Definition: tiffiop.h:169

◆ TIFFDataWidth()

int TIFFDataWidth ( TIFFDataType  type)

Definition at line 438 of file tif_dirinfo.c.

439{
440 switch(type)
441 {
442 case 0: /* nothing */
443 case TIFF_BYTE:
444 case TIFF_ASCII:
445 case TIFF_SBYTE:
446 case TIFF_UNDEFINED:
447 return 1;
448 case TIFF_SHORT:
449 case TIFF_SSHORT:
450 return 2;
451 case TIFF_LONG:
452 case TIFF_SLONG:
453 case TIFF_FLOAT:
454 case TIFF_IFD:
455 return 4;
456 case TIFF_RATIONAL:
457 case TIFF_SRATIONAL:
458 case TIFF_DOUBLE:
459 case TIFF_LONG8:
460 case TIFF_SLONG8:
461 case TIFF_IFD8:
462 return 8;
463 default:
464 return 0; /* will return 0 for unknown types */
465 }
466}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
@ TIFF_SSHORT
Definition: tiff.h:132
@ TIFF_SLONG
Definition: tiff.h:133
@ TIFF_BYTE
Definition: tiff.h:125
@ TIFF_SBYTE
Definition: tiff.h:130
@ TIFF_IFD
Definition: tiff.h:137
@ TIFF_SHORT
Definition: tiff.h:127
@ TIFF_UNDEFINED
Definition: tiff.h:131
@ TIFF_LONG
Definition: tiff.h:128
@ TIFF_SLONG8
Definition: tiff.h:139
@ TIFF_LONG8
Definition: tiff.h:138
@ TIFF_ASCII
Definition: tiff.h:126
@ TIFF_FLOAT
Definition: tiff.h:135
@ TIFF_DOUBLE
Definition: tiff.h:136
@ TIFF_IFD8
Definition: tiff.h:140
@ TIFF_SRATIONAL
Definition: tiff.h:134
@ TIFF_RATIONAL
Definition: tiff.h:129

Referenced by _TIFFRewriteField(), EstimateStripByteCounts(), and TIFFReadDirEntryArrayWithLimit().

◆ TIFFDefaultStripSize()

uint32 TIFFDefaultStripSize ( TIFF tif,
uint32  request 
)

Definition at line 217 of file tif_strip.c.

218{
219 return (*tif->tif_defstripsize)(tif, request);
220}
Definition: tftpd.h:86
TIFFStripMethod tif_defstripsize
Definition: tiffiop.h:189

◆ TIFFDefaultTileSize()

void TIFFDefaultTileSize ( TIFF tif,
uint32 tw,
uint32 th 
)

Definition at line 272 of file tif_tile.c.

273{
274 (*tif->tif_deftilesize)(tif, tw, th);
275}
TIFFTileMethod tif_deftilesize
Definition: tiffiop.h:190

◆ TIFFDeferStrileArrayWriting()

int TIFFDeferStrileArrayWriting ( TIFF tif)

Definition at line 210 of file tif_dirwrite.c.

211{
212 static const char module[] = "TIFFDeferStrileArrayWriting";
213 if (tif->tif_mode == O_RDONLY)
214 {
216 "File opened in read-only mode");
217 return 0;
218 }
219 if( tif->tif_diroff != 0 )
220 {
222 "Directory has already been written");
223 return 0;
224 }
225
227 return 1;
228}
unsigned char td_deferstrilearraywriting
Definition: tif_dir.h:124

◆ TIFFError()

void TIFFError ( const char ,
const char ,
  ... 
)

◆ TIFFErrorExt()

void void TIFFErrorExt ( thandle_t  ,
const char ,
const char ,
  ... 
)

◆ TIFFFdOpen()

TIFF * TIFFFdOpen ( int  fd,
const char name,
const char mode 
)

Definition at line 203 of file tif_unix.c.

204{
205 TIFF* tif;
206
208 fdh.fd = fd;
209 tif = TIFFClientOpen(name, mode,
210 fdh.h,
214 if (tif)
215 tif->tif_fd = fd;
216 return (tif);
217}
int tif_fd
Definition: tiffiop.h:117
TIFF * TIFFClientOpen(const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc)
Definition: tif_open.c:71
static tmsize_t _tiffReadProc(thandle_t fd, void *buf, tmsize_t size)
Definition: tif_unix.c:67
static void _tiffUnmapProc(thandle_t fd, void *base, toff_t size)
Definition: tif_unix.c:193
static tmsize_t _tiffWriteProc(thandle_t fd, void *buf, tmsize_t size)
Definition: tif_unix.c:95
static uint64 _tiffSeekProc(thandle_t fd, uint64 off, int whence)
Definition: tif_unix.c:124
static int _tiffCloseProc(thandle_t fd)
Definition: tif_unix.c:138
static int _tiffMapProc(thandle_t fd, void **pbase, toff_t *psize)
Definition: tif_unix.c:186
static uint64 _tiffSizeProc(thandle_t fd)
Definition: tif_unix.c:146
thandle_t h
Definition: tif_unix.c:63

Referenced by TIFFOpen(), and TIFFOpenW().

◆ TIFFFieldDataType()

TIFFDataType TIFFFieldDataType ( const TIFFField fip)

Definition at line 594 of file tif_dirinfo.c.

595{
596 return fip->field_type;
597}
TIFFDataType field_type
Definition: tif_dir.h:286

◆ TIFFFieldName()

const char * TIFFFieldName ( const TIFFField fip)

Definition at line 588 of file tif_dirinfo.c.

589{
590 return fip->field_name;
591}

◆ TIFFFieldPassCount()

int TIFFFieldPassCount ( const TIFFField fip)

Definition at line 600 of file tif_dirinfo.c.

601{
602 return fip->field_passcount;
603}
unsigned char field_passcount
Definition: tif_dir.h:292

◆ TIFFFieldReadCount()

int TIFFFieldReadCount ( const TIFFField fip)

Definition at line 606 of file tif_dirinfo.c.

607{
608 return fip->field_readcount;
609}
short field_readcount
Definition: tif_dir.h:284

◆ TIFFFieldTag()

uint32 TIFFFieldTag ( const TIFFField fip)

Definition at line 582 of file tif_dirinfo.c.

583{
584 return fip->field_tag;
585}
uint32 field_tag
Definition: tif_dir.h:283

Referenced by TIFFWriteDirectorySec().

◆ TIFFFieldWithName()

const TIFFField * TIFFFieldWithName ( TIFF tif,
const char field_name 
)

Definition at line 570 of file tif_dirinfo.c.

571{
572 const TIFFField* fip =
573 _TIFFFindFieldByName(tif, field_name, TIFF_ANY);
574 if (!fip) {
575 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName",
576 "Internal error, unknown tag %s", field_name);
577 }
578 return (fip);
579}
static const TIFFField * _TIFFFindFieldByName(TIFF *tif, const char *field_name, TIFFDataType dt)
Definition: tif_dirinfo.c:531
#define TIFF_ANY
Definition: tiffio.h:307

◆ TIFFFieldWithTag()

const TIFFField * TIFFFieldWithTag ( TIFF tif,
uint32  tag 
)

Definition at line 558 of file tif_dirinfo.c.

559{
560 const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
561 if (!fip) {
562 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag",
563 "Internal error, unknown tag 0x%x",
564 (unsigned int) tag);
565 }
566 return (fip);
567}
Definition: ecma_167.h:138
const TIFFField * TIFFFindField(TIFF *tif, uint32 tag, TIFFDataType dt)
Definition: tif_dirinfo.c:506

Referenced by _TIFFVSetField(), CheckDirCount(), TIFFFetchStripThing(), TIFFPrintDirectory(), TIFFReadDirectory(), and TIFFUnsetField().

◆ TIFFFieldWriteCount()

int TIFFFieldWriteCount ( const TIFFField fip)

Definition at line 612 of file tif_dirinfo.c.

613{
614 return fip->field_writecount;
615}
short field_writecount
Definition: tif_dir.h:285

◆ TIFFFileName()

◆ TIFFFileno()

int TIFFFileno ( TIFF tif)

Definition at line 533 of file tif_open.c.

534{
535 return (tif->tif_fd);
536}

◆ TIFFFindCODEC()

const TIFFCodec * TIFFFindCODEC ( uint16  scheme)

Definition at line 186 of file tif_compress.c.

187{
188 const TIFFCodec* c;
189 codec_t* cd;
190
191 for (cd = registeredCODECS; cd; cd = cd->next)
192 if (cd->info->scheme == scheme)
193 return ((const TIFFCodec*) cd->info);
194 for (c = _TIFFBuiltinCODECS; c->name; c++)
195 if (c->scheme == scheme)
196 return (c);
197 return ((const TIFFCodec*) 0);
198}
InitDirComponents & cd
#define c
Definition: ke_i.h:80
DWORD scheme
char * name
Definition: tiffio.h:251
TIFFCodec _TIFFBuiltinCODECS[]
Definition: tif_codec.c:87
static codec_t * registeredCODECS
Definition: tif_compress.c:183

Referenced by _notConfigured(), TIFFIsCODECConfigured(), TIFFNoDecode(), TIFFNoEncode(), TIFFPrintDirectory(), and TIFFSetCompressionScheme().

◆ TIFFFindField()

const TIFFField * TIFFFindField ( TIFF tif,
uint32  tag,
TIFFDataType  dt 
)

Definition at line 506 of file tif_dirinfo.c.

507{
508 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
509 TIFFField* pkey = &key;
510 const TIFFField **ret;
511 if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
512 (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
513 return tif->tif_foundfield;
514
515 /* If we are invoked with no field information, then just return. */
516 if (!tif->tif_fields)
517 return NULL;
518
519 /* NB: use sorted search (e.g. binary search) */
520
521 key.field_tag = tag;
522 key.field_type = dt;
523
524 ret = (const TIFFField **) bsearch(&pkey, tif->tif_fields,
525 tif->tif_nfields,
526 sizeof(TIFFField *), tagCompare);
527 return tif->tif_foundfield = (ret ? *ret : NULL);
528}
Definition: copy.c:22
const TIFFField * tif_foundfield
Definition: tiffiop.h:218
#define bsearch
static int tagCompare(const void *a, const void *b)
Definition: tif_dirinfo.c:342
@ TIFF_NOTYPE
Definition: tiff.h:124
int ret

Referenced by _TIFFFindOrRegisterField(), _TIFFMergeFields(), _TIFFRewriteField(), _TIFFVGetField(), _TIFFVSetField(), OkToChangeTag(), TIFFFieldWithTag(), and TIFFVGetField().

◆ TIFFFlush()

int TIFFFlush ( TIFF tif)

Definition at line 32 of file tif_flush.c.

33{
34 if( tif->tif_mode == O_RDONLY )
35 return 1;
36
37 if (!TIFFFlushData(tif))
38 return (0);
39
40 /* In update (r+) mode we try to detect the case where
41 only the strip/tile map has been altered, and we try to
42 rewrite only that portion of the directory without
43 making any other changes */
44
45 if( (tif->tif_flags & TIFF_DIRTYSTRIP)
46 && !(tif->tif_flags & TIFF_DIRTYDIRECT)
47 && tif->tif_mode == O_RDWR )
48 {
50 return 1;
51 }
52
54 && !TIFFRewriteDirectory(tif))
55 return (0);
56
57 return (1);
58}
int TIFFRewriteDirectory(TIFF *tif)
Definition: tif_dirwrite.c:261
int TIFFForceStrileArrayWriting(TIFF *tif)
Definition: tif_flush.c:79
int TIFFFlushData(TIFF *tif)
Definition: tif_flush.c:156
#define TIFF_DIRTYSTRIP
Definition: tiffiop.h:140
#define TIFF_DIRTYDIRECT
Definition: tiffiop.h:122

Referenced by TIFFCleanup().

◆ TIFFFlushData()

int TIFFFlushData ( TIFF tif)

Definition at line 156 of file tif_flush.c.

157{
158 if ((tif->tif_flags & TIFF_BEENWRITING) == 0)
159 return (1);
160 if (tif->tif_flags & TIFF_POSTENCODE) {
161 tif->tif_flags &= ~TIFF_POSTENCODE;
162 if (!(*tif->tif_postencode)(tif))
163 return (0);
164 }
165 return (TIFFFlushData1(tif));
166}
TIFFBoolMethod tif_postencode
Definition: tiffiop.h:179
int TIFFFlushData1(TIFF *tif)
Definition: tif_write.c:803
#define TIFF_POSTENCODE
Definition: tiffiop.h:131
#define TIFF_BEENWRITING
Definition: tiffiop.h:125

Referenced by TIFFFlush(), and TIFFWriteScanline().

◆ TIFFForceStrileArrayWriting()

int TIFFForceStrileArrayWriting ( TIFF tif)

Definition at line 79 of file tif_flush.c.

80{
81 static const char module[] = "TIFFForceStrileArrayWriting";
82 const int isTiled = TIFFIsTiled(tif);
83
84 if (tif->tif_mode == O_RDONLY)
85 {
87 "File opened in read-only mode");
88 return 0;
89 }
90 if( tif->tif_diroff == 0 )
91 {
93 "Directory has not yet been written");
94 return 0;
95 }
96 if( (tif->tif_flags & TIFF_DIRTYDIRECT) != 0 )
97 {
99 "Directory has changes other than the strile arrays. "
100 "TIFFRewriteDirectory() should be called instead");
101 return 0;
102 }
103
104 if( !(tif->tif_flags & TIFF_DIRTYSTRIP) )
105 {
106 if( !(tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 &&
114 {
116 "Function not called together with "
117 "TIFFDeferStrileArrayWriting()");
118 return 0;
119 }
120
121 if (tif->tif_dir.td_stripoffset_p == NULL && !TIFFSetupStrips(tif))
122 return 0;
123 }
124
125 if( _TIFFRewriteField( tif,
129 tif->tif_dir.td_nstrips,
131 && _TIFFRewriteField( tif,
135 tif->tif_dir.td_nstrips,
137 {
138 tif->tif_flags &= ~TIFF_DIRTYSTRIP;
139 tif->tif_flags &= ~TIFF_BEENWRITING;
140 return 1;
141 }
142
143 return 0;
144}
union TIFFDirEntry::@3466 tdir_offset
uint64 toff_long8
Definition: tif_dir.h:59
uint64 tdir_count
Definition: tif_dir.h:55
uint16 tdir_tag
Definition: tif_dir.h:53
uint16 tdir_type
Definition: tif_dir.h:54
uint64 * td_stripbytecount_p
Definition: tif_dir.h:102
TIFFDirEntry td_stripoffset_entry
Definition: tif_dir.h:107
uint32 td_nstrips
Definition: tif_dir.h:100
TIFFDirEntry td_stripbytecount_entry
Definition: tif_dir.h:108
int _TIFFRewriteField(TIFF *tif, uint16 tag, TIFFDataType in_datatype, tmsize_t count, void *data)
int TIFFIsTiled(TIFF *tif)
Definition: tif_open.c:594
#define TIFFTAG_TILEBYTECOUNTS
Definition: tiff.h:288
#define TIFFTAG_STRIPBYTECOUNTS
Definition: tiff.h:233
#define TIFFTAG_TILEOFFSETS
Definition: tiff.h:287
#define TIFFTAG_STRIPOFFSETS
Definition: tiff.h:221
#define isTiled(tif)
Definition: tiffiop.h:229

Referenced by TIFFFlush(), and TIFFWriteCheck().

◆ TIFFFreeDirectory()

void TIFFFreeDirectory ( TIFF tif)

Definition at line 1268 of file tif_dir.c.

1269{
1270 TIFFDirectory *td = &tif->tif_dir;
1271 int i;
1272
1274 CleanupField(td_sminsamplevalue);
1275 CleanupField(td_smaxsamplevalue);
1276 CleanupField(td_colormap[0]);
1277 CleanupField(td_colormap[1]);
1278 CleanupField(td_colormap[2]);
1279 CleanupField(td_sampleinfo);
1280 CleanupField(td_subifd);
1281 CleanupField(td_inknames);
1282 CleanupField(td_refblackwhite);
1283 CleanupField(td_transferfunction[0]);
1284 CleanupField(td_transferfunction[1]);
1285 CleanupField(td_transferfunction[2]);
1286 CleanupField(td_stripoffset_p);
1287 CleanupField(td_stripbytecount_p);
1291
1292 /* Cleanup custom tag values */
1293 for( i = 0; i < td->td_customValueCount; i++ ) {
1294 if (td->td_customValues[i].value)
1296 }
1297
1298 td->td_customValueCount = 0;
1299 CleanupField(td_customValues);
1300
1301 _TIFFmemset( &(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
1303}
int td_customValueCount
Definition: tif_dir.h:121
uint32 td_stripoffsetbyteallocsize
Definition: tif_dir.h:103
TIFFTagValue * td_customValues
Definition: tif_dir.h:122
unsigned long td_fieldsset[FIELD_SETLONGS]
Definition: tif_dir.h:70
void * value
Definition: tif_dir.h:38
#define CleanupField(member)
Definition: tif_dir.c:1257
#define FIELD_SETLONGS
Definition: tif_dir.h:68
#define FIELD_YCBCRSUBSAMPLING
Definition: tif_dir.h:171
#define FIELD_YCBCRPOSITIONING
Definition: tif_dir.h:172
#define TIFFClrFieldBit(tif, field)
Definition: tif_dir.h:198

Referenced by TIFFCleanup(), TIFFReadCustomDirectory(), TIFFReadDirectory(), TIFFUnlinkDirectory(), and TIFFWriteDirectorySec().

◆ TIFFGetBitRevTable()

const unsigned char * TIFFGetBitRevTable ( int  reversed)

Definition at line 278 of file tif_swab.c.

279{
280 return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable);
281}
static const unsigned char TIFFBitRevTable[256]
Definition: tif_swab.c:208
static const unsigned char TIFFNoBitRevTable[256]
Definition: tif_swab.c:242

◆ TIFFGetClientInfo()

void * TIFFGetClientInfo ( TIFF tif,
const char name 
)

Definition at line 64 of file tif_extension.c.

66{
68
69 while( psLink != NULL && strcmp(psLink->name,name) != 0 )
70 psLink = psLink->next;
71
72 if( psLink != NULL )
73 return psLink->data;
74 else
75 return NULL;
76}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void * data
Definition: tiffiop.h:95

◆ TIFFGetCloseProc()

TIFFCloseProc TIFFGetCloseProc ( TIFF tif)

Definition at line 702 of file tif_open.c.

703{
704 return (tif->tif_closeproc);
705}

◆ TIFFGetConfiguredCODECs()

TIFFCodec * TIFFGetConfiguredCODECs ( void  )

Get list of configured codecs, both built-in and registered by user. Caller is responsible to free this structure.

Returns
returns array of TIFFCodec records (the last record should be NULL) or NULL if function failed.

Definition at line 252 of file tif_compress.c.

253{
254 int i = 1;
255 codec_t *cd;
256 const TIFFCodec* c;
258 TIFFCodec* new_codecs;
259
260 for (cd = registeredCODECS; cd; cd = cd->next) {
261 new_codecs = (TIFFCodec *)
262 _TIFFrealloc(codecs, i * sizeof(TIFFCodec));
263 if (!new_codecs) {
265 return NULL;
266 }
267 codecs = new_codecs;
268 _TIFFmemcpy(codecs + i - 1, cd, sizeof(TIFFCodec));
269 i++;
270 }
271 for (c = _TIFFBuiltinCODECS; c->name; c++) {
272 if (TIFFIsCODECConfigured(c->scheme)) {
273 new_codecs = (TIFFCodec *)
274 _TIFFrealloc(codecs, i * sizeof(TIFFCodec));
275 if (!new_codecs) {
277 return NULL;
278 }
279 codecs = new_codecs;
280 _TIFFmemcpy(codecs + i - 1, (const void*)c, sizeof(TIFFCodec));
281 i++;
282 }
283 }
284
285 new_codecs = (TIFFCodec *) _TIFFrealloc(codecs, i * sizeof(TIFFCodec));
286 if (!new_codecs) {
288 return NULL;
289 }
290 codecs = new_codecs;
291 _TIFFmemset(codecs + i - 1, 0, sizeof(TIFFCodec));
292
293 return codecs;
294}
static const struct image_codec codecs[NUM_CODECS]
Definition: image.c:4283
int TIFFIsCODECConfigured(uint16 scheme)
Definition: tif_codec.c:150
void * _TIFFrealloc(void *p, tmsize_t s)
Definition: tif_unix.c:332

◆ TIFFGetField()

int TIFFGetField ( TIFF tif,
uint32  tag,
  ... 
)

Definition at line 1232 of file tif_dir.c.

1233{
1234 int status;
1235 va_list ap;
1236
1237 va_start(ap, tag);
1238 status = TIFFVGetField(tif, tag, ap);
1239 va_end(ap);
1240 return (status);
1241}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
Definition: ps.c:97
int TIFFVGetField(TIFF *tif, uint32 tag, va_list ap)
Definition: tif_dir.c:1250
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Referenced by gtTileContig(), gtTileSeparate(), isCCITTCompression(), TIFFPrintDirectory(), TIFFRGBAImageBegin(), TIFFRGBAImageOK(), and TIFFWriteDirectorySec().

◆ TIFFGetFieldDefaulted()

int TIFFGetFieldDefaulted ( TIFF tif,
uint32  tag,
  ... 
)

Definition at line 345 of file tif_aux.c.

346{
347 int ok;
348 va_list ap;
349
350 va_start(ap, tag);
352 va_end(ap);
353 return (ok);
354}
#define ok(value,...)
Definition: atltest.h:57
int TIFFVGetFieldDefaulted(TIFF *tif, uint32 tag, va_list ap)
Definition: tif_aux.c:209

Referenced by gtStripContig(), gtStripSeparate(), initCIELabConversion(), initYCbCrConversion(), PickContigCase(), PickSeparateCase(), TIFFReadRGBAStripExt(), TIFFReadRGBATileExt(), TIFFRGBAImageBegin(), TIFFRGBAImageOK(), TIFFScanlineSize64(), TIFFVStripSize64(), TIFFVTileSize64(), and TIFFWriteDirectorySec().

◆ TIFFGetMapFileProc()

TIFFMapFileProc TIFFGetMapFileProc ( TIFF tif)

Definition at line 720 of file tif_open.c.

721{
722 return (tif->tif_mapproc);
723}

◆ TIFFGetMode()

int TIFFGetMode ( TIFF tif)

Definition at line 573 of file tif_open.c.

574{
575 return (tif->tif_mode);
576}

◆ TIFFGetReadProc()

TIFFReadWriteProc TIFFGetReadProc ( TIFF tif)

Definition at line 675 of file tif_open.c.

676{
677 return (tif->tif_readproc);
678}

◆ TIFFGetSeekProc()

TIFFSeekProc TIFFGetSeekProc ( TIFF tif)

Definition at line 693 of file tif_open.c.

694{
695 return (tif->tif_seekproc);
696}

◆ TIFFGetSizeProc()

TIFFSizeProc TIFFGetSizeProc ( TIFF tif)

Definition at line 711 of file tif_open.c.

712{
713 return (tif->tif_sizeproc);
714}

◆ TIFFGetStrileByteCount()

◆ TIFFGetStrileByteCountWithErr()

uint64 TIFFGetStrileByteCountWithErr ( TIFF tif,
uint32  strile,
int pbErr 
)

Definition at line 6311 of file tif_dirread.c.

6312{
6313 TIFFDirectory *td = &tif->tif_dir;
6314 return _TIFFGetStrileOffsetOrByteCountValue(tif, strile,
6316 &(td->td_stripbytecount_p), pbErr);
6317}
static uint64 _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32 strile, TIFFDirEntry *dirent, uint64 **parray, int *pbErr)
Definition: tif_dirread.c:6246

Referenced by TIFFGetStrileByteCount().

◆ TIFFGetStrileOffset()

uint64 TIFFGetStrileOffset ( TIFF tif,
uint32  strile 
)

◆ TIFFGetStrileOffsetWithErr()

uint64 TIFFGetStrileOffsetWithErr ( TIFF tif,
uint32  strile,
int pbErr 
)

Definition at line 6296 of file tif_dirread.c.

6297{
6298 TIFFDirectory *td = &tif->tif_dir;
6299 return _TIFFGetStrileOffsetOrByteCountValue(tif, strile,
6300 &(td->td_stripoffset_entry),
6301 &(td->td_stripoffset_p), pbErr);
6302}

Referenced by TIFFGetStrileOffset().

◆ TIFFGetTagListCount()

int TIFFGetTagListCount ( TIFF tif)

Definition at line 34 of file tif_extension.c.

36{
37 TIFFDirectory* td = &tif->tif_dir;
38
39 return td->td_customValueCount;
40}

Referenced by TIFFPrintDirectory().

◆ TIFFGetTagListEntry()

uint32 TIFFGetTagListEntry ( TIFF tif,
int  tag_index 
)

Definition at line 42 of file tif_extension.c.

44{
45 TIFFDirectory* td = &tif->tif_dir;
46
47 if( tag_index < 0 || tag_index >= td->td_customValueCount )
48 return (uint32)(-1);
49 else
50 return td->td_customValues[tag_index].info->field_tag;
51}
const TIFFField * info
Definition: tif_dir.h:36

Referenced by TIFFPrintDirectory().

◆ TIFFGetUnmapFileProc()

TIFFUnmapFileProc TIFFGetUnmapFileProc ( TIFF tif)

Definition at line 729 of file tif_open.c.

730{
731 return (tif->tif_unmapproc);
732}

◆ TIFFGetVersion()

const char * TIFFGetVersion ( void  )

Definition at line 29 of file tif_version.c.

30{
31 return (TIFFVersion);
32}
static const char TIFFVersion[]
Definition: tif_version.c:26

◆ TIFFGetWriteProc()

TIFFReadWriteProc TIFFGetWriteProc ( TIFF tif)

Definition at line 684 of file tif_open.c.

685{
686 return (tif->tif_writeproc);
687}

◆ TIFFIsBigEndian()

int TIFFIsBigEndian ( TIFF tif)

Definition at line 666 of file tif_open.c.

667{
669}

◆ TIFFIsByteSwapped()

int TIFFIsByteSwapped ( TIFF tif)

Definition at line 639 of file tif_open.c.

640{
641 return ((tif->tif_flags & TIFF_SWAB) != 0);
642}

◆ TIFFIsCODECConfigured()

int TIFFIsCODECConfigured ( uint16  scheme)

Check whether we have working codec for the specific coding scheme.

Returns
returns 1 if the codec is configured and working. Otherwise 0 will be returned.

Definition at line 150 of file tif_codec.c.

151{
152 const TIFFCodec* codec = TIFFFindCODEC(scheme);
153
154 if(codec == NULL) {
155 return 0;
156 }
157 if(codec->init == NULL) {
158 return 0;
159 }
160 if(codec->init != NotConfigured){
161 return 1;
162 }
163 return 0;
164}
TIFFInitMethod init
Definition: tiffio.h:253
static int NotConfigured(TIFF *, int)
Definition: tif_codec.c:126
const TIFFCodec * TIFFFindCODEC(uint16 scheme)
Definition: tif_compress.c:186

Referenced by TIFFGetConfiguredCODECs().

◆ TIFFIsMSB2LSB()

int TIFFIsMSB2LSB ( TIFF tif)

Definition at line 657 of file tif_open.c.

658{
659 return (isFillOrder(tif, FILLORDER_MSB2LSB));
660}
#define isFillOrder(tif, o)
Definition: tiffiop.h:231

◆ TIFFIsTiled()

int TIFFIsTiled ( TIFF tif)

◆ TIFFIsUpSampled()

int TIFFIsUpSampled ( TIFF tif)

Definition at line 648 of file tif_open.c.

649{
650 return (isUpSampled(tif));
651}
#define isUpSampled(tif)
Definition: tiffiop.h:232

◆ TIFFLastDirectory()

int TIFFLastDirectory ( TIFF tif)

Definition at line 1676 of file tif_dir.c.

1677{
1678 return (tif->tif_nextdiroff == 0);
1679}

◆ TIFFMergeFieldInfo()

int TIFFMergeFieldInfo ( TIFF tif,
const  TIFFFieldInfo[],
uint32  n 
)

Definition at line 888 of file tif_dirinfo.c.

889{
890 static const char module[] = "TIFFMergeFieldInfo";
891 static const char reason[] = "for fields array";
892 TIFFField *tp;
893 size_t nfields;
894 uint32 i;
895
896 if (tif->tif_nfieldscompat > 0) {
899 tif->tif_nfieldscompat + 1,
900 sizeof(TIFFFieldArray), reason);
901 } else {
903 _TIFFCheckMalloc(tif, 1, sizeof(TIFFFieldArray),
904 reason);
905 }
906 if (!tif->tif_fieldscompat) {
908 "Failed to allocate fields array");
909 return -1;
910 }
911 nfields = tif->tif_nfieldscompat++;
912
913 tif->tif_fieldscompat[nfields].type = tfiatOther;
914 tif->tif_fieldscompat[nfields].allocated_size = n;
915 tif->tif_fieldscompat[nfields].count = n;
916 tif->tif_fieldscompat[nfields].fields =
917 (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField),
918 reason);
919 if (!tif->tif_fieldscompat[nfields].fields) {
921 "Failed to allocate fields array");
922 return -1;
923 }
924
925 tp = tif->tif_fieldscompat[nfields].fields;
926 for (i = 0; i < n; i++) {
927 tp->field_tag = info[i].field_tag;
928 tp->field_readcount = info[i].field_readcount;
929 tp->field_writecount = info[i].field_writecount;
930 tp->field_type = info[i].field_type;
931 tp->reserved = 0;
932 tp->set_field_type =
933 _TIFFSetGetType(info[i].field_type,
934 info[i].field_readcount,
935 info[i].field_passcount);
936 tp->get_field_type =
937 _TIFFSetGetType(info[i].field_type,
938 info[i].field_readcount,
939 info[i].field_passcount);
940 tp->field_bit = info[i].field_bit;
941 tp->field_oktochange = info[i].field_oktochange;
942 tp->field_passcount = info[i].field_passcount;
943 tp->field_name = info[i].field_name;
944 tp->field_subfields = NULL;
945 tp++;
946 }
947
948 if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n)) {
950 "Setting up field info failed");
951 return -1;
952 }
953
954 return 0;
955}
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
TIFFFieldArrayType type
Definition: tif_dir.h:276
uint32 count
Definition: tif_dir.h:278
void * _TIFFCheckRealloc(TIFF *tif, void *buffer, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Definition: tif_aux.c:97
void * _TIFFCheckMalloc(TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Definition: tif_aux.c:121
@ tfiatOther
Definition: tif_dir.h:272
int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32 n)
Definition: tif_dirinfo.c:369
static TIFFSetGetFieldType _TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount)
Definition: tif_dirinfo.c:735

◆ TIFFNumberOfDirectories()

uint16 TIFFNumberOfDirectories ( TIFF tif)

Definition at line 1586 of file tif_dir.c.

1587{
1588 static const char module[] = "TIFFNumberOfDirectories";
1589 uint64 nextdir;
1590 uint16 n;
1591 if (!(tif->tif_flags&TIFF_BIGTIFF))
1592 nextdir = tif->tif_header.classic.tiff_diroff;
1593 else
1594 nextdir = tif->tif_header.big.tiff_diroff;
1595 n = 0;
1596 while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL))
1597 {
1598 if (n != 65535) {
1599 ++n;
1600 }
1601 else
1602 {
1604 "Directory count exceeded 65535 limit,"
1605 " giving up on counting.");
1606 return (65535);
1607 }
1608 }
1609 return (n);
1610}
static int TIFFAdvanceDirectory(TIFF *tif, uint64 *nextdir, uint64 *off)
Definition: tif_dir.c:1444

◆ TIFFNumberOfStrips()

uint32 TIFFNumberOfStrips ( TIFF tif)

Definition at line 59 of file tif_strip.c.

60{
61 TIFFDirectory *td = &tif->tif_dir;
62 uint32 nstrips;
63
64 nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
67 nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel,
68 "TIFFNumberOfStrips");
69 return (nstrips);
70}
uint32 _TIFFMultiply32(TIFF *tif, uint32 first, uint32 second, const char *where)
Definition: tif_aux.c:37

Referenced by TIFFReadDirectory(), and TIFFSetupStrips().

◆ TIFFNumberOfTiles()

uint32 TIFFNumberOfTiles ( TIFF tif)

Definition at line 113 of file tif_tile.c.

114{
115 TIFFDirectory *td = &tif->tif_dir;
116 uint32 dx = td->td_tilewidth;
117 uint32 dy = td->td_tilelength;
118 uint32 dz = td->td_tiledepth;
119 uint32 ntiles;
120
121 if (dx == (uint32) -1)
122 dx = td->td_imagewidth;
123 if (dy == (uint32) -1)
124 dy = td->td_imagelength;
125 if (dz == (uint32) -1)
126 dz = td->td_imagedepth;
127 ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 :
130 "TIFFNumberOfTiles"),
131 TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles");
133 ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel,
134 "TIFFNumberOfTiles");
135 return (ntiles);
136}

Referenced by TIFFReadDirectory(), and TIFFSetupStrips().

◆ TIFFOpen()

TIFF * TIFFOpen ( const char name,
const char mode 
)

Definition at line 223 of file tif_unix.c.

224{
225 static const char module[] = "TIFFOpen";
226 int m, fd;
227 TIFF* tif;
228
230 if (m == -1)
231 return ((TIFF*)0);
232
233/* for cygwin and mingw */
234#ifdef O_BINARY
235 m |= O_BINARY;
236#endif
237
238 fd = open(name, m, 0666);
239 if (fd < 0) {
240 if (errno > 0 && strerror(errno) != NULL ) {
241 TIFFErrorExt(0, module, "%s: %s", name, strerror(errno) );
242 } else {
243 TIFFErrorExt(0, module, "%s: Cannot open", name);
244 }
245 return ((TIFF *)0);
246 }
247
248 tif = TIFFFdOpen((int)fd, name, mode);
249 if(!tif)
250 close(fd);
251 return tif;
252}
#define O_BINARY
Definition: acwin.h:109
#define open
Definition: acwin.h:95
#define close
Definition: acwin.h:98
const char * strerror(int err)
Definition: compat_str.c:23
#define errno
Definition: errno.h:18
TIFF * TIFFFdOpen(int fd, const char *name, const char *mode)
Definition: tif_unix.c:203

◆ TIFFPrintDirectory()

void TIFFPrintDirectory ( TIFF tif,
FILE fd,
long  flags 
)

Definition at line 234 of file tif_print.c.

235{
236 TIFFDirectory *td = &tif->tif_dir;
237 char *sep;
238 long l, n;
239
240#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
241 fprintf(fd, "TIFF Directory at offset 0x%I64x (%I64u)\n",
242 (unsigned __int64) tif->tif_diroff,
243 (unsigned __int64) tif->tif_diroff);
244#else
245 fprintf(fd, "TIFF Directory at offset 0x%llx (%llu)\n",
246 (unsigned long long) tif->tif_diroff,
247 (unsigned long long) tif->tif_diroff);
248#endif
250 fprintf(fd, " Subfile Type:");
251 sep = " ";
253 fprintf(fd, "%sreduced-resolution image", sep);
254 sep = "/";
255 }
256 if (td->td_subfiletype & FILETYPE_PAGE) {
257 fprintf(fd, "%smulti-page document", sep);
258 sep = "/";
259 }
261 fprintf(fd, "%stransparency mask", sep);
262 fprintf(fd, " (%lu = 0x%lx)\n",
263 (unsigned long) td->td_subfiletype, (long) td->td_subfiletype);
264 }
266 fprintf(fd, " Image Width: %lu Image Length: %lu",
267 (unsigned long) td->td_imagewidth, (unsigned long) td->td_imagelength);
269 fprintf(fd, " Image Depth: %lu",
270 (unsigned long) td->td_imagedepth);
271 fprintf(fd, "\n");
272 }
274 fprintf(fd, " Tile Width: %lu Tile Length: %lu",
275 (unsigned long) td->td_tilewidth, (unsigned long) td->td_tilelength);
277 fprintf(fd, " Tile Depth: %lu",
278 (unsigned long) td->td_tiledepth);
279 fprintf(fd, "\n");
280 }
282 fprintf(fd, " Resolution: %g, %g",
285 switch (td->td_resolutionunit) {
286 case RESUNIT_NONE:
287 fprintf(fd, " (unitless)");
288 break;
289 case RESUNIT_INCH:
290 fprintf(fd, " pixels/inch");
291 break;
293 fprintf(fd, " pixels/cm");
294 break;
295 default:
296 fprintf(fd, " (unit %u = 0x%x)",
299 break;
300 }
301 }
302 fprintf(fd, "\n");
303 }
305 fprintf(fd, " Position: %g, %g\n",
306 td->td_xposition, td->td_yposition);
308 fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample);
310 fprintf(fd, " Sample Format: ");
311 switch (td->td_sampleformat) {
313 fprintf(fd, "void\n");
314 break;
315 case SAMPLEFORMAT_INT:
316 fprintf(fd, "signed integer\n");
317 break;
319 fprintf(fd, "unsigned integer\n");
320 break;
322 fprintf(fd, "IEEE floating point\n");
323 break;
325 fprintf(fd, "complex signed integer\n");
326 break;
328 fprintf(fd, "complex IEEE floating point\n");
329 break;
330 default:
331 fprintf(fd, "%u (0x%x)\n",
333 break;
334 }
335 }
338 fprintf(fd, " Compression Scheme: ");
339 if (c)
340 fprintf(fd, "%s\n", c->name);
341 else
342 fprintf(fd, "%u (0x%x)\n",
344 }
346 fprintf(fd, " Photometric Interpretation: ");
347 if (td->td_photometric < NPHOTONAMES)
348 fprintf(fd, "%s\n", photoNames[td->td_photometric]);
349 else {
350 switch (td->td_photometric) {
351 case PHOTOMETRIC_LOGL:
352 fprintf(fd, "CIE Log2(L)\n");
353 break;
355 fprintf(fd, "CIE Log2(L) (u',v')\n");
356 break;
357 default:
358 fprintf(fd, "%u (0x%x)\n",
360 break;
361 }
362 }
363 }
365 uint16 i;
366 fprintf(fd, " Extra Samples: %u<", td->td_extrasamples);
367 sep = "";
368 for (i = 0; i < td->td_extrasamples; i++) {
369 switch (td->td_sampleinfo[i]) {
371 fprintf(fd, "%sunspecified", sep);
372 break;
374 fprintf(fd, "%sassoc-alpha", sep);
375 break;
377 fprintf(fd, "%sunassoc-alpha", sep);
378 break;
379 default:
380 fprintf(fd, "%s%u (0x%x)", sep,
381 td->td_sampleinfo[i], td->td_sampleinfo[i]);
382 break;
383 }
384 sep = ", ";
385 }
386 fprintf(fd, ">\n");
387 }
388 if (TIFFFieldSet(tif,FIELD_INKNAMES)) {
389 char* cp;
390 uint16 i;
391 fprintf(fd, " Ink Names: ");
392 i = td->td_samplesperpixel;
393 sep = "";
394 for (cp = td->td_inknames;
395 i > 0 && cp < td->td_inknames + td->td_inknameslen;
396 cp = strchr(cp,'\0')+1, i--) {
397 size_t max_chars =
398 td->td_inknameslen - (cp - td->td_inknames);
399 fputs(sep, fd);
400 _TIFFprintAsciiBounded(fd, cp, max_chars);
401 sep = ", ";
402 }
403 fputs("\n", fd);
404 }
406 fprintf(fd, " Thresholding: ");
407 switch (td->td_threshholding) {
409 fprintf(fd, "bilevel art scan\n");
410 break;
412 fprintf(fd, "halftone or dithered scan\n");
413 break;
415 fprintf(fd, "error diffused\n");
416 break;
417 default:
418 fprintf(fd, "%u (0x%x)\n",
420 break;
421 }
422 }
423 if (TIFFFieldSet(tif,FIELD_FILLORDER)) {
424 fprintf(fd, " FillOrder: ");
425 switch (td->td_fillorder) {
427 fprintf(fd, "msb-to-lsb\n");
428 break;
430 fprintf(fd, "lsb-to-msb\n");
431 break;
432 default:
433 fprintf(fd, "%u (0x%x)\n",
434 td->td_fillorder, td->td_fillorder);
435 break;
436 }
437 }
439 {
440 fprintf(fd, " YCbCr Subsampling: %u, %u\n",
442 }
444 fprintf(fd, " YCbCr Positioning: ");
445 switch (td->td_ycbcrpositioning) {
447 fprintf(fd, "centered\n");
448 break;
450 fprintf(fd, "cosited\n");
451 break;
452 default:
453 fprintf(fd, "%u (0x%x)\n",
455 break;
456 }
457 }
459 fprintf(fd, " Halftone Hints: light %u dark %u\n",
460 td->td_halftonehints[0], td->td_halftonehints[1]);
462 fprintf(fd, " Orientation: ");
464 fprintf(fd, "%s\n", orientNames[td->td_orientation]);
465 else
466 fprintf(fd, "%u (0x%x)\n",
468 }
470 fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel);
472 fprintf(fd, " Rows/Strip: ");
473 if (td->td_rowsperstrip == (uint32) -1)
474 fprintf(fd, "(infinite)\n");
475 else
476 fprintf(fd, "%lu\n", (unsigned long) td->td_rowsperstrip);
477 }
479 fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue);
481 fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue);
483 int i;
484 int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
485 fprintf(fd, " SMin Sample Value:");
486 for (i = 0; i < count; ++i)
487 fprintf(fd, " %g", td->td_sminsamplevalue[i]);
488 fprintf(fd, "\n");
489 }
491 int i;
492 int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
493 fprintf(fd, " SMax Sample Value:");
494 for (i = 0; i < count; ++i)
495 fprintf(fd, " %g", td->td_smaxsamplevalue[i]);
496 fprintf(fd, "\n");
497 }
499 fprintf(fd, " Planar Configuration: ");
500 switch (td->td_planarconfig) {
502 fprintf(fd, "single image plane\n");
503 break;
505 fprintf(fd, "separate image planes\n");
506 break;
507 default:
508 fprintf(fd, "%u (0x%x)\n",
510 break;
511 }
512 }
514 fprintf(fd, " Page Number: %u-%u\n",
515 td->td_pagenumber[0], td->td_pagenumber[1]);
516 if (TIFFFieldSet(tif,FIELD_COLORMAP)) {
517 fprintf(fd, " Color Map: ");
519 fprintf(fd, "\n");
520 n = 1L<<td->td_bitspersample;
521 for (l = 0; l < n; l++)
522 fprintf(fd, " %5ld: %5u %5u %5u\n",
523 l,
524 td->td_colormap[0][l],
525 td->td_colormap[1][l],
526 td->td_colormap[2][l]);
527 } else
528 fprintf(fd, "(present)\n");
529 }
531 int i;
532 fprintf(fd, " Reference Black/White:\n");
533 for (i = 0; i < 3; i++)
534 fprintf(fd, " %2d: %5g %5g\n", i,
535 td->td_refblackwhite[2*i+0],
536 td->td_refblackwhite[2*i+1]);
537 }
539 fprintf(fd, " Transfer Function: ");
540 if (flags & TIFFPRINT_CURVES) {
541 fprintf(fd, "\n");
542 n = 1L<<td->td_bitspersample;
543 for (l = 0; l < n; l++) {
544 uint16 i;
545 fprintf(fd, " %2ld: %5u",
546 l, td->td_transferfunction[0][l]);
547 for (i = 1; i < td->td_samplesperpixel - td->td_extrasamples && i < 3; i++)
548 fprintf(fd, " %5u",
549 td->td_transferfunction[i][l]);
550 fputc('\n', fd);
551 }
552 } else
553 fprintf(fd, "(present)\n");
554 }
555 if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) {
556 uint16 i;
557 fprintf(fd, " SubIFD Offsets:");
558 for (i = 0; i < td->td_nsubifd; i++)
559#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
560 fprintf(fd, " %5I64u",
561 (unsigned __int64) td->td_subifd[i]);
562#else
563 fprintf(fd, " %5llu",
564 (unsigned long long) td->td_subifd[i]);
565#endif
566 fputc('\n', fd);
567 }
568
569 /*
570 ** Custom tag support.
571 */
572 {
573 int i;
574 short count;
575
577 for(i = 0; i < count; i++) {
579 const TIFFField *fip;
580 uint32 value_count;
581 int mem_alloc = 0;
582 void *raw_data;
583
584 fip = TIFFFieldWithTag(tif, tag);
585 if(fip == NULL)
586 continue;
587
588 if(fip->field_passcount) {
589 if (fip->field_readcount == TIFF_VARIABLE2 ) {
590 if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
591 continue;
592 } else if (fip->field_readcount == TIFF_VARIABLE ) {
593 uint16 small_value_count;
594 if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1)
595 continue;
596 value_count = small_value_count;
597 } else {
600 continue;
601 }
602 } else {
605 value_count = 1;
606 else if (fip->field_readcount == TIFF_SPP)
607 value_count = td->td_samplesperpixel;
608 else
609 value_count = fip->field_readcount;
610 if (fip->field_tag == TIFFTAG_DOTRANGE
611 && strcmp(fip->field_name,"DotRange") == 0) {
612 /* TODO: This is an evil exception and should not have been
613 handled this way ... likely best if we move it into
614 the directory structure with an explicit field in
615 libtiff 4.1 and assign it a FIELD_ value */
616 static uint16 dotrange[2];
617 raw_data = dotrange;
618 TIFFGetField(tif, tag, dotrange+0, dotrange+1);
619 } else if (fip->field_type == TIFF_ASCII
622 || fip->field_readcount == TIFF_SPP
623 || value_count > 1) {
624 if(TIFFGetField(tif, tag, &raw_data) != 1)
625 continue;
626 } else {
627 raw_data = _TIFFmalloc(
629 * value_count);
630 mem_alloc = 1;
631 if(TIFFGetField(tif, tag, raw_data) != 1) {
632 _TIFFfree(raw_data);
633 continue;
634 }
635 }
636 }
637
638 /*
639 * Catch the tags which needs to be specially handled
640 * and pretty print them. If tag not handled in
641 * _TIFFPrettyPrintField() fall down and print it as
642 * any other tag.
643 */
644 if (!_TIFFPrettyPrintField(tif, fip, fd, tag, value_count, raw_data))
645 _TIFFPrintField(fd, fip, value_count, raw_data);
646
647 if(mem_alloc)
648 _TIFFfree(raw_data);
649 }
650 }
651
652 if (tif->tif_tagmethods.printdir)
653 (*tif->tif_tagmethods.printdir)(tif, fd, flags);
654
655 if ((flags & TIFFPRINT_STRIPS) &&
657 uint32 s;
658
659 fprintf(fd, " %lu %s:\n",
660 (unsigned long) td->td_nstrips,
661 isTiled(tif) ? "Tiles" : "Strips");
662 for (s = 0; s < td->td_nstrips; s++)
663#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
664 fprintf(fd, " %3lu: [%8I64u, %8I64u]\n",
665 (unsigned long) s,
666 (unsigned __int64) TIFFGetStrileOffset(tif, s),
667 (unsigned __int64) TIFFGetStrileByteCount(tif, s));
668#else
669 fprintf(fd, " %3lu: [%8llu, %8llu]\n",
670 (unsigned long) s,
671 (unsigned long long) TIFFGetStrileOffset(tif, s),
672 (unsigned long long) TIFFGetStrileByteCount(tif, s));
673#endif
674 }
675}
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define __int64
Definition: basetyps.h:16
#define mem_alloc(bsize)
Definition: types.h:123
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLbitfield flags
Definition: glext.h:7161
_Check_return_opt_ _CRTIMP int __cdecl fputs(_In_z_ const char *_Str, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
float td_xposition
Definition: tif_dir.h:90
uint16 td_resolutionunit
Definition: tif_dir.h:88
uint16 td_sampleformat
Definition: tif_dir.h:76
float td_xresolution
Definition: tif_dir.h:87
int td_inknameslen
Definition: tif_dir.h:118
uint16 td_pagenumber[2]
Definition: tif_dir.h:91
float * td_refblackwhite
Definition: tif_dir.h:116
uint16 td_bitspersample
Definition: tif_dir.h:75
uint16 td_maxsamplevalue
Definition: tif_dir.h:84
float td_yresolution
Definition: tif_dir.h:87
uint16 td_photometric
Definition: tif_dir.h:78
uint16 td_fillorder
Definition: tif_dir.h:80
uint32 td_subfiletype
Definition: tif_dir.h:74
double * td_sminsamplevalue
Definition: tif_dir.h:85
uint16 td_minsamplevalue
Definition: tif_dir.h:84
uint16 td_threshholding
Definition: tif_dir.h:79
char * td_inknames
Definition: tif_dir.h:119
uint16 td_nsubifd
Definition: tif_dir.h:109
uint16 * td_transferfunction[3]
Definition: tif_dir.h:115
uint16 td_ycbcrpositioning
Definition: tif_dir.h:113
uint16 * td_sampleinfo
Definition: tif_dir.h:95
double * td_smaxsamplevalue
Definition: tif_dir.h:86
uint16 td_compression
Definition: tif_dir.h:77
uint16 td_extrasamples
Definition: tif_dir.h:94
uint16 td_halftonehints[2]
Definition: tif_dir.h:93
uint16 td_orientation
Definition: tif_dir.h:81
uint16 * td_colormap[3]
Definition: tif_dir.h:92
uint16 td_ycbcrsubsampling[2]
Definition: tif_dir.h:112
uint64 * td_subifd
Definition: tif_dir.h:110
float td_yposition
Definition: tif_dir.h:90
TIFFPrintMethod printdir
Definition: tiffio.h:335
int TIFFGetField(TIFF *tif, uint32 tag,...)
Definition: tif_dir.c:1232
#define FIELD_RESOLUTION
Definition: tif_dir.h:143
#define FIELD_SUBFILETYPE
Definition: tif_dir.h:147
#define FIELD_STRIPOFFSETS
Definition: tif_dir.h:162
#define FIELD_TRANSFERFUNCTION
Definition: tif_dir.h:174
#define FIELD_HALFTONEHINTS
Definition: tif_dir.h:170
#define FIELD_ORIENTATION
Definition: tif_dir.h:153
#define FIELD_MINSAMPLEVALUE
Definition: tif_dir.h:156
#define FIELD_FILLORDER
Definition: tif_dir.h:152
#define FIELD_SMAXSAMPLEVALUE
Definition: tif_dir.h:167
#define FIELD_IMAGEDIMENSIONS
Definition: tif_dir.h:141
#define FIELD_COLORMAP
Definition: tif_dir.h:163
#define FIELD_SUBIFD
Definition: tif_dir.h:176
#define FIELD_EXTRASAMPLES
Definition: tif_dir.h:164
#define FIELD_IMAGEDEPTH
Definition: tif_dir.h:168
#define FIELD_SMINSAMPLEVALUE
Definition: tif_dir.h:166
#define TIFFFieldSet(tif, field)
Definition: tif_dir.h:196
#define FIELD_MAXSAMPLEVALUE
Definition: tif_dir.h:157
#define FIELD_TILEDEPTH
Definition: tif_dir.h:169
#define FIELD_TILEDIMENSIONS
Definition: tif_dir.h:142
#define FIELD_POSITION
Definition: tif_dir.h:144
#define FIELD_ROWSPERSTRIP
Definition: tif_dir.h:155
#define FIELD_COMPRESSION
Definition: tif_dir.h:149
#define FIELD_REFBLACKWHITE
Definition: tif_dir.h:173
#define FIELD_SAMPLEFORMAT
Definition: tif_dir.h:165
#define FIELD_PAGENUMBER
Definition: tif_dir.h:160
#define FIELD_BITSPERSAMPLE
Definition: tif_dir.h:148
#define FIELD_INKNAMES
Definition: tif_dir.h:175
#define FIELD_RESOLUTIONUNIT
Definition: tif_dir.h:159
#define FIELD_PLANARCONFIG
Definition: tif_dir.h:158
#define FIELD_SAMPLESPERPIXEL
Definition: tif_dir.h:154
#define FIELD_PHOTOMETRIC
Definition: tif_dir.h:150
#define FIELD_THRESHHOLDING
Definition: tif_dir.h:151
const TIFFField * TIFFFieldWithTag(TIFF *tif, uint32 tag)
Definition: tif_dirinfo.c:558
int _TIFFDataSize(TIFFDataType type)
Definition: tif_dirinfo.c:476
uint64 TIFFGetStrileOffset(TIFF *tif, uint32 strile)
Definition: tif_dirread.c:6290
uint64 TIFFGetStrileByteCount(TIFF *tif, uint32 strile)
Definition: tif_dirread.c:6305
int TIFFGetTagListCount(TIFF *tif)
Definition: tif_extension.c:34
uint32 TIFFGetTagListEntry(TIFF *tif, int tag_index)
Definition: tif_extension.c:42
static void _TIFFPrintField(FILE *fd, const TIFFField *fip, uint32 value_count, void *raw_data)
Definition: tif_print.c:67
#define NORIENTNAMES
Definition: tif_print.c:64
#define NPHOTONAMES
Definition: tif_print.c:51
static int _TIFFPrettyPrintField(TIFF *tif, const TIFFField *fip, FILE *fd, uint32 tag, uint32 value_count, void *raw_data)
Definition: tif_print.c:141
static void _TIFFprintAsciiBounded(FILE *fd, const char *cp, size_t max_chars)
Definition: tif_print.c:684
static const char *const photoNames[]
Definition: tif_print.c:38
static const char *const orientNames[]
Definition: tif_print.c:53
#define THRESHHOLD_HALFTONE
Definition: tiff.h:210
#define TIFFTAG_DOTRANGE
Definition: tiff.h:301
#define EXTRASAMPLE_UNASSALPHA
Definition: tiff.h:306
#define YCBCRPOSITION_CENTERED
Definition: tiff.h:364
#define YCBCRPOSITION_COSITED
Definition: tiff.h:365
#define RESUNIT_CENTIMETER
Definition: tiff.h:264
#define EXTRASAMPLE_ASSOCALPHA
Definition: tiff.h:305
#define FILETYPE_MASK
Definition: tiff.h:149
#define PHOTOMETRIC_LOGL
Definition: tiff.h:206
#define SAMPLEFORMAT_COMPLEXINT
Definition: tiff.h:312
#define SAMPLEFORMAT_UINT
Definition: tiff.h:308
#define EXTRASAMPLE_UNSPECIFIED
Definition: tiff.h:304
#define RESUNIT_NONE
Definition: tiff.h:262
#define FILETYPE_REDUCEDIMAGE
Definition: tiff.h:147
#define THRESHHOLD_ERRORDIFFUSE
Definition: tiff.h:211
#define PHOTOMETRIC_LOGLUV
Definition: tiff.h:207
#define FILETYPE_PAGE
Definition: tiff.h:148
#define SAMPLEFORMAT_IEEEFP
Definition: tiff.h:310
#define SAMPLEFORMAT_COMPLEXIEEEFP
Definition: tiff.h:313
#define RESUNIT_INCH
Definition: tiff.h:263
#define THRESHHOLD_BILEVEL
Definition: tiff.h:209
#define SAMPLEFORMAT_VOID
Definition: tiff.h:311
#define SAMPLEFORMAT_INT
Definition: tiff.h:309
#define PLANARCONFIG_CONTIG
Definition: tiff.h:239
#define TIFFPRINT_STRIPS
Definition: tiffio.h:114
#define TIFFPRINT_COLORMAP
Definition: tiffio.h:116
#define TIFF_SPP
Definition: tiffio.h:309
#define TIFF_VARIABLE
Definition: tiffio.h:308
#define TIFFPRINT_CURVES
Definition: tiffio.h:115
#define TIFF_VARIABLE2
Definition: tiffio.h:310
#define TIFF_PERSAMPLE
Definition: tiffiop.h:141

◆ TIFFRasterScanlineSize()

tmsize_t TIFFRasterScanlineSize ( TIFF tif)

Definition at line 344 of file tif_strip.c.

345{
346 static const char module[] = "TIFFRasterScanlineSize";
347 uint64 m;
349 return _TIFFCastUInt64ToSSize(tif, m, module);
350}
tmsize_t _TIFFCastUInt64ToSSize(TIFF *tif, uint64 val, const char *module)
Definition: tif_aux.c:83
uint64 TIFFRasterScanlineSize64(TIFF *tif)
Definition: tif_strip.c:329

◆ TIFFRasterScanlineSize64()

uint64 TIFFRasterScanlineSize64 ( TIFF tif)

Definition at line 329 of file tif_strip.c.

330{
331 static const char module[] = "TIFFRasterScanlineSize64";
332 TIFFDirectory *td = &tif->tif_dir;
333 uint64 scanline;
334
335 scanline = _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module);
337 scanline = _TIFFMultiply64(tif, scanline, td->td_samplesperpixel, module);
338 return (TIFFhowmany8_64(scanline));
339 } else
340 return (_TIFFMultiply64(tif, TIFFhowmany8_64(scanline),
342}
uint64 _TIFFMultiply64(TIFF *tif, uint64 first, uint64 second, const char *where)
Definition: tif_aux.c:48
#define TIFFhowmany8_64(x)
Definition: tiffiop.h:274

Referenced by TIFFRasterScanlineSize().

◆ TIFFRawStripSize()

tmsize_t TIFFRawStripSize ( TIFF tif,
uint32  strip 
)

Definition at line 164 of file tif_strip.c.

165{
166 static const char module[] = "TIFFRawStripSize";
167 uint64 m;
168 tmsize_t n;
169 m=TIFFRawStripSize64(tif,strip);
170 if (m==(uint64)(-1))
171 n=(tmsize_t)(-1);
172 else
173 {
174 n=(tmsize_t)m;
175 if ((uint64)n!=m)
176 {
177 TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
178 n=0;
179 }
180 }
181 return(n);
182}
uint64 TIFFRawStripSize64(TIFF *tif, uint32 strip)
Definition: tif_strip.c:140

◆ TIFFRawStripSize64()

uint64 TIFFRawStripSize64 ( TIFF tif,
uint32  strip 
)

Definition at line 140 of file tif_strip.c.

141{
142 static const char module[] = "TIFFRawStripSize64";
143 uint64 bytecount = TIFFGetStrileByteCount(tif, strip);
144
145 if (bytecount == 0)
146 {
147#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
149 "%I64u: Invalid strip byte count, strip %lu",
150 (unsigned __int64) bytecount,
151 (unsigned long) strip);
152#else
154 "%llu: Invalid strip byte count, strip %lu",
155 (unsigned long long) bytecount,
156 (unsigned long) strip);
157#endif
158 bytecount = (uint64) -1;
159 }
160
161 return bytecount;
162}

Referenced by TIFFRawStripSize().

◆ TIFFReadBufferSetup()

int TIFFReadBufferSetup ( TIFF tif,
void bp,
tmsize_t  size 
)

Definition at line 1378 of file tif_read.c.

1379{
1380 static const char module[] = "TIFFReadBufferSetup";
1381
1382 assert((tif->tif_flags&TIFF_NOREADRAW)==0);
1383 tif->tif_flags &= ~TIFF_BUFFERMMAP;
1384
1385 if (tif->tif_rawdata) {
1386 if (tif->tif_flags & TIFF_MYBUFFER)
1387 _TIFFfree(tif->tif_rawdata);
1388 tif->tif_rawdata = NULL;
1389 tif->tif_rawdatasize = 0;
1390 }
1391 if (bp) {
1392 tif->tif_rawdatasize = size;
1393 tif->tif_rawdata = (uint8*) bp;
1394 tif->tif_flags &= ~TIFF_MYBUFFER;
1395 } else {
1397 if (tif->tif_rawdatasize==0) {
1399 "Invalid buffer size");
1400 return (0);
1401 }
1402 /* Initialize to zero to avoid uninitialized buffers in case of */
1403 /* short reads (http://bugzilla.maptools.org/show_bug.cgi?id=2651) */
1404 tif->tif_rawdata = (uint8*) _TIFFcalloc(1, tif->tif_rawdatasize);
1405 tif->tif_flags |= TIFF_MYBUFFER;
1406 }
1407 if (tif->tif_rawdata == NULL) {
1409 "No space for data buffer at scanline %lu",
1410 (unsigned long) tif->tif_row);
1411 tif->tif_rawdatasize = 0;
1412 return (0);
1413 }
1414 return (1);
1415}
GLsizeiptr size
Definition: glext.h:5919
void * _TIFFcalloc(tmsize_t nmemb, tmsize_t siz)
Definition: tif_unix.c:317
#define TIFFroundup_64(x, y)
Definition: tiffiop.h:275
#define TIFF_NOREADRAW
Definition: tiffiop.h:136

Referenced by TIFFFillStrip(), and TIFFFillTile().

◆ TIFFReadCustomDirectory()

int TIFFReadCustomDirectory ( TIFF tif,
toff_t  diroff,
const TIFFFieldArray infoarray 
)

Definition at line 4394 of file tif_dirread.c.

4396{
4397 static const char module[] = "TIFFReadCustomDirectory";
4399 uint16 dircount;
4400 TIFFDirEntry* dp;
4401 uint16 di;
4402 const TIFFField* fip;
4403 uint32 fii;
4404 _TIFFSetupFields(tif, infoarray);
4405 dircount=TIFFFetchDirectory(tif,diroff,&dir,NULL);
4406 if (!dircount)
4407 {
4409 "Failed to read custom directory at offset " TIFF_UINT64_FORMAT,diroff);
4410 return 0;
4411 }
4412 TIFFFreeDirectory(tif);
4413 _TIFFmemset(&tif->tif_dir, 0, sizeof(TIFFDirectory));
4414 TIFFReadDirectoryCheckOrder(tif,dir,dircount);
4415 for (di=0, dp=dir; di<dircount; di++, dp++)
4416 {
4418 if (fii == FAILED_FII)
4419 {
4421 "Unknown field with tag %d (0x%x) encountered",
4422 dp->tdir_tag, dp->tdir_tag);
4424 dp->tdir_tag,
4425 (TIFFDataType) dp->tdir_type),
4426 1)) {
4428 "Registering anonymous field with tag %d (0x%x) failed",
4429 dp->tdir_tag, dp->tdir_tag);
4430 dp->tdir_ignore = TRUE;
4431 } else {
4433 assert( fii != FAILED_FII );
4434 }
4435 }
4436 if (!dp->tdir_ignore)
4437 {
4438 fip=tif->tif_fields[fii];
4439 if (fip->field_bit==FIELD_IGNORE)
4440 dp->tdir_ignore = TRUE;
4441 else
4442 {
4443 /* check data type */
4444 while ((fip->field_type!=TIFF_ANY)&&(fip->field_type!=dp->tdir_type))
4445 {
4446 fii++;
4447 if ((fii==tif->tif_nfields)||
4448 (tif->tif_fields[fii]->field_tag!=(uint32)dp->tdir_tag))
4449 {
4450 fii=0xFFFF;
4451 break;
4452 }
4453 fip=tif->tif_fields[fii];
4454 }
4455 if (fii==0xFFFF)
4456 {
4458 "Wrong data type %d for \"%s\"; tag ignored",
4459 dp->tdir_type,fip->field_name);
4460 dp->tdir_ignore = TRUE;
4461 }
4462 else
4463 {
4464 /* check count if known in advance */
4465 if ((fip->field_readcount!=TIFF_VARIABLE)&&
4467 {
4469 if (fip->field_readcount==TIFF_SPP)
4471 else
4473 if (!CheckDirCount(tif,dp,expected))
4474 dp->tdir_ignore = TRUE;
4475 }
4476 }
4477 }
4478 if (!dp->tdir_ignore) {
4479 switch (dp->tdir_tag)
4480 {
4483 break;
4484 default:
4485 (void)TIFFFetchNormalTag(tif, dp, TRUE);
4486 break;
4487 }
4488 } /*-- if (!dp->tdir_ignore) */
4489 }
4490 }
4491 if (dir)
4492 _TIFFfree(dir);
4493 return 1;
4494}
unsigned int dir
Definition: maze.c:112
BOOL expected
Definition: store.c:2063
uint8 tdir_ignore
Definition: tif_dir.h:61
#define TIFF_UINT64_FORMAT
Definition: tif_config.h:52
#define FIELD_IGNORE
Definition: tif_dir.h:138
TIFFField * _TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type)
Definition: tif_dirinfo.c:634
#define FAILED_FII
Definition: tif_dirread.c:41
static void TIFFReadDirectoryCheckOrder(TIFF *tif, TIFFDirEntry *dir, uint16 dircount)
Definition: tif_dirread.c:4324
static void TIFFReadDirectoryFindFieldInfo(TIFF *tif, uint16 tagid, uint32 *fii)
Definition: tif_dirread.c:4358
static int CheckDirCount(TIFF *, TIFFDirEntry *, uint32)
Definition: tif_dirread.c:4679
static uint16 TIFFFetchDirectory(TIFF *tif, uint64 diroff, TIFFDirEntry **pdir, uint64 *nextdiroff)
Definition: tif_dirread.c:4706
static int TIFFFetchSubjectDistance(TIFF *, TIFFDirEntry *)
Definition: tif_dirread.c:5698
static int TIFFFetchNormalTag(TIFF *, TIFFDirEntry *, int recover)
Definition: tif_dirread.c:4964
void TIFFWarningExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_warning.c:65
TIFFDataType
Definition: tiff.h:123
#define EXIFTAG_SUBJECTDISTANCE
Definition: tiff.h:599

Referenced by TIFFReadEXIFDirectory().

◆ TIFFReadDirectory()

int TIFFReadDirectory ( TIFF tif)

Definition at line 3574 of file tif_dirread.c.

3575{
3576 static const char module[] = "TIFFReadDirectory";
3578 uint16 dircount;
3579 TIFFDirEntry* dp;
3580 uint16 di;
3581 const TIFFField* fip;
3582 uint32 fii=FAILED_FII;
3583 toff_t nextdiroff;
3584 int bitspersample_read = FALSE;
3585 int color_channels;
3586
3587 tif->tif_diroff=tif->tif_nextdiroff;
3588 if (!TIFFCheckDirOffset(tif,tif->tif_nextdiroff))
3589 return 0; /* last offset or bad offset (IFD looping) */
3590 (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */
3591 tif->tif_curdir++;
3592 nextdiroff = tif->tif_nextdiroff;
3593 dircount=TIFFFetchDirectory(tif,nextdiroff,&dir,&tif->tif_nextdiroff);
3594 if (!dircount)
3595 {
3597 "Failed to read directory at offset " TIFF_UINT64_FORMAT,nextdiroff);
3598 return 0;
3599 }
3600 TIFFReadDirectoryCheckOrder(tif,dir,dircount);
3601
3602 /*
3603 * Mark duplicates of any tag to be ignored (bugzilla 1994)
3604 * to avoid certain pathological problems.
3605 */
3606 {
3607 TIFFDirEntry* ma;
3608 uint16 mb;
3609 for (ma=dir, mb=0; mb<dircount; ma++, mb++)
3610 {
3611 TIFFDirEntry* na;
3612 uint16 nb;
3613 for (na=ma+1, nb=mb+1; nb<dircount; na++, nb++)
3614 {
3615 if (ma->tdir_tag == na->tdir_tag) {
3616 na->tdir_ignore = TRUE;
3617 }
3618 }
3619 }
3620 }
3621
3622 tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */
3623 tif->tif_flags &= ~TIFF_BUF4WRITE; /* reset before new dir */
3624 tif->tif_flags &= ~TIFF_CHOPPEDUPARRAYS;
3625
3626 /* free any old stuff and reinit */
3627 TIFFFreeDirectory(tif);
3629 /*
3630 * Electronic Arts writes gray-scale TIFF files
3631 * without a PlanarConfiguration directory entry.
3632 * Thus we setup a default value here, even though
3633 * the TIFF spec says there is no default value.
3634 */
3636 /*
3637 * Setup default value and then make a pass over
3638 * the fields to check type and tag information,
3639 * and to extract info required to size data
3640 * structures. A second pass is made afterwards
3641 * to read in everything not taken in the first pass.
3642 * But we must process the Compression tag first
3643 * in order to merge in codec-private tag definitions (otherwise
3644 * we may get complaints about unknown tags). However, the
3645 * Compression tag may be dependent on the SamplesPerPixel
3646 * tag value because older TIFF specs permitted Compression
3647 * to be written as a SamplesPerPixel-count tag entry.
3648 * Thus if we don't first figure out the correct SamplesPerPixel
3649 * tag value then we may end up ignoring the Compression tag
3650 * value because it has an incorrect count value (if the
3651 * true value of SamplesPerPixel is not 1).
3652 */
3654 if (dp)
3655 {
3656 if (!TIFFFetchNormalTag(tif,dp,0))
3657 goto bad;
3658 dp->tdir_ignore = TRUE;
3659 }
3661 if (dp)
3662 {
3663 /*
3664 * The 5.0 spec says the Compression tag has one value, while
3665 * earlier specs say it has one value per sample. Because of
3666 * this, we accept the tag if one value is supplied with either
3667 * count.
3668 */
3669 uint16 value;
3675 {
3676 TIFFReadDirEntryOutputErr(tif,err,module,"Compression",0);
3677 goto bad;
3678 }
3680 goto bad;
3681 dp->tdir_ignore = TRUE;
3682 }
3683 else
3684 {
3686 goto bad;
3687 }
3688 /*
3689 * First real pass over the directory.
3690 */
3691 for (di=0, dp=dir; di<dircount; di++, dp++)
3692 {
3693 if (!dp->tdir_ignore)
3694 {
3696 if (fii == FAILED_FII)
3697 {
3699 "Unknown field with tag %d (0x%x) encountered",
3700 dp->tdir_tag,dp->tdir_tag);
3701 /* the following knowingly leaks the
3702 anonymous field structure */
3703 if (!_TIFFMergeFields(tif,
3705 dp->tdir_tag,
3706 (TIFFDataType) dp->tdir_type),
3707 1)) {
3709 module,
3710 "Registering anonymous field with tag %d (0x%x) failed",
3711 dp->tdir_tag,
3712 dp->tdir_tag);
3713 dp->tdir_ignore = TRUE;
3714 } else {
3716 assert(fii != FAILED_FII);
3717 }
3718 }
3719 }
3720 if (!dp->tdir_ignore)
3721 {
3722 fip=tif->tif_fields[fii];
3723 if (fip->field_bit==FIELD_IGNORE)
3724 dp->tdir_ignore = TRUE;
3725 else
3726 {
3727 switch (dp->tdir_tag)
3728 {
3733 TIFFSetFieldBit(tif,fip->field_bit);
3734 break;
3735 case TIFFTAG_IMAGEWIDTH:
3737 case TIFFTAG_IMAGEDEPTH:
3738 case TIFFTAG_TILELENGTH:
3739 case TIFFTAG_TILEWIDTH:
3740 case TIFFTAG_TILEDEPTH:
3744 if (!TIFFFetchNormalTag(tif,dp,0))
3745 goto bad;
3746 dp->tdir_ignore = TRUE;
3747 break;
3748 default:
3750 dp->tdir_ignore = TRUE;
3751 break;
3752 }
3753 }
3754 }
3755 }
3756 /*
3757 * XXX: OJPEG hack.
3758 * If a) compression is OJPEG, b) planarconfig tag says it's separate,
3759 * c) strip offsets/bytecounts tag are both present and
3760 * d) both contain exactly one value, then we consistently find
3761 * that the buggy implementation of the buggy compression scheme
3762 * matches contig planarconfig best. So we 'fix-up' the tag here
3763 */
3766 {
3767 if (!_TIFFFillStriles(tif))
3768 goto bad;
3770 if ((dp!=0)&&(dp->tdir_count==1))
3771 {
3772 dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,
3774 if ((dp!=0)&&(dp->tdir_count==1))
3775 {
3778 "Planarconfig tag value assumed incorrect, "
3779 "assuming data is contig instead of chunky");
3780 }
3781 }
3782 }
3783 /*
3784 * Allocate directory structure and setup defaults.
3785 */
3787 {
3788 MissingRequired(tif,"ImageLength");
3789 goto bad;
3790 }
3791 /*
3792 * Setup appropriate structures (by strip or by tile)
3793 */
3799 tif->tif_flags &= ~TIFF_ISTILED;
3800 } else {
3802 tif->tif_flags |= TIFF_ISTILED;
3803 }
3804 if (!tif->tif_dir.td_nstrips) {
3806 "Cannot handle zero number of %s",
3807 isTiled(tif) ? "tiles" : "strips");
3808 goto bad;
3809 }
3813 if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) {
3814#ifdef OJPEG_SUPPORT
3816 (isTiled(tif)==0) &&
3817 (tif->tif_dir.td_nstrips==1)) {
3818 /*
3819 * XXX: OJPEG hack.
3820 * If a) compression is OJPEG, b) it's not a tiled TIFF,
3821 * and c) the number of strips is 1,
3822 * then we tolerate the absence of stripoffsets tag,
3823 * because, presumably, all required data is in the
3824 * JpegInterchangeFormat stream.
3825 */
3827 } else
3828#endif
3829 {
3830 MissingRequired(tif,
3831 isTiled(tif) ? "TileOffsets" : "StripOffsets");
3832 goto bad;
3833 }
3834 }
3835 /*
3836 * Second pass: extract other information.
3837 */
3838 for (di=0, dp=dir; di<dircount; di++, dp++)
3839 {
3840 if (!dp->tdir_ignore) {
3841 switch (dp->tdir_tag)
3842 {
3846 case TIFFTAG_DATATYPE:
3848 /*
3849 * The MinSampleValue, MaxSampleValue, BitsPerSample
3850 * DataType and SampleFormat tags are supposed to be
3851 * written as one value/sample, but some vendors
3852 * incorrectly write one value only -- so we accept
3853 * that as well (yuck). Other vendors write correct
3854 * value for NumberOfSamples, but incorrect one for
3855 * BitsPerSample and friends, and we will read this
3856 * too.
3857 */
3858 {
3859 uint16 value;
3865 {
3866 fip = TIFFFieldWithTag(tif,dp->tdir_tag);
3867 TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0);
3868 goto bad;
3869 }
3870 if (!TIFFSetField(tif,dp->tdir_tag,value))
3871 goto bad;
3872 if( dp->tdir_tag == TIFFTAG_BITSPERSAMPLE )
3873 bitspersample_read = TRUE;
3874 }
3875 break;
3878 {
3879
3880 double *data = NULL;
3882 uint32 saved_flags;
3883 int m;
3886 else
3889 {
3890 fip = TIFFFieldWithTag(tif,dp->tdir_tag);
3891 TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0);
3892 goto bad;
3893 }
3894 saved_flags = tif->tif_flags;
3895 tif->tif_flags |= TIFF_PERSAMPLE;
3896 m = TIFFSetField(tif,dp->tdir_tag,data);
3897 tif->tif_flags = saved_flags;
3898 _TIFFfree(data);
3899 if (!m)
3900 goto bad;
3901 }
3902 break;
3906 dp, sizeof(TIFFDirEntry) );
3907 break;
3911 dp, sizeof(TIFFDirEntry) );
3912 break;
3913 case TIFFTAG_COLORMAP:
3915 {
3917 uint32 countpersample;
3918 uint32 countrequired;
3919 uint32 incrementpersample;
3920 uint16* value=NULL;
3921 /* It would be dangerous to instantiate those tag values */
3922 /* since if td_bitspersample has not yet been read (due to */
3923 /* unordered tags), it could be read afterwards with a */
3924 /* values greater than the default one (1), which may cause */
3925 /* crashes in user code */
3926 if( !bitspersample_read )
3927 {
3928 fip = TIFFFieldWithTag(tif,dp->tdir_tag);
3930 "Ignoring %s since BitsPerSample tag not found",
3931 fip ? fip->field_name : "unknown tagname");
3932 continue;
3933 }
3934 /* ColorMap or TransferFunction for high bit */
3935 /* depths do not make much sense and could be */
3936 /* used as a denial of service vector */
3937 if (tif->tif_dir.td_bitspersample > 24)
3938 {
3939 fip = TIFFFieldWithTag(tif,dp->tdir_tag);
3941 "Ignoring %s because BitsPerSample=%d>24",
3942 fip ? fip->field_name : "unknown tagname",
3944 continue;
3945 }
3946 countpersample=(1U<<tif->tif_dir.td_bitspersample);
3947 if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample))
3948 {
3949 countrequired=countpersample;
3950 incrementpersample=0;
3951 }
3952 else
3953 {
3954 countrequired=3*countpersample;
3955 incrementpersample=countpersample;
3956 }
3957 if (dp->tdir_count!=(uint64)countrequired)
3959 else
3962 {
3963 fip = TIFFFieldWithTag(tif,dp->tdir_tag);
3964 TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",1);
3965 }
3966 else
3967 {
3968 TIFFSetField(tif,dp->tdir_tag,value,value+incrementpersample,value+2*incrementpersample);
3970 }
3971 }
3972 break;
3973/* BEGIN REV 4.0 COMPATIBILITY */
3975 {
3976 uint16 valueo;
3977 uint32 value;
3978 if (TIFFReadDirEntryShort(tif,dp,&valueo)==TIFFReadDirEntryErrOk)
3979 {
3980 switch (valueo)
3981 {
3983 case OFILETYPE_PAGE: value=FILETYPE_PAGE; break;
3984 default: value=0; break;
3985 }
3986 if (value!=0)
3988 }
3989 }
3990 break;
3991/* END REV 4.0 COMPATIBILITY */
3992 default:
3993 (void) TIFFFetchNormalTag(tif, dp, TRUE);
3994 break;
3995 }
3996 } /* -- if (!dp->tdir_ignore) */
3997 } /* -- for-loop -- */
3998
3999 if( tif->tif_mode == O_RDWR &&
4008 {
4009 /* Directory typically created with TIFFDeferStrileArrayWriting() */
4010 TIFFSetupStrips(tif);
4011 }
4012 else if( !(tif->tif_flags&TIFF_DEFERSTRILELOAD) )
4013 {
4014 if( tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 )
4015 {
4017 tif->tif_dir.td_nstrips,
4019 {
4020 goto bad;
4021 }
4022 }
4024 {
4026 tif->tif_dir.td_nstrips,
4028 {
4029 goto bad;
4030 }
4031 }
4032 }
4033
4034 /*
4035 * OJPEG hack:
4036 * - If a) compression is OJPEG, and b) photometric tag is missing,
4037 * then we consistently find that photometric should be YCbCr
4038 * - If a) compression is OJPEG, and b) photometric tag says it's RGB,
4039 * then we consistently find that the buggy implementation of the
4040 * buggy compression scheme matches photometric YCbCr instead.
4041 * - If a) compression is OJPEG, and b) bitspersample tag is missing,
4042 * then we consistently find bitspersample should be 8.
4043 * - If a) compression is OJPEG, b) samplesperpixel tag is missing,
4044 * and c) photometric is RGB or YCbCr, then we consistently find
4045 * samplesperpixel should be 3
4046 * - If a) compression is OJPEG, b) samplesperpixel tag is missing,
4047 * and c) photometric is MINISWHITE or MINISBLACK, then we consistently
4048 * find samplesperpixel should be 3
4049 */
4051 {
4053 {
4055 "Photometric tag is missing, assuming data is YCbCr");
4057 goto bad;
4058 }
4059 else if (tif->tif_dir.td_photometric==PHOTOMETRIC_RGB)
4060 {
4063 "Photometric tag value assumed incorrect, "
4064 "assuming data is YCbCr instead of RGB");
4065 }
4067 {
4069 "BitsPerSample tag is missing, assuming 8 bits per sample");
4071 goto bad;
4072 }
4074 {
4076 {
4078 "SamplesPerPixel tag is missing, "
4079 "assuming correct SamplesPerPixel value is 3");
4081 goto bad;
4082 }
4084 {
4086 "SamplesPerPixel tag is missing, "
4087 "applying correct SamplesPerPixel value of 3");
4089 goto bad;
4090 }
4093 {
4094 /*
4095 * SamplesPerPixel tag is missing, but is not required
4096 * by spec. Assume correct SamplesPerPixel value of 1.
4097 */
4099 goto bad;
4100 }
4101 }
4102 }
4103
4104 /*
4105 * Make sure all non-color channels are extrasamples.
4106 * If it's not the case, define them as such.
4107 */
4108 color_channels = _TIFFGetMaxColorChannels(tif->tif_dir.td_photometric);
4109 if (color_channels && tif->tif_dir.td_samplesperpixel - tif->tif_dir.td_extrasamples > color_channels) {
4110 uint16 old_extrasamples;
4111 uint16 *new_sampleinfo;
4112
4113 TIFFWarningExt(tif->tif_clientdata,module, "Sum of Photometric type-related "
4114 "color channels and ExtraSamples doesn't match SamplesPerPixel. "
4115 "Defining non-color channels as ExtraSamples.");
4116
4117 old_extrasamples = tif->tif_dir.td_extrasamples;
4118 tif->tif_dir.td_extrasamples = (uint16) (tif->tif_dir.td_samplesperpixel - color_channels);
4119
4120 // sampleinfo should contain information relative to these new extra samples
4121 new_sampleinfo = (uint16*) _TIFFcalloc(tif->tif_dir.td_extrasamples, sizeof(uint16));
4122 if (!new_sampleinfo) {
4123 TIFFErrorExt(tif->tif_clientdata, module, "Failed to allocate memory for "
4124 "temporary new sampleinfo array (%d 16 bit elements)",
4126 goto bad;
4127 }
4128
4129 memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo, old_extrasamples * sizeof(uint16));
4130 _TIFFsetShortArray(&tif->tif_dir.td_sampleinfo, new_sampleinfo, tif->tif_dir.td_extrasamples);
4131 _TIFFfree(new_sampleinfo);
4132 }
4133
4134 /*
4135 * Verify Palette image has a Colormap.
4136 */
4139 if ( tif->tif_dir.td_bitspersample>=8 && tif->tif_dir.td_samplesperpixel==3)
4141 else if (tif->tif_dir.td_bitspersample>=8)
4143 else {
4144 MissingRequired(tif, "Colormap");
4145 goto bad;
4146 }
4147 }
4148 /*
4149 * OJPEG hack:
4150 * We do no further messing with strip/tile offsets/bytecounts in OJPEG
4151 * TIFFs
4152 */
4154 {
4155 /*
4156 * Attempt to deal with a missing StripByteCounts tag.
4157 */
4159 /*
4160 * Some manufacturers violate the spec by not giving
4161 * the size of the strips. In this case, assume there
4162 * is one uncompressed strip of data.
4163 */
4165 tif->tif_dir.td_nstrips > 1) ||
4168 MissingRequired(tif, "StripByteCounts");
4169 goto bad;
4170 }
4172 "TIFF directory is missing required "
4173 "\"StripByteCounts\" field, calculating from imagelength");
4174 if (EstimateStripByteCounts(tif, dir, dircount) < 0)
4175 goto bad;
4176
4177 } else if (tif->tif_dir.td_nstrips == 1
4178 && !(tif->tif_flags&TIFF_ISTILED)
4179 && ByteCountLooksBad(tif)) {
4180 /*
4181 * XXX: Plexus (and others) sometimes give a value of
4182 * zero for a tag when they don't know what the
4183 * correct value is! Try and handle the simple case
4184 * of estimating the size of a one strip image.
4185 */
4187 "Bogus \"StripByteCounts\" field, ignoring and calculating from imagelength");
4188 if(EstimateStripByteCounts(tif, dir, dircount) < 0)
4189 goto bad;
4190
4191 } else if (!(tif->tif_flags&TIFF_DEFERSTRILELOAD)
4193 && tif->tif_dir.td_nstrips > 2
4196 && TIFFGetStrileByteCount(tif, 0) != 0
4197 && TIFFGetStrileByteCount(tif, 1) != 0 ) {
4198 /*
4199 * XXX: Some vendors fill StripByteCount array with
4200 * absolutely wrong values (it can be equal to
4201 * StripOffset array, for example). Catch this case
4202 * here.
4203 *
4204 * We avoid this check if deferring strile loading
4205 * as it would always force us to load the strip/tile
4206 * information.
4207 */
4209 "Wrong \"StripByteCounts\" field, ignoring and calculating from imagelength");
4210 if (EstimateStripByteCounts(tif, dir, dircount) < 0)
4211 goto bad;
4212 }
4213 }
4214 if (dir)
4215 {
4216 _TIFFfree(dir);
4217 dir=NULL;
4218 }
4220 {
4221 if (tif->tif_dir.td_bitspersample>=16)
4222 tif->tif_dir.td_maxsamplevalue=0xFFFF;
4223 else
4225 }
4226
4227#ifdef STRIPBYTECOUNTSORTED_UNUSED
4228 /*
4229 * XXX: We can optimize checking for the strip bounds using the sorted
4230 * bytecounts array. See also comments for TIFFAppendToStrip()
4231 * function in tif_write.c.
4232 */
4233 if (!(tif->tif_flags&TIFF_DEFERSTRILELOAD) && tif->tif_dir.td_nstrips > 1) {
4234 uint32 strip;
4235
4236 tif->tif_dir.td_stripbytecountsorted = 1;
4237 for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) {
4238 if (TIFFGetStrileOffset(tif, strip - 1) >
4239 TIFFGetStrileOffset(tif, strip)) {
4240 tif->tif_dir.td_stripbytecountsorted = 0;
4241 break;
4242 }
4243 }
4244 }
4245#endif
4246
4247 /*
4248 * An opportunity for compression mode dependent tag fixup
4249 */
4250 (*tif->tif_fixuptags)(tif);
4251
4252 /*
4253 * Some manufacturers make life difficult by writing
4254 * large amounts of uncompressed data as a single strip.
4255 * This is contrary to the recommendations of the spec.
4256 * The following makes an attempt at breaking such images
4257 * into strips closer to the recommended 8k bytes. A
4258 * side effect, however, is that the RowsPerStrip tag
4259 * value may be changed.
4260 */
4262 (tif->tif_dir.td_nstrips==1)&&
4265 {
4267 }
4268
4269 /* There are also uncompressed striped files with strips larger than */
4270 /* 2 GB, which make them unfriendly with a lot of code. If possible, */
4271 /* try to expose smaller "virtual" strips. */
4275 TIFFStripSize64(tif) > 0x7FFFFFFFUL )
4276 {
4278 }
4279
4280 /*
4281 * Clear the dirty directory flag.
4282 */
4283 tif->tif_flags &= ~TIFF_DIRTYDIRECT;
4284 tif->tif_flags &= ~TIFF_DIRTYSTRIP;
4285
4286 /*
4287 * Reinitialize i/o since we are starting on a new directory.
4288 */
4289 tif->tif_row = (uint32) -1;
4290 tif->tif_curstrip = (uint32) -1;
4291 tif->tif_col = (uint32) -1;
4292 tif->tif_curtile = (uint32) -1;
4293 tif->tif_tilesize = (tmsize_t) -1;
4294
4296 if (!tif->tif_scanlinesize) {
4298 "Cannot handle zero scanline size");
4299 return (0);
4300 }
4301
4302 if (isTiled(tif)) {
4303 tif->tif_tilesize = TIFFTileSize(tif);
4304 if (!tif->tif_tilesize) {
4306 "Cannot handle zero tile size");
4307 return (0);
4308 }
4309 } else {
4310 if (!TIFFStripSize(tif)) {
4312 "Cannot handle zero strip size");
4313 return (0);
4314 }
4315 }
4316 return (1);
4317bad:
4318 if (dir)
4319 _TIFFfree(dir);
4320 return (0);
4321}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define err(...)
tmsize_t tif_scanlinesize
Definition: tiffiop.h:193
TIFFBoolMethod tif_fixuptags
Definition: tiffiop.h:173
tmsize_t tif_tilesize
Definition: tiffiop.h:170
uint32 tif_col
Definition: tiffiop.h:168
int TIFFSetField(TIFF *tif, uint32 tag,...)
Definition: tif_dir.c:807
void _TIFFsetShortArray(uint16 **wpp, uint16 *wp, uint32 n)
Definition: tif_dir.c:63
#define FIELD_STRIPBYTECOUNTS
Definition: tif_dir.h:161
#define TIFFSetFieldBit(tif, field)
Definition: tif_dir.h:197
int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag)
Definition: tif_dirinfo.c:958
static void MissingRequired(TIFF *, const char *)
Definition: tif_dirread.c:4616
static int TIFFCheckDirOffset(TIFF *tif, uint64 diroff)
Definition: tif_dirread.c:4632
static void TryChopUpUncompressedBigTiff(TIFF *)
Definition: tif_dirread.c:5898
static int ByteCountLooksBad(TIFF *tif)
Definition: tif_dirread.c:3526
static enum TIFFReadDirEntryErr TIFFReadDirEntryDoubleArray(TIFF *tif, TIFFDirEntry *direntry, double **value)
Definition: tif_dirread.c:2530
static void TIFFReadDirEntryOutputErr(TIFF *tif, enum TIFFReadDirEntryErr err, const char *module, const char *tagname, int recover)
Definition: tif_dirread.c:3410
static int EstimateStripByteCounts(TIFF *tif, TIFFDirEntry *dir, uint16 dircount)
Definition: tif_dirread.c:4509
static void ChopUpSingleUncompressedStrip(TIFF *)
Definition: tif_dirread.c:5828
TIFFReadDirEntryErr
Definition: tif_dirread.c:56
@ TIFFReadDirEntryErrCount
Definition: tif_dirread.c:58
@ TIFFReadDirEntryErrOk
Definition: tif_dirread.c:57
int _TIFFFillStriles(TIFF *tif)
Definition: tif_dirread.c:6320
static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF *tif, TIFFDirEntry *direntry, uint16 *value)
Definition: tif_dirread.c:292
static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF *tif, TIFFDirEntry *direntry, uint16 **value)
Definition: tif_dirread.c:1294
static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF *tif, TIFFDirEntry *direntry, uint16 *value)
Definition: tif_dirread.c:2828
static int TIFFFetchStripThing(TIFF *tif, TIFFDirEntry *dir, uint32 nstrips, uint64 **lpp)
Definition: tif_dirread.c:5649
static int _TIFFGetMaxColorChannels(uint16 photometric)
Definition: tif_dirread.c:3502
static TIFFDirEntry * TIFFReadDirectoryFindEntry(TIFF *tif, TIFFDirEntry *dir, uint16 dircount, uint16 tagid)
Definition: tif_dirread.c:4344
tmsize_t TIFFStripSize(TIFF *tif)
Definition: tif_strip.c:202
tmsize_t TIFFScanlineSize(TIFF *tif)
Definition: tif_strip.c:314
uint64 TIFFStripSize64(TIFF *tif)
Definition: tif_strip.c:193
uint32 TIFFNumberOfStrips(TIFF *tif)
Definition: tif_strip.c:59
tmsize_t TIFFTileSize(TIFF *tif)
Definition: tif_tile.c:257
uint32 TIFFNumberOfTiles(TIFF *tif)
Definition: tif_tile.c:113
#define COMPRESSION_NONE
Definition: tiff.h:158
#define TIFFTAG_BITSPERSAMPLE
Definition: tiff.h:156
#define OFILETYPE_REDUCEDIMAGE
Definition: tiff.h:152
#define OFILETYPE_PAGE
Definition: tiff.h:153
#define COMPRESSION_OJPEG
Definition: tiff.h:165
#define TIFFTAG_SAMPLESPERPIXEL
Definition: tiff.h:231
#define TIFFTAG_DATATYPE
Definition: tiff.h:377
#define TIFFTAG_COLORMAP
Definition: tiff.h:283
#define TIFFTAG_IMAGEDEPTH
Definition: tiff.h:378
#define TIFFTAG_PHOTOMETRIC
Definition: tiff.h:194
#define TIFFTAG_TILELENGTH
Definition: tiff.h:286
#define TIFFTAG_OSUBFILETYPE
Definition: tiff.h:150
#define TIFFTAG_MAXSAMPLEVALUE
Definition: tiff.h:235
#define TIFFTAG_TILEDEPTH
Definition: tiff.h:379
#define PHOTOMETRIC_PALETTE
Definition: tiff.h:198
#define TIFFTAG_EXTRASAMPLES
Definition: tiff.h:303
#define TIFFTAG_IMAGEWIDTH
Definition: tiff.h:154
#define TIFFTAG_MINSAMPLEVALUE
Definition: tiff.h:234
#define PHOTOMETRIC_YCBCR
Definition: tiff.h:201
#define TIFFTAG_TRANSFERFUNCTION
Definition: tiff.h:272
#define PHOTOMETRIC_MINISWHITE
Definition: tiff.h:195
#define TIFFTAG_SMINSAMPLEVALUE
Definition: tiff.h:314
#define TIFFTAG_ROWSPERSTRIP
Definition: tiff.h:232
#define TIFFTAG_SMAXSAMPLEVALUE
Definition: tiff.h:315
#define TIFFTAG_SAMPLEFORMAT
Definition: tiff.h:307
#define TIFFTAG_TILEWIDTH
Definition: tiff.h:285
#define TIFFTAG_IMAGELENGTH
Definition: tiff.h:155
#define TIFFTAG_COMPRESSION
Definition: tiff.h:157
#define PHOTOMETRIC_MINISBLACK
Definition: tiff.h:196
#define PHOTOMETRIC_RGB
Definition: tiff.h:197
#define TIFFTAG_PLANARCONFIG
Definition: tiff.h:238
#define TIFFTAG_SUBFILETYPE
Definition: tiff.h:146
#define TIFF_ISTILED
Definition: tiffiop.h:129
Definition: pdh_main.c:94

Referenced by TIFFClientOpen(), TIFFSetDirectory(), and TIFFSetSubDirectory().

◆ TIFFReadEncodedStrip()

tmsize_t TIFFReadEncodedStrip ( TIFF tif,
uint32  strip,
void buf,
tmsize_t  size 
)

Definition at line 527 of file tif_read.c.

528{
529 static const char module[] = "TIFFReadEncodedStrip";
530 TIFFDirectory *td = &tif->tif_dir;
531 tmsize_t stripsize;
533
534 stripsize=TIFFReadEncodedStripGetStripSize(tif, strip, &plane);
535 if (stripsize==((tmsize_t)(-1)))
536 return((tmsize_t)(-1));
537
538 /* shortcut to avoid an extra memcpy() */
539 if( td->td_compression == COMPRESSION_NONE &&
540 size!=(tmsize_t)(-1) && size >= stripsize &&
541 !isMapped(tif) &&
542 ((tif->tif_flags&TIFF_NOREADRAW)==0) )
543 {
544 if (TIFFReadRawStrip1(tif, strip, buf, stripsize, module) != stripsize)
545 return ((tmsize_t)(-1));
546
547 if (!isFillOrder(tif, td->td_fillorder) &&
548 (tif->tif_flags & TIFF_NOBITREV) == 0)
549 TIFFReverseBits(buf,stripsize);
550
551 (*tif->tif_postdecode)(tif,buf,stripsize);
552 return (stripsize);
553 }
554
555 if ((size!=(tmsize_t)(-1))&&(size<stripsize))
556 stripsize=size;
557 if (!TIFFFillStrip(tif,strip))
558 return((tmsize_t)(-1));
559 if ((*tif->tif_decodestrip)(tif,buf,stripsize,plane)<=0)
560 return((tmsize_t)(-1));
561 (*tif->tif_postdecode)(tif,buf,stripsize);
562 return(stripsize);
563}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum plane
Definition: glfuncs.h:270
TIFFCodeMethod tif_decodestrip
Definition: tiffiop.h:182
TIFFPostMethod tif_postdecode
Definition: tiffiop.h:214
static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF *tif, uint32 strip, uint16 *pplane)
Definition: tif_read.c:488
static tmsize_t TIFFReadRawStrip1(TIFF *tif, uint32 strip, void *buf, tmsize_t size, const char *module)
Definition: tif_read.c:609
int TIFFFillStrip(TIFF *tif, uint32 strip)
Definition: tif_read.c:766
void TIFFReverseBits(uint8 *cp, tmsize_t n)
Definition: tif_swab.c:284
#define TIFF_NOBITREV
Definition: tiffiop.h:127

Referenced by _TIFFReadEncodedStripAndAllocBuffer(), and gtStripSeparate().

◆ TIFFReadEncodedTile()

tmsize_t TIFFReadEncodedTile ( TIFF tif,
uint32  tile,
void buf,
tmsize_t  size 
)

Definition at line 978 of file tif_read.c.

979{
980 static const char module[] = "TIFFReadEncodedTile";
981 TIFFDirectory *td = &tif->tif_dir;
982 tmsize_t tilesize = tif->tif_tilesize;
983
984 if (!TIFFCheckRead(tif, 1))
985 return ((tmsize_t)(-1));
986 if (tile >= td->td_nstrips) {
988 "%lu: Tile out of range, max %lu",
989 (unsigned long) tile, (unsigned long) td->td_nstrips);
990 return ((tmsize_t)(-1));
991 }
992
993 /* shortcut to avoid an extra memcpy() */
994 if( td->td_compression == COMPRESSION_NONE &&
995 size!=(tmsize_t)(-1) && size >= tilesize &&
996 !isMapped(tif) &&
997 ((tif->tif_flags&TIFF_NOREADRAW)==0) )
998 {
999 if (TIFFReadRawTile1(tif, tile, buf, tilesize, module) != tilesize)
1000 return ((tmsize_t)(-1));
1001
1002 if (!isFillOrder(tif, td->td_fillorder) &&
1003 (tif->tif_flags & TIFF_NOBITREV) == 0)
1004 TIFFReverseBits(buf,tilesize);
1005
1006 (*tif->tif_postdecode)(tif,buf,tilesize);
1007 return (tilesize);
1008 }
1009
1010 if (size == (tmsize_t)(-1))
1011 size = tilesize;
1012 else if (size > tilesize)
1013 size = tilesize;
1014 if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif,
1015 (uint8*) buf, size, (uint16)(tile/td->td_stripsperimage))) {
1016 (*tif->tif_postdecode)(tif, (uint8*) buf, size);
1017 return (size);
1018 } else
1019 return ((tmsize_t)(-1));
1020}
TIFFCodeMethod tif_decodetile
Definition: tiffiop.h:184
static int TIFFCheckRead(TIFF *, int)
Definition: tif_read.c:1500
static tmsize_t TIFFReadRawTile1(TIFF *tif, uint32 tile, void *buf, tmsize_t size, const char *module)
Definition: tif_read.c:1094
int TIFFFillTile(TIFF *tif, uint32 tile)
Definition: tif_read.c:1204

Referenced by _TIFFReadEncodedTileAndAllocBuffer(), and TIFFReadTile().

◆ TIFFReadEXIFDirectory()

int TIFFReadEXIFDirectory ( TIFF tif,
toff_t  diroff 
)

Definition at line 4501 of file tif_dirread.c.

4502{
4505 return TIFFReadCustomDirectory(tif, diroff, exifFieldArray);
4506}
int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff, const TIFFFieldArray *infoarray)
Definition: tif_dirread.c:4394

◆ TIFFReadFromUserBuffer()

int TIFFReadFromUserBuffer ( TIFF tif,
uint32  strile,
void inbuf,
tmsize_t  insize,
void outbuf,
tmsize_t  outsize 
)

Definition at line 1524 of file tif_read.c.

1527{
1528 static const char module[] = "TIFFReadFromUserBuffer";
1529 TIFFDirectory *td = &tif->tif_dir;
1530 int ret = 1;
1531 uint32 old_tif_flags = tif->tif_flags;
1532 tmsize_t old_rawdatasize = tif->tif_rawdatasize;
1533 void* old_rawdata = tif->tif_rawdata;
1534
1535 if (tif->tif_mode == O_WRONLY) {
1536 TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "File not open for reading");
1537 return 0;
1538 }
1539 if (tif->tif_flags&TIFF_NOREADRAW)
1540 {
1542 "Compression scheme does not support access to raw uncompressed data");
1543 return 0;
1544 }
1545
1546 tif->tif_flags &= ~TIFF_MYBUFFER;
1547 tif->tif_flags |= TIFF_BUFFERMMAP;
1548 tif->tif_rawdatasize = insize;
1549 tif->tif_rawdata = inbuf;
1550 tif->tif_rawdataoff = 0;
1552
1553 if (!isFillOrder(tif, td->td_fillorder) &&
1554 (tif->tif_flags & TIFF_NOBITREV) == 0)
1555 {
1557 }
1558
1559 if( TIFFIsTiled(tif) )
1560 {
1561 if( !TIFFStartTile(tif, strile) ||
1562 !(*tif->tif_decodetile)(tif, (uint8*) outbuf, outsize,
1563 (uint16)(strile/td->td_stripsperimage)) )
1564 {
1565 ret = 0;
1566 }
1567 }
1568 else
1569 {
1570 uint32 rowsperstrip=td->td_rowsperstrip;
1571 uint32 stripsperplane;
1572 if (rowsperstrip>td->td_imagelength)
1573 rowsperstrip=td->td_imagelength;
1574 stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
1575 if( !TIFFStartStrip(tif, strile) ||
1576 !(*tif->tif_decodestrip)(tif, (uint8*) outbuf, outsize,
1577 (uint16)(strile/stripsperplane)) )
1578 {
1579 ret = 0;
1580 }
1581 }
1582 if( ret )
1583 {
1584 (*tif->tif_postdecode)(tif, (uint8*) outbuf, outsize);
1585 }
1586
1587 if (!isFillOrder(tif, td->td_fillorder) &&
1588 (tif->tif_flags & TIFF_NOBITREV) == 0)
1589 {
1591 }
1592
1593 tif->tif_flags = old_tif_flags;
1594 tif->tif_rawdatasize = old_rawdatasize;
1595 tif->tif_rawdata = old_rawdata;
1596 tif->tif_rawdataoff = 0;
1597 tif->tif_rawdataloaded = 0;
1598
1599 return ret;
1600}
#define O_WRONLY
Definition: acwin.h:111
static int inbuf
Definition: adnsresfilter.c:73
const unsigned char size_t insize
Definition: jpeglib.h:984
unsigned char size_t * outsize
Definition: jpeglib.h:981
static int TIFFStartStrip(TIFF *tif, uint32 strip)
Definition: tif_read.c:1422
static int TIFFStartTile(TIFF *tif, uint32 tile)
Definition: tif_read.c:1457
#define TIFFhowmany_32_maxuint_compat(x, y)
Definition: tiffiop.h:269
#define TIFF_BUFFERMMAP
Definition: tiffiop.h:142

◆ TIFFReadRawStrip()

tmsize_t TIFFReadRawStrip ( TIFF tif,
uint32  strip,
void buf,
tmsize_t  size 
)

Definition at line 722 of file tif_read.c.

723{
724 static const char module[] = "TIFFReadRawStrip";
725 TIFFDirectory *td = &tif->tif_dir;
726 uint64 bytecount64;
727 tmsize_t bytecountm;
728
729 if (!TIFFCheckRead(tif, 0))
730 return ((tmsize_t)(-1));
731 if (strip >= td->td_nstrips) {
733 "%lu: Strip out of range, max %lu",
734 (unsigned long) strip,
735 (unsigned long) td->td_nstrips);
736 return ((tmsize_t)(-1));
737 }
738 if (tif->tif_flags&TIFF_NOREADRAW)
739 {
741 "Compression scheme does not support access to raw uncompressed data");
742 return ((tmsize_t)(-1));
743 }
744 bytecount64 = TIFFGetStrileByteCount(tif, strip);
745 if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64)
746 bytecountm = size;
747 else
748 bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module);
749 if( bytecountm == 0 ) {
750 return ((tmsize_t)(-1));
751 }
752 return (TIFFReadRawStrip1(tif, strip, buf, bytecountm, module));
753}

◆ TIFFReadRawTile()

tmsize_t TIFFReadRawTile ( TIFF tif,
uint32  tile,
void buf,
tmsize_t  size 
)

Definition at line 1167 of file tif_read.c.

1168{
1169 static const char module[] = "TIFFReadRawTile";
1170 TIFFDirectory *td = &tif->tif_dir;
1171 uint64 bytecount64;
1172 tmsize_t bytecountm;
1173
1174 if (!TIFFCheckRead(tif, 1))
1175 return ((tmsize_t)(-1));
1176 if (tile >= td->td_nstrips) {
1178 "%lu: Tile out of range, max %lu",
1179 (unsigned long) tile, (unsigned long) td->td_nstrips);
1180 return ((tmsize_t)(-1));
1181 }
1182 if (tif->tif_flags&TIFF_NOREADRAW)
1183 {
1185 "Compression scheme does not support access to raw uncompressed data");
1186 return ((tmsize_t)(-1));
1187 }
1188 bytecount64 = TIFFGetStrileByteCount(tif, tile);
1189 if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64)
1190 bytecountm = size;
1191 else
1192 bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module);
1193 if( bytecountm == 0 ) {
1194 return ((tmsize_t)(-1));
1195 }
1196 return (TIFFReadRawTile1(tif, tile, buf, bytecountm, module));
1197}

◆ TIFFReadRGBAImage()

int TIFFReadRGBAImage ( TIFF tif,
uint32  rwidth,
uint32  rheight,
uint32 raster,
int  stop 
)

Definition at line 545 of file tif_getimage.c.

547{
548 return TIFFReadRGBAImageOriented(tif, rwidth, rheight, raster,
549 ORIENTATION_BOTLEFT, stop);
550}
int TIFFReadRGBAImageOriented(TIFF *tif, uint32 rwidth, uint32 rheight, uint32 *raster, int orientation, int stop)
Definition: tif_getimage.c:519
#define ORIENTATION_BOTLEFT
Definition: tiff.h:226

◆ TIFFReadRGBAImageOriented()

int TIFFReadRGBAImageOriented ( TIFF tif,
uint32  rwidth,
uint32  rheight,
uint32 raster,
int  orientation,
int  stop 
)

Definition at line 519 of file tif_getimage.c.

522{
523 char emsg[1024] = "";
525 int ok;
526
527 if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop, emsg)) {
528 img.req_orientation = (uint16)orientation;
529 /* XXX verify rwidth and rheight against width and height */
530 ok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth,
531 rwidth, img.height);
533 } else {
534 TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg);
535 ok = 0;
536 }
537 return (ok);
538}
GLint GLvoid * img
Definition: gl.h:1956
int TIFFRGBAImageGet(TIFFRGBAImage *img, uint32 *raster, uint32 w, uint32 h)
Definition: tif_getimage.c:500
int TIFFRGBAImageBegin(TIFFRGBAImage *img, TIFF *tif, int stop, char emsg[1024])
Definition: tif_getimage.c:265
void TIFFRGBAImageEnd(TIFFRGBAImage *img)
Definition: tif_getimage.c:214
int TIFFRGBAImageOK(TIFF *tif, char emsg[1024])
Definition: tif_getimage.c:74
const char * TIFFFileName(TIFF *tif)
Definition: tif_open.c:513

Referenced by TIFFReadRGBAImage().

◆ TIFFReadRGBAStrip()

int TIFFReadRGBAStrip ( TIFF tif,
uint32  row,
uint32 raster 
)

Definition at line 2889 of file tif_getimage.c.

2891{
2892 return TIFFReadRGBAStripExt(tif, row, raster, 0 );
2893}
int TIFFReadRGBAStripExt(TIFF *tif, uint32 row, uint32 *raster, int stop_on_error)

◆ TIFFReadRGBAStripExt()

int TIFFReadRGBAStripExt ( TIFF tif,
uint32  row,
uint32 raster,
int  stop_on_error 
)

Definition at line 2896 of file tif_getimage.c.

2898{
2899 char emsg[1024] = "";
2901 int ok;
2902 uint32 rowsperstrip, rows_to_read;
2903
2904 if( TIFFIsTiled( tif ) )
2905 {
2907 "Can't use TIFFReadRGBAStrip() with tiled file.");
2908 return (0);
2909 }
2910
2911 TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
2912 if( (row % rowsperstrip) != 0 )
2913 {
2915 "Row passed to TIFFReadRGBAStrip() must be first in a strip.");
2916 return (0);
2917 }
2918
2919 if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) {
2920
2921 img.row_offset = row;
2922 img.col_offset = 0;
2923
2924 if( row + rowsperstrip > img.height )
2925 rows_to_read = img.height - row;
2926 else
2927 rows_to_read = rowsperstrip;
2928
2929 ok = TIFFRGBAImageGet(&img, raster, img.width, rows_to_read );
2930
2932 } else {
2933 TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg);
2934 ok = 0;
2935 }
2936
2937 return (ok);
2938}
int TIFFGetFieldDefaulted(TIFF *tif, uint32 tag,...)
Definition: tif_aux.c:345

Referenced by TIFFReadRGBAStrip().

◆ TIFFReadRGBATile()

int TIFFReadRGBATile ( TIFF tif,
uint32  col,
uint32  row,
uint32 raster 
)

Definition at line 2947 of file tif_getimage.c.

2949{
2950 return TIFFReadRGBATileExt(tif, col, row, raster, 0 );
2951}
int TIFFReadRGBATileExt(TIFF *tif, uint32 col, uint32 row, uint32 *raster, int stop_on_error)

◆ TIFFReadRGBATileExt()

int TIFFReadRGBATileExt ( TIFF tif,
uint32  col,
uint32  row,
uint32 raster,
int  stop_on_error 
)

Definition at line 2955 of file tif_getimage.c.

2956{
2957 char emsg[1024] = "";
2959 int ok;
2960 uint32 tile_xsize, tile_ysize;
2961 uint32 read_xsize, read_ysize;
2962 uint32 i_row;
2963
2964 /*
2965 * Verify that our request is legal - on a tile file, and on a
2966 * tile boundary.
2967 */
2968
2969 if( !TIFFIsTiled( tif ) )
2970 {
2972 "Can't use TIFFReadRGBATile() with striped file.");
2973 return (0);
2974 }
2975
2976 TIFFGetFieldDefaulted(tif, TIFFTAG_TILEWIDTH, &tile_xsize);
2977 TIFFGetFieldDefaulted(tif, TIFFTAG_TILELENGTH, &tile_ysize);
2978 if( (col % tile_xsize) != 0 || (row % tile_ysize) != 0 )
2979 {
2981 "Row/col passed to TIFFReadRGBATile() must be top"
2982 "left corner of a tile.");
2983 return (0);
2984 }
2985
2986 /*
2987 * Setup the RGBA reader.
2988 */
2989
2990 if (!TIFFRGBAImageOK(tif, emsg)
2991 || !TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) {
2992 TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg);
2993 return( 0 );
2994 }
2995
2996 /*
2997 * The TIFFRGBAImageGet() function doesn't allow us to get off the
2998 * edge of the image, even to fill an otherwise valid tile. So we
2999 * figure out how much we can read, and fix up the tile buffer to
3000 * a full tile configuration afterwards.
3001 */
3002
3003 if( row + tile_ysize > img.height )
3004 read_ysize = img.height - row;
3005 else
3006 read_ysize = tile_ysize;
3007
3008 if( col + tile_xsize > img.width )
3009 read_xsize = img.width - col;
3010 else
3011 read_xsize = tile_xsize;
3012
3013 /*
3014 * Read the chunk of imagery.
3015 */
3016
3017 img.row_offset = row;
3018 img.col_offset = col;
3019
3020 ok = TIFFRGBAImageGet(&img, raster, read_xsize, read_ysize );
3021
3023
3024 /*
3025 * If our read was incomplete we will need to fix up the tile by
3026 * shifting the data around as if a full tile of data is being returned.
3027 *
3028 * This is all the more complicated because the image is organized in
3029 * bottom to top format.
3030 */
3031
3032 if( read_xsize == tile_xsize && read_ysize == tile_ysize )
3033 return( ok );
3034
3035 for( i_row = 0; i_row < read_ysize; i_row++ ) {
3036 memmove( raster + (tile_ysize - i_row - 1) * tile_xsize,
3037 raster + (read_ysize - i_row - 1) * read_xsize,
3038 read_xsize * sizeof(uint32) );
3039 _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize+read_xsize,
3040 0, sizeof(uint32) * (tile_xsize - read_xsize) );
3041 }
3042
3043 for( i_row = read_ysize; i_row < tile_ysize; i_row++ ) {
3044 _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize,
3045 0, sizeof(uint32) * tile_xsize );
3046 }
3047
3048 return (ok);
3049}
#define memmove(s1, s2, n)
Definition: mkisofs.h:881

Referenced by TIFFReadRGBATile().

◆ TIFFReadScanline()

int TIFFReadScanline ( TIFF tif,
void buf,
uint32  row,
uint16  sample 
)

Definition at line 460 of file tif_read.c.

461{
462 int e;
463
464 if (!TIFFCheckRead(tif, 0))
465 return (-1);
466 if( (e = TIFFSeek(tif, row, sample)) != 0) {
467 /*
468 * Decompress desired row into user buffer.
469 */
470 e = (*tif->tif_decoderow)
471 (tif, (uint8*) buf, tif->tif_scanlinesize, sample);
472
473 /* we are now poised at the beginning of the next row */
474 tif->tif_row = row + 1;
475
476 if (e)
477 (*tif->tif_postdecode)(tif, (uint8*) buf,
478 tif->tif_scanlinesize);
479 }
480 return (e > 0 ? 1 : -1);
481}
#define e
Definition: ke_i.h:82
TIFFCodeMethod tif_decoderow
Definition: tiffiop.h:180
static int TIFFSeek(TIFF *tif, uint32 row, uint16 sample)
Definition: tif_read.c:329

◆ TIFFReadTile()

tmsize_t TIFFReadTile ( TIFF tif,
void buf,
uint32  x,
uint32  y,
uint32  z,
uint16  s 
)

Definition at line 965 of file tif_read.c.

966{
967 if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
968 return ((tmsize_t)(-1));
969 return (TIFFReadEncodedTile(tif,
970 TIFFComputeTile(tif, x, y, z, s), buf, (tmsize_t)(-1)));
971}
tmsize_t TIFFReadEncodedTile(TIFF *tif, uint32 tile, void *buf, tmsize_t size)
Definition: tif_read.c:978
int TIFFCheckTile(TIFF *tif, uint32 x, uint32 y, uint32 z, uint16 s)
Definition: tif_tile.c:73
uint32 TIFFComputeTile(TIFF *tif, uint32 x, uint32 y, uint32 z, uint16 s)
Definition: tif_tile.c:36

Referenced by gtTileSeparate().

◆ TIFFRegisterCODEC()

TIFFCodec * TIFFRegisterCODEC ( uint16  scheme,
const char name,
TIFFInitMethod  init 
)

Definition at line 201 of file tif_compress.c.

202{
203 codec_t* cd = (codec_t*)
204 _TIFFmalloc((tmsize_t)(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1));
205
206 if (cd != NULL) {
207 cd->info = (TIFFCodec*) ((uint8*) cd + sizeof (codec_t));
208 cd->info->name = (char*)
209 ((uint8*) cd->info + sizeof (TIFFCodec));
210 strcpy(cd->info->name, name);
211 cd->info->scheme = scheme;
212 cd->info->init = init;
213 cd->next = registeredCODECS;
215 } else {
216 TIFFErrorExt(0, "TIFFRegisterCODEC",
217 "No space to register compression scheme %s", name);
218 return NULL;
219 }
220 return (cd->info);
221}
struct _codec codec_t
static int init
Definition: wintirpc.c:33

◆ TIFFReverseBits()

void TIFFReverseBits ( uint8 cp,
tmsize_t  n 
)

Definition at line 284 of file tif_swab.c.

285{
286 for (; n > 8; n -= 8) {
287 cp[0] = TIFFBitRevTable[cp[0]];
288 cp[1] = TIFFBitRevTable[cp[1]];
289 cp[2] = TIFFBitRevTable[cp[2]];
290 cp[3] = TIFFBitRevTable[cp[3]];
291 cp[4] = TIFFBitRevTable[cp[4]];
292 cp[5] = TIFFBitRevTable[cp[5]];
293 cp[6] = TIFFBitRevTable[cp[6]];
294 cp[7] = TIFFBitRevTable[cp[7]];
295 cp += 8;
296 }
297 while (n-- > 0) {
298 *cp = TIFFBitRevTable[*cp];
299 cp++;
300 }
301}

Referenced by TIFFFillStrip(), TIFFFillStripPartial(), TIFFFillTile(), TIFFFlushData1(), TIFFReadEncodedStrip(), TIFFReadEncodedTile(), TIFFReadFromUserBuffer(), TIFFWriteEncodedStrip(), and TIFFWriteEncodedTile().

◆ TIFFRewriteDirectory()

int TIFFRewriteDirectory ( TIFF tif)

Definition at line 261 of file tif_dirwrite.c.

262{
263 static const char module[] = "TIFFRewriteDirectory";
264
265 /* We don't need to do anything special if it hasn't been written. */
266 if( tif->tif_diroff == 0 )
267 return TIFFWriteDirectory( tif );
268
269 /*
270 * Find and zero the pointer to this directory, so that TIFFLinkDirectory
271 * will cause it to be added after this directories current pre-link.
272 */
273
274 if (!(tif->tif_flags&TIFF_BIGTIFF))
275 {
276 if (tif->tif_header.classic.tiff_diroff == tif->tif_diroff)
277 {
279 tif->tif_diroff = 0;
280
281 TIFFSeekFile(tif,4,SEEK_SET);
282 if (!WriteOK(tif, &(tif->tif_header.classic.tiff_diroff),4))
283 {
285 "Error updating TIFF header");
286 return (0);
287 }
288 }
289 else
290 {
291 uint32 nextdir;
292 nextdir = tif->tif_header.classic.tiff_diroff;
293 while(1) {
294 uint16 dircount;
295 uint32 nextnextdir;
296
297 if (!SeekOK(tif, nextdir) ||
298 !ReadOK(tif, &dircount, 2)) {
300 "Error fetching directory count");
301 return (0);
302 }
303 if (tif->tif_flags & TIFF_SWAB)
304 TIFFSwabShort(&dircount);
305 (void) TIFFSeekFile(tif,
306 nextdir+2+dircount*12, SEEK_SET);
307 if (!ReadOK(tif, &nextnextdir, 4)) {
309 "Error fetching directory link");
310 return (0);
311 }
312 if (tif->tif_flags & TIFF_SWAB)
313 TIFFSwabLong(&nextnextdir);
314 if (nextnextdir==tif->tif_diroff)
315 {
316 uint32 m;
317 m=0;
318 (void) TIFFSeekFile(tif,
319 nextdir+2+dircount*12, SEEK_SET);
320 if (!WriteOK(tif, &m, 4)) {
322 "Error writing directory link");
323 return (0);
324 }
325 tif->tif_diroff=0;
326 break;
327 }
328 nextdir=nextnextdir;
329 }
330 }
331 }
332 else
333 {
334 if (tif->tif_header.big.tiff_diroff == tif->tif_diroff)
335 {
336 tif->tif_header.big.tiff_diroff = 0;
337 tif->tif_diroff = 0;
338
339 TIFFSeekFile(tif,8,SEEK_SET);
340 if (!WriteOK(tif, &(tif->tif_header.big.tiff_diroff),8))
341 {
343 "Error updating TIFF header");
344 return (0);
345 }
346 }
347 else
348 {
349 uint64 nextdir;
350 nextdir = tif->tif_header.big.tiff_diroff;
351 while(1) {
352 uint64 dircount64;
353 uint16 dircount;
354 uint64 nextnextdir;
355
356 if (!SeekOK(tif, nextdir) ||
357 !ReadOK(tif, &dircount64, 8)) {
359 "Error fetching directory count");
360 return (0);
361 }
362 if (tif->tif_flags & TIFF_SWAB)
363 TIFFSwabLong8(&dircount64);
364 if (dircount64>0xFFFF)
365 {
367 "Sanity check on tag count failed, likely corrupt TIFF");
368 return (0);
369 }
370 dircount=(uint16)dircount64;
371 (void) TIFFSeekFile(tif,
372 nextdir+8+dircount*20, SEEK_SET);
373 if (!ReadOK(tif, &nextnextdir, 8)) {
375 "Error fetching directory link");
376 return (0);
377 }
378 if (tif->tif_flags & TIFF_SWAB)
379 TIFFSwabLong8(&nextnextdir);
380 if (nextnextdir==tif->tif_diroff)
381 {
382 uint64 m;
383 m=0;
384 (void) TIFFSeekFile(tif,
385 nextdir+8+dircount*20, SEEK_SET);
386 if (!WriteOK(tif, &m, 8)) {
388 "Error writing directory link");
389 return (0);
390 }
391 tif->tif_diroff=0;
392 break;
393 }
394 nextdir=nextnextdir;
395 }
396 }
397 }
398
399 /*
400 * Now use TIFFWriteDirectory() normally.
401 */
402
403 return TIFFWriteDirectory( tif );
404}
int TIFFWriteDirectory(TIFF *tif)
Definition: tif_dirwrite.c:180
#define SeekOK(tif, off)
Definition: tiffiop.h:256

Referenced by TIFFFlush().

◆ TIFFRGBAImageBegin()

int TIFFRGBAImageBegin ( TIFFRGBAImage img,
TIFF tif,
int  stop,
char  emsg[1024] 
)

Definition at line 265 of file tif_getimage.c.

266{
267 uint16* sampleinfo;
268 uint16 extrasamples;
269 uint16 planarconfig;
271 int colorchannels;
272 uint16 *red_orig, *green_orig, *blue_orig;
273 int n_color;
274
275 if( !TIFFRGBAImageOK(tif, emsg) )
276 return 0;
277
278 /* Initialize to normal values */
279 img->row_offset = 0;
280 img->col_offset = 0;
281 img->redcmap = NULL;
282 img->greencmap = NULL;
283 img->bluecmap = NULL;
284 img->Map = NULL;
285 img->BWmap = NULL;
286 img->PALmap = NULL;
287 img->ycbcr = NULL;
288 img->cielab = NULL;
289 img->UaToAa = NULL;
290 img->Bitdepth16To8 = NULL;
291 img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */
292
293 img->tif = tif;
294 img->stoponerr = stop;
295 TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample);
296 switch (img->bitspersample) {
297 case 1:
298 case 2:
299 case 4:
300 case 8:
301 case 16:
302 break;
303 default:
304 sprintf(emsg, "Sorry, can not handle images with %d-bit samples",
305 img->bitspersample);
306 goto fail_return;
307 }
308 img->alpha = 0;
309 TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel);
311 &extrasamples, &sampleinfo);
312 if (extrasamples >= 1)
313 {
314 switch (sampleinfo[0]) {
315 case EXTRASAMPLE_UNSPECIFIED: /* Workaround for some images without */
316 if (img->samplesperpixel > 3) /* correct info about alpha channel */
318 break;
319 case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */
320 case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */
321 img->alpha = sampleinfo[0];
322 break;
323 }
324 }
325
326#ifdef DEFAULT_EXTRASAMPLE_AS_ALPHA
327 if( !TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric))
328 img->photometric = PHOTOMETRIC_MINISWHITE;
329
330 if( extrasamples == 0
331 && img->samplesperpixel == 4
332 && img->photometric == PHOTOMETRIC_RGB )
333 {
335 extrasamples = 1;
336 }
337#endif
338
339 colorchannels = img->samplesperpixel - extrasamples;
341 TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig);
342 if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) {
343 switch (colorchannels) {
344 case 1:
345 if (isCCITTCompression(tif))
346 img->photometric = PHOTOMETRIC_MINISWHITE;
347 else
348 img->photometric = PHOTOMETRIC_MINISBLACK;
349 break;
350 case 3:
351 img->photometric = PHOTOMETRIC_RGB;
352 break;
353 default:
354 sprintf(emsg, "Missing needed %s tag", photoTag);
355 goto fail_return;
356 }
357 }
358 switch (img->photometric) {
361 &red_orig, &green_orig, &blue_orig)) {
362 sprintf(emsg, "Missing required \"Colormap\" tag");
363 goto fail_return;
364 }
365
366 /* copy the colormaps so we can modify them */
367 n_color = (1U << img->bitspersample);
368 img->redcmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color);
369 img->greencmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color);
370 img->bluecmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color);
371 if( !img->redcmap || !img->greencmap || !img->bluecmap ) {
372 sprintf(emsg, "Out of memory for colormap copy");
373 goto fail_return;
374 }
375
376 _TIFFmemcpy( img->redcmap, red_orig, n_color * 2 );
377 _TIFFmemcpy( img->greencmap, green_orig, n_color * 2 );
378 _TIFFmemcpy( img->bluecmap, blue_orig, n_color * 2 );
379
380 /* fall through... */
383 if (planarconfig == PLANARCONFIG_CONTIG
384 && img->samplesperpixel != 1
385 && img->bitspersample < 8 ) {
386 sprintf(emsg,
387 "Sorry, can not handle contiguous data with %s=%d, "
388 "and %s=%d and Bits/Sample=%d",
389 photoTag, img->photometric,
390 "Samples/pixel", img->samplesperpixel,
391 img->bitspersample);
392 goto fail_return;
393 }
394 break;
396 /* It would probably be nice to have a reality check here. */
397 if (planarconfig == PLANARCONFIG_CONTIG)
398 /* can rely on libjpeg to convert to RGB */
399 /* XXX should restore current state on exit */
400 switch (compress) {
401 case COMPRESSION_JPEG:
402 /*
403 * TODO: when complete tests verify complete desubsampling
404 * and YCbCr handling, remove use of TIFFTAG_JPEGCOLORMODE in
405 * favor of tif_getimage.c native handling
406 */
408 img->photometric = PHOTOMETRIC_RGB;
409 break;
410 default:
411 /* do nothing */;
412 break;
413 }
414 /*
415 * TODO: if at all meaningful and useful, make more complete
416 * support check here, or better still, refactor to let supporting
417 * code decide whether there is support and what meaningful
418 * error to return
419 */
420 break;
421 case PHOTOMETRIC_RGB:
422 if (colorchannels < 3) {
423 sprintf(emsg, "Sorry, can not handle RGB image with %s=%d",
424 "Color channels", colorchannels);
425 goto fail_return;
426 }
427 break;
429 {
430 uint16 inkset;
432 if (inkset != INKSET_CMYK) {
433 sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
434 "InkSet", inkset);
435 goto fail_return;
436 }
437 if (img->samplesperpixel < 4) {
438 sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
439 "Samples/pixel", img->samplesperpixel);
440 goto fail_return;
441 }
442 }
443 break;
444 case PHOTOMETRIC_LOGL:
446 sprintf(emsg, "Sorry, LogL data must have %s=%d",
447 "Compression", COMPRESSION_SGILOG);
448 goto fail_return;
449 }
451 img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */
452 img->bitspersample = 8;
453 break;
456 sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d",
458 goto fail_return;
459 }
460 if (planarconfig != PLANARCONFIG_CONTIG) {
461 sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d",
462 "Planarconfiguration", planarconfig);
463 return (0);
464 }
466 img->photometric = PHOTOMETRIC_RGB; /* little white lie */
467 img->bitspersample = 8;
468 break;
470 break;
471 default:
472 sprintf(emsg, "Sorry, can not handle image with %s=%d",
473 photoTag, img->photometric);
474 goto fail_return;
475 }
476 TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width);
477 TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height);
478 TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation);
479 img->isContig =
480 !(planarconfig == PLANARCONFIG_SEPARATE && img->samplesperpixel > 1);
481 if (img->isContig) {
482 if (!PickContigCase(img)) {
483 sprintf(emsg, "Sorry, can not handle image");
484 goto fail_return;
485 }
486 } else {
487 if (!PickSeparateCase(img)) {
488 sprintf(emsg, "Sorry, can not handle image");
489 goto fail_return;
490 }
491 }
492 return 1;
493
494 fail_return:
496 return 0;
497}
#define sprintf(buf, format,...)
Definition: sprintf.c:55
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition: compress.c:68
static int PickContigCase(TIFFRGBAImage *)
static int isCCITTCompression(TIFF *tif)
Definition: tif_getimage.c:254
static int PickSeparateCase(TIFFRGBAImage *)
static const char photoTag[]
Definition: tif_getimage.c:43
#define TIFFTAG_INKSET
Definition: tiff.h:296
#define COMPRESSION_SGILOG
Definition: tiff.h:186
#define PHOTOMETRIC_CIELAB
Definition: tiff.h:202
#define PHOTOMETRIC_SEPARATED
Definition: tiff.h:200
#define TIFFTAG_ORIENTATION
Definition: tiff.h:222
#define SGILOGDATAFMT_8BIT
Definition: tiff.h:561
#define INKSET_CMYK
Definition: tiff.h:297
#define TIFFTAG_SGILOGDATAFMT
Definition: tiff.h:557
#define COMPRESSION_SGILOG24
Definition: tiff.h:187
#define TIFFTAG_JPEGCOLORMODE
Definition: tiff.h:520
#define JPEGCOLORMODE_RGB
Definition: tiff.h:522
#define COMPRESSION_JPEG
Definition: tiff.h:166

Referenced by TIFFReadRGBAImageOriented(), TIFFReadRGBAStripExt(), and TIFFReadRGBATileExt().

◆ TIFFRGBAImageEnd()

void TIFFRGBAImageEnd ( TIFFRGBAImage img)

Definition at line 214 of file tif_getimage.c.

215{
216 if (img->Map) {
217 _TIFFfree(img->Map);
218 img->Map = NULL;
219 }
220 if (img->BWmap) {
221 _TIFFfree(img->BWmap);
222 img->BWmap = NULL;
223 }
224 if (img->PALmap) {
225 _TIFFfree(img->PALmap);
226 img->PALmap = NULL;
227 }
228 if (img->ycbcr) {
229 _TIFFfree(img->ycbcr);
230 img->ycbcr = NULL;
231 }
232 if (img->cielab) {
233 _TIFFfree(img->cielab);
234 img->cielab = NULL;
235 }
236 if (img->UaToAa) {
237 _TIFFfree(img->UaToAa);
238 img->UaToAa = NULL;
239 }
240 if (img->Bitdepth16To8) {
241 _TIFFfree(img->Bitdepth16To8);
242 img->Bitdepth16To8 = NULL;
243 }
244
245 if( img->redcmap ) {
246 _TIFFfree( img->redcmap );
247 _TIFFfree( img->greencmap );
248 _TIFFfree( img->bluecmap );
249 img->redcmap = img->greencmap = img->bluecmap = NULL;
250 }
251}

Referenced by TIFFReadRGBAImageOriented(), TIFFReadRGBAStripExt(), TIFFReadRGBATileExt(), and TIFFRGBAImageBegin().

◆ TIFFRGBAImageGet()

int TIFFRGBAImageGet ( TIFFRGBAImage img,
uint32 raster,
uint32  w,
uint32  h 
)

Definition at line 500 of file tif_getimage.c.

501{
502 if (img->get == NULL) {
503 TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No \"get\" routine setup");
504 return (0);
505 }
506 if (img->put.any == NULL) {
507 TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif),
508 "No \"put\" routine setupl; probably can not handle image format");
509 return (0);
510 }
511 return (*img->get)(img, raster, w, h);
512}
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723

Referenced by TIFFReadRGBAImageOriented(), TIFFReadRGBAStripExt(), and TIFFReadRGBATileExt().

◆ TIFFRGBAImageOK()

int TIFFRGBAImageOK ( TIFF tif,
char  emsg[1024] 
)

Definition at line 74 of file tif_getimage.c.

75{
76 TIFFDirectory* td = &tif->tif_dir;
77 uint16 photometric;
78 int colorchannels;
79
80 if (!tif->tif_decodestatus) {
81 sprintf(emsg, "Sorry, requested compression method is not configured");
82 return (0);
83 }
84 switch (td->td_bitspersample) {
85 case 1:
86 case 2:
87 case 4:
88 case 8:
89 case 16:
90 break;
91 default:
92 sprintf(emsg, "Sorry, can not handle images with %d-bit samples",
94 return (0);
95 }
97 sprintf(emsg, "Sorry, can not handle images with IEEE floating-point samples");
98 return (0);
99 }
100 colorchannels = td->td_samplesperpixel - td->td_extrasamples;
101 if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) {
102 switch (colorchannels) {
103 case 1:
104 photometric = PHOTOMETRIC_MINISBLACK;
105 break;
106 case 3:
107 photometric = PHOTOMETRIC_RGB;
108 break;
109 default:
110 sprintf(emsg, "Missing needed %s tag", photoTag);
111 return (0);
112 }
113 }
114 switch (photometric) {
119 && td->td_samplesperpixel != 1
120 && td->td_bitspersample < 8 ) {
121 sprintf(emsg,
122 "Sorry, can not handle contiguous data with %s=%d, "
123 "and %s=%d and Bits/Sample=%d",
124 photoTag, photometric,
125 "Samples/pixel", td->td_samplesperpixel,
126 td->td_bitspersample);
127 return (0);
128 }
129 /*
130 * We should likely validate that any extra samples are either
131 * to be ignored, or are alpha, and if alpha we should try to use
132 * them. But for now we won't bother with this.
133 */
134 break;
136 /*
137 * TODO: if at all meaningful and useful, make more complete
138 * support check here, or better still, refactor to let supporting
139 * code decide whether there is support and what meaningful
140 * error to return
141 */
142 break;
143 case PHOTOMETRIC_RGB:
144 if (colorchannels < 3) {
145 sprintf(emsg, "Sorry, can not handle RGB image with %s=%d",
146 "Color channels", colorchannels);
147 return (0);
148 }
149 break;
151 {
152 uint16 inkset;
154 if (inkset != INKSET_CMYK) {
155 sprintf(emsg,
156 "Sorry, can not handle separated image with %s=%d",
157 "InkSet", inkset);
158 return 0;
159 }
160 if (td->td_samplesperpixel < 4) {
161 sprintf(emsg,
162 "Sorry, can not handle separated image with %s=%d",
163 "Samples/pixel", td->td_samplesperpixel);
164 return 0;
165 }
166 break;
167 }
168 case PHOTOMETRIC_LOGL:
170 sprintf(emsg, "Sorry, LogL data must have %s=%d",
171 "Compression", COMPRESSION_SGILOG);
172 return (0);
173 }
174 break;
178 sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d",
180 return (0);
181 }
183 sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d",
184 "Planarconfiguration", td->td_planarconfig);
185 return (0);
186 }
187 if ( td->td_samplesperpixel != 3 || colorchannels != 3 ) {
188 sprintf(emsg,
189 "Sorry, can not handle image with %s=%d, %s=%d",
190 "Samples/pixel", td->td_samplesperpixel,
191 "colorchannels", colorchannels);
192 return 0;
193 }
194 break;
196 if ( td->td_samplesperpixel != 3 || colorchannels != 3 || td->td_bitspersample != 8 ) {
197 sprintf(emsg,
198 "Sorry, can not handle image with %s=%d, %s=%d and %s=%d",
199 "Samples/pixel", td->td_samplesperpixel,
200 "colorchannels", colorchannels,
201 "Bits/sample", td->td_bitspersample);
202 return 0;
203 }
204 break;
205 default:
206 sprintf(emsg, "Sorry, can not handle image with %s=%d",
207 photoTag, photometric);
208 return (0);
209 }
210 return (1);
211}
int tif_decodestatus
Definition: tiffiop.h:172

Referenced by TIFFReadRGBAImageOriented(), TIFFReadRGBAStripExt(), TIFFReadRGBATileExt(), and TIFFRGBAImageBegin().

◆ TIFFScanlineSize()

tmsize_t TIFFScanlineSize ( TIFF tif)

Definition at line 314 of file tif_strip.c.

315{
316 static const char module[] = "TIFFScanlineSize";
317 uint64 m;
319 return _TIFFCastUInt64ToSSize(tif, m, module);
320}
uint64 TIFFScanlineSize64(TIFF *tif)
Definition: tif_strip.c:257

Referenced by gtStripContig(), gtStripSeparate(), PredictorSetup(), TIFFReadDirectory(), and TIFFWriteCheck().

◆ TIFFScanlineSize64()

uint64 TIFFScanlineSize64 ( TIFF tif)

Definition at line 257 of file tif_strip.c.

258{
259 static const char module[] = "TIFFScanlineSize64";
260 TIFFDirectory *td = &tif->tif_dir;
261 uint64 scanline_size;
263 {
265 (td->td_samplesperpixel==3)&&
266 (!isUpSampled(tif)))
267 {
268 uint16 ycbcrsubsampling[2];
269 uint16 samplingblock_samples;
270 uint32 samplingblocks_hor;
271 uint64 samplingrow_samples;
272 uint64 samplingrow_size;
273 if(td->td_samplesperpixel!=3)
274 {
276 "Invalid td_samplesperpixel value");
277 return 0;
278 }
280 ycbcrsubsampling+0,
281 ycbcrsubsampling+1);
282 if (((ycbcrsubsampling[0]!=1)&&(ycbcrsubsampling[0]!=2)&&(ycbcrsubsampling[0]!=4)) ||
283 ((ycbcrsubsampling[1]!=1)&&(ycbcrsubsampling[1]!=2)&&(ycbcrsubsampling[1]!=4)))
284 {
286 "Invalid YCbCr subsampling");
287 return 0;
288 }
289 samplingblock_samples = ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
290 samplingblocks_hor = TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]);
291 samplingrow_samples = _TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
292 samplingrow_size = TIFFhowmany_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module),8);
293 scanline_size = (samplingrow_size/ycbcrsubsampling[1]);
294 }
295 else
296 {
297 uint64 scanline_samples;
298 scanline_samples=_TIFFMultiply64(tif,td->td_imagewidth,td->td_samplesperpixel,module);
299 scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,scanline_samples,td->td_bitspersample,module),8);
300 }
301 }
302 else
303 {
305 }
306 if (scanline_size == 0)
307 {
308 TIFFErrorExt(tif->tif_clientdata,module,"Computed scanline size is zero");
309 return 0;
310 }
311 return(scanline_size);
312}
#define TIFFTAG_YCBCRSUBSAMPLING
Definition: tiff.h:362
#define TIFFhowmany_64(x, y)
Definition: tiffiop.h:273

Referenced by _TIFFDefaultStripSize(), ByteCountLooksBad(), EstimateStripByteCounts(), TIFFScanlineSize(), and TIFFVStripSize64().

◆ TIFFSetClientdata()

thandle_t TIFFSetClientdata ( TIFF tif,
thandle_t  newvalue 
)

Definition at line 562 of file tif_open.c.

563{
565 tif->tif_clientdata = newvalue;
566 return m;
567}

◆ TIFFSetClientInfo()

void TIFFSetClientInfo ( TIFF tif,
void data,
const char name 
)

Definition at line 78 of file tif_extension.c.

80{
82
83 /*
84 ** Do we have an existing link with this name? If so, just
85 ** set it.
86 */
87 while( psLink != NULL && strcmp(psLink->name,name) != 0 )
88 psLink = psLink->next;
89
90 if( psLink != NULL )
91 {
92 psLink->data = data;
93 return;
94 }
95
96 /*
97 ** Create a new link.
98 */
99
101 assert (psLink != NULL);
102 psLink->next = tif->tif_clientinfo;
103 psLink->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1));
104 assert (psLink->name != NULL);
105 strcpy(psLink->name, name);
106 psLink->data = data;
107
108 tif->tif_clientinfo = psLink;
109}

◆ TIFFSetDirectory()

int TIFFSetDirectory ( TIFF tif,
uint16  dirn 
)

Definition at line 1617 of file tif_dir.c.

1618{
1619 uint64 nextdir;
1620 uint16 n;
1621
1622 if (!(tif->tif_flags&TIFF_BIGTIFF))
1623 nextdir = tif->tif_header.classic.tiff_diroff;
1624 else
1625 nextdir = tif->tif_header.big.tiff_diroff;
1626 for (n = dirn; n > 0 && nextdir != 0; n--)
1627 if (!TIFFAdvanceDirectory(tif, &nextdir, NULL))
1628 return (0);
1629 tif->tif_nextdiroff = nextdir;
1630 /*
1631 * Set curdir to the actual directory index. The
1632 * -1 is because TIFFReadDirectory will increment
1633 * tif_curdir after successfully reading the directory.
1634 */
1635 tif->tif_curdir = (dirn - n) - 1;
1636 /*
1637 * Reset tif_dirnumber counter and start new list of seen directories.
1638 * We need this to prevent IFD loops.
1639 */
1640 tif->tif_dirnumber = 0;
1641 return (TIFFReadDirectory(tif));
1642}

◆ TIFFSetErrorHandler()

void void void void TIFFErrorHandler TIFFSetErrorHandler ( TIFFErrorHandler  handler)

Definition at line 33 of file tif_error.c.

34{
37 return (prev);
38}
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7482
TIFFErrorHandler _TIFFerrorHandler
Definition: tif_unix.c:374
void(* TIFFErrorHandler)(const char *, const char *, va_list)
Definition: tiffio.h:271

◆ TIFFSetErrorHandlerExt()

TIFFErrorHandlerExt TIFFSetErrorHandlerExt ( TIFFErrorHandlerExt  handler)

Definition at line 41 of file tif_error.c.

42{
45 return (prev);
46}
TIFFErrorHandlerExt _TIFFerrorHandlerExt
Definition: tif_error.c:30
void(* TIFFErrorHandlerExt)(thandle_t, const char *, const char *, va_list)
Definition: tiffio.h:272

◆ TIFFSetField()

int TIFFSetField ( TIFF tif,
uint32  tag,
  ... 
)

Definition at line 807 of file tif_dir.c.

808{
809 va_list ap;
810 int status;
811
812 va_start(ap, tag);
813 status = TIFFVSetField(tif, tag, ap);
814 va_end(ap);
815 return (status);
816}
int TIFFVSetField(TIFF *tif, uint32 tag, va_list ap)
Definition: tif_dir.c:866

Referenced by allocChoppedUpStripArrays(), TIFFDefaultDirectory(), TIFFFetchNormalTag(), TIFFFetchSubjectDistance(), TIFFReadDirectory(), and TIFFRGBAImageBegin().

◆ TIFFSetFileName()

const char * TIFFSetFileName ( TIFF tif,
const char name 
)

Definition at line 522 of file tif_open.c.

523{
524 const char* old_name = tif->tif_name;
525 tif->tif_name = (char *)name;
526 return (old_name);
527}

◆ TIFFSetFileno()

int TIFFSetFileno ( TIFF tif,
int  fd 
)

Definition at line 542 of file tif_open.c.

543{
544 int old_fd = tif->tif_fd;
545 tif->tif_fd = fd;
546 return old_fd;
547}

◆ TIFFSetMode()

int TIFFSetMode ( TIFF tif,
int  mode 
)

Definition at line 582 of file tif_open.c.

583{
584 int old_mode = tif->tif_mode;
585 tif->tif_mode = mode;
586 return (old_mode);
587}

◆ TIFFSetSubDirectory()

int TIFFSetSubDirectory ( TIFF tif,
uint64  diroff 
)

Definition at line 1651 of file tif_dir.c.

1652{
1653 tif->tif_nextdiroff = diroff;
1654 /*
1655 * Reset tif_dirnumber counter and start new list of seen directories.
1656 * We need this to prevent IFD loops.
1657 */
1658 tif->tif_dirnumber = 0;
1659 return (TIFFReadDirectory(tif));
1660}

◆ TIFFSetTagExtender()

TIFFExtendProc TIFFSetTagExtender ( TIFFExtendProc  extender)

Definition at line 1312 of file tif_dir.c.

1313{
1315 _TIFFextender = extender;
1316 return (prev);
1317}
static TIFFExtendProc _TIFFextender
Definition: tif_dir.c:1309
void(* TIFFExtendProc)(TIFF *)
Definition: tiffio.h:279

◆ TIFFSetupStrips()

int TIFFSetupStrips ( TIFF tif)

Definition at line 523 of file tif_write.c.

524{
525 TIFFDirectory* td = &tif->tif_dir;
526
527 if (isTiled(tif))
531 else
538 td->td_stripoffset_p = (uint64 *)
540 "for \"StripOffsets\" array");
543 "for \"StripByteCounts\" array");
544 if (td->td_stripoffset_p == NULL || td->td_stripbytecount_p == NULL)
545 return (0);
546 /*
547 * Place data at the end-of-file
548 * (by setting offsets to zero).
549 */
554 return (1);
555}
#define isUnspecified(tif, f)
Definition: tif_write.c:519

Referenced by TIFFCheckpointDirectory(), TIFFForceStrileArrayWriting(), TIFFReadDirectory(), and TIFFWriteCheck().

◆ TIFFSetWarningHandler()

TIFFErrorHandler TIFFSetWarningHandler ( TIFFErrorHandler  handler)

Definition at line 33 of file tif_warning.c.

34{
37 return (prev);
38}
TIFFErrorHandler _TIFFwarningHandler
Definition: tif_unix.c:364

◆ TIFFSetWarningHandlerExt()

TIFFErrorHandlerExt TIFFSetWarningHandlerExt ( TIFFErrorHandlerExt  handler)

Definition at line 41 of file tif_warning.c.

42{
45 return (prev);
46}
TIFFErrorHandlerExt _TIFFwarningHandlerExt
Definition: tif_warning.c:30

◆ TIFFSetWriteOffset()

void TIFFSetWriteOffset ( TIFF tif,
toff_t  off 
)

Definition at line 834 of file tif_write.c.

835{
836 tif->tif_curoff = off;
837}

Referenced by TIFFCheckpointDirectory().

◆ TIFFStripSize()

tmsize_t TIFFStripSize ( TIFF tif)

Definition at line 202 of file tif_strip.c.

203{
204 static const char module[] = "TIFFStripSize";
205 uint64 m;
206 m=TIFFStripSize64(tif);
207 return _TIFFCastUInt64ToSSize(tif, m, module);
208}

Referenced by gtStripContig(), gtStripSeparate(), TIFFFillStrip(), TIFFReadDirectory(), and TIFFWriteBufferSetup().

◆ TIFFStripSize64()

uint64 TIFFStripSize64 ( TIFF tif)

Definition at line 193 of file tif_strip.c.

194{
195 TIFFDirectory* td = &tif->tif_dir;
196 uint32 rps = td->td_rowsperstrip;
197 if (rps > td->td_imagelength)
198 rps = td->td_imagelength;
199 return (TIFFVStripSize64(tif, rps));
200}
uint64 TIFFVStripSize64(TIFF *tif, uint32 nrows)
Definition: tif_strip.c:76

Referenced by _TIFFRewriteField(), TIFFReadDirectory(), TIFFStripSize(), TIFFWriteDirectoryTagLongLong8Array(), and TryChopUpUncompressedBigTiff().

◆ TIFFSwabArrayOfDouble()

void TIFFSwabArrayOfDouble ( double dp,
tmsize_t  n 
)

Definition at line 182 of file tif_swab.c.

183{
184 register unsigned char *cp;
185 register unsigned char t;
186 assert(sizeof(double)==8);
187 /* XXX unroll loop some */
188 while (n-- > 0) {
189 cp = (unsigned char *)dp;
190 t = cp[7]; cp[7] = cp[0]; cp[0] = t;
191 t = cp[6]; cp[6] = cp[1]; cp[1] = t;
192 t = cp[5]; cp[5] = cp[2]; cp[2] = t;
193 t = cp[4]; cp[4] = cp[3]; cp[3] = t;
194 dp++;
195 }
196}
GLdouble GLdouble t
Definition: gl.h:2047

Referenced by _TIFFSwab64BitData(), and TIFFWriteDirectoryTagCheckedDoubleArray().

◆ TIFFSwabArrayOfFloat()

void TIFFSwabArrayOfFloat ( float fp,
tmsize_t  n 
)

◆ TIFFSwabArrayOfLong()

void TIFFSwabArrayOfLong ( uint32 lp,
tmsize_t  n 
)

◆ TIFFSwabArrayOfLong8()

void TIFFSwabArrayOfLong8 ( uint64 lp,
tmsize_t  n 
)

◆ TIFFSwabArrayOfShort()

void TIFFSwabArrayOfShort ( uint16 wp,
tmsize_t  n 
)

◆ TIFFSwabArrayOfTriples()

void TIFFSwabArrayOfTriples ( uint8 tp,
tmsize_t  n 
)

◆ TIFFSwabDouble()

void TIFFSwabDouble ( double dp)

Definition at line 168 of file tif_swab.c.

169{
170 register unsigned char* cp = (unsigned char*) dp;
171 unsigned char t;
172 assert(sizeof(double)==8);
173 t = cp[7]; cp[7] = cp[0]; cp[0] = t;
174 t = cp[6]; cp[6] = cp[1]; cp[1] = t;
175 t = cp[5]; cp[5] = cp[2]; cp[2] = t;
176 t = cp[4]; cp[4] = cp[3]; cp[3] = t;
177}

◆ TIFFSwabFloat()

void TIFFSwabFloat ( float fp)

Definition at line 139 of file tif_swab.c.

140{
141 register unsigned char* cp = (unsigned char*) fp;
142 unsigned char t;
143 assert(sizeof(float)==4);
144 t = cp[3]; cp[3] = cp[0]; cp[0] = t;
145 t = cp[2]; cp[2] = cp[1]; cp[1] = t;
146}

◆ TIFFSwabLong()

◆ TIFFSwabLong8()

◆ TIFFSwabShort()

◆ TIFFTileRowSize()

tmsize_t TIFFTileRowSize ( TIFF tif)

Definition at line 180 of file tif_tile.c.

181{
182 static const char module[] = "TIFFTileRowSize";
183 uint64 m;
184 m=TIFFTileRowSize64(tif);
185 return _TIFFCastUInt64ToSSize(tif, m, module);
186}
uint64 TIFFTileRowSize64(TIFF *tif)
Definition: tif_tile.c:142

Referenced by gtTileContig(), gtTileSeparate(), and PredictorSetup().

◆ TIFFTileRowSize64()

uint64 TIFFTileRowSize64 ( TIFF tif)

Definition at line 142 of file tif_tile.c.

143{
144 static const char module[] = "TIFFTileRowSize64";
145 TIFFDirectory *td = &tif->tif_dir;
146 uint64 rowsize;
147 uint64 tilerowsize;
148
149 if (td->td_tilelength == 0)
150 {
151 TIFFErrorExt(tif->tif_clientdata,module,"Tile length is zero");
152 return 0;
153 }
154 if (td->td_tilewidth == 0)
155 {
156 TIFFErrorExt(tif->tif_clientdata,module,"Tile width is zero");
157 return (0);
158 }
159 rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth,
160 "TIFFTileRowSize");
162 {
163 if (td->td_samplesperpixel == 0)
164 {
165 TIFFErrorExt(tif->tif_clientdata,module,"Samples per pixel is zero");
166 return 0;
167 }
168 rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel,
169 "TIFFTileRowSize");
170 }
171 tilerowsize=TIFFhowmany8_64(rowsize);
172 if (tilerowsize == 0)
173 {
174 TIFFErrorExt(tif->tif_clientdata,module,"Computed tile row size is zero");
175 return 0;
176 }
177 return (tilerowsize);
178}

Referenced by TIFFTileRowSize(), and TIFFVTileSize64().

◆ TIFFTileSize()

tmsize_t TIFFTileSize ( TIFF tif)

Definition at line 257 of file tif_tile.c.

258{
259 static const char module[] = "TIFFTileSize";
260 uint64 m;
261 m=TIFFTileSize64(tif);
262 return _TIFFCastUInt64ToSSize(tif, m, module);
263}
uint64 TIFFTileSize64(TIFF *tif)
Definition: tif_tile.c:252

Referenced by gtTileContig(), gtTileSeparate(), TIFFFillTile(), TIFFReadDirectory(), and TIFFWriteCheck().

◆ TIFFTileSize64()

uint64 TIFFTileSize64 ( TIFF tif)

Definition at line 252 of file tif_tile.c.

253{
254 return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength));
255}
uint64 TIFFVTileSize64(TIFF *tif, uint32 nrows)
Definition: tif_tile.c:192

Referenced by _TIFFRewriteField(), EstimateStripByteCounts(), TIFFTileSize(), and TIFFWriteDirectoryTagLongLong8Array().

◆ TIFFUnlinkDirectory()

int TIFFUnlinkDirectory ( TIFF tif,
uint16  dirn 
)

Definition at line 1685 of file tif_dir.c.

1686{
1687 static const char module[] = "TIFFUnlinkDirectory";
1688 uint64 nextdir;
1689 uint64 off;
1690 uint16 n;
1691
1692 if (tif->tif_mode == O_RDONLY) {
1694 "Can not unlink directory in read-only file");
1695 return (0);
1696 }
1697 /*
1698 * Go to the directory before the one we want
1699 * to unlink and nab the offset of the link
1700 * field we'll need to patch.
1701 */
1702 if (!(tif->tif_flags&TIFF_BIGTIFF))
1703 {
1704 nextdir = tif->tif_header.classic.tiff_diroff;
1705 off = 4;
1706 }
1707 else
1708 {
1709 nextdir = tif->tif_header.big.tiff_diroff;
1710 off = 8;
1711 }
1712 for (n = dirn-1; n > 0; n--) {
1713 if (nextdir == 0) {
1714 TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn);
1715 return (0);
1716 }
1717 if (!TIFFAdvanceDirectory(tif, &nextdir, &off))
1718 return (0);
1719 }
1720 /*
1721 * Advance to the directory to be unlinked and fetch
1722 * the offset of the directory that follows.
1723 */
1724 if (!TIFFAdvanceDirectory(tif, &nextdir, NULL))
1725 return (0);
1726 /*
1727 * Go back and patch the link field of the preceding
1728 * directory to point to the offset of the directory
1729 * that follows.
1730 */
1731 (void) TIFFSeekFile(tif, off, SEEK_SET);
1732 if (!(tif->tif_flags&TIFF_BIGTIFF))
1733 {
1734 uint32 nextdir32;
1735 nextdir32=(uint32)nextdir;
1736 assert((uint64)nextdir32==nextdir);
1737 if (tif->tif_flags & TIFF_SWAB)
1738 TIFFSwabLong(&nextdir32);
1739 if (!WriteOK(tif, &nextdir32, sizeof (uint32))) {
1740 TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
1741 return (0);
1742 }
1743 }
1744 else
1745 {
1746 if (tif->tif_flags & TIFF_SWAB)
1747 TIFFSwabLong8(&nextdir);
1748 if (!WriteOK(tif, &nextdir, sizeof (uint64))) {
1749 TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
1750 return (0);
1751 }
1752 }
1753 /*
1754 * Leave directory state setup safely. We don't have
1755 * facilities for doing inserting and removing directories,
1756 * so it's safest to just invalidate everything. This
1757 * means that the caller can only append to the directory
1758 * chain.
1759 */
1760 (*tif->tif_cleanup)(tif);
1761 if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
1762 _TIFFfree(tif->tif_rawdata);
1763 tif->tif_rawdata = NULL;
1764 tif->tif_rawcc = 0;
1765 tif->tif_rawdataoff = 0;
1766 tif->tif_rawdataloaded = 0;
1767 }
1769 TIFFFreeDirectory(tif);
1771 tif->tif_diroff = 0; /* force link on next write */
1772 tif->tif_nextdiroff = 0; /* next write must be at end */
1773 tif->tif_curoff = 0;
1774 tif->tif_row = (uint32) -1;
1775 tif->tif_curstrip = (uint32) -1;
1776 return (1);
1777}
#define TIFF_BUF4WRITE
Definition: tiffiop.h:139

◆ TIFFUnRegisterCODEC()

void TIFFUnRegisterCODEC ( TIFFCodec c)

Definition at line 224 of file tif_compress.c.

225{
226 codec_t* cd;
227 codec_t** pcd;
228
229 for (pcd = &registeredCODECS; (cd = *pcd) != NULL; pcd = &cd->next)
230 if (cd->info == c) {
231 *pcd = cd->next;
232 _TIFFfree(cd);
233 return;
234 }
235 TIFFErrorExt(0, "TIFFUnRegisterCODEC",
236 "Cannot remove compression scheme %s; not registered", c->name);
237}

◆ TIFFUnsetField()

int TIFFUnsetField ( TIFF tif,
uint32  tag 
)

Definition at line 822 of file tif_dir.c.

823{
824 const TIFFField *fip = TIFFFieldWithTag(tif, tag);
825 TIFFDirectory* td = &tif->tif_dir;
826
827 if( !fip )
828 return 0;
829
830 if( fip->field_bit != FIELD_CUSTOM )
831 TIFFClrFieldBit(tif, fip->field_bit);
832 else
833 {
834 TIFFTagValue *tv = NULL;
835 int i;
836
837 for (i = 0; i < td->td_customValueCount; i++) {
838
839 tv = td->td_customValues + i;
840 if( tv->info->field_tag == tag )
841 break;
842 }
843
844 if( i < td->td_customValueCount )
845 {
846 _TIFFfree(tv->value);
847 for( ; i < td->td_customValueCount-1; i++) {
848 td->td_customValues[i] = td->td_customValues[i+1];
849 }
851 }
852 }
853
855
856 return (1);
857}

◆ TIFFVGetField()

int TIFFVGetField ( TIFF tif,
uint32  tag,
va_list  ap 
)

Definition at line 1250 of file tif_dir.c.

1251{
1252 const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
1253 return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ?
1254 (*tif->tif_tagmethods.vgetfield)(tif, tag, ap) : 0);
1255}
TIFFVGetMethod vgetfield
Definition: tiffio.h:334
#define isPseudoTag(t)
Definition: tiffiop.h:227

Referenced by TIFFGetField(), and TIFFVGetFieldDefaulted().

◆ TIFFVGetFieldDefaulted()

int TIFFVGetFieldDefaulted ( TIFF tif,
uint32  tag,
va_list  ap 
)

Definition at line 209 of file tif_aux.c.

210{
211 TIFFDirectory *td = &tif->tif_dir;
212
213 if (TIFFVGetField(tif, tag, ap))
214 return (1);
215 switch (tag) {
217 *va_arg(ap, uint32 *) = td->td_subfiletype;
218 return (1);
220 *va_arg(ap, uint16 *) = td->td_bitspersample;
221 return (1);
223 *va_arg(ap, uint16 *) = td->td_threshholding;
224 return (1);
226 *va_arg(ap, uint16 *) = td->td_fillorder;
227 return (1);
229 *va_arg(ap, uint16 *) = td->td_orientation;
230 return (1);
233 return (1);
235 *va_arg(ap, uint32 *) = td->td_rowsperstrip;
236 return (1);
239 return (1);
242 return (1);
244 *va_arg(ap, uint16 *) = td->td_planarconfig;
245 return (1);
248 return (1);
250 {
252 if( sp == NULL )
253 {
255 "Cannot get \"Predictor\" tag as plugin is not configured");
256 *va_arg(ap, uint16*) = 0;
257 return 0;
258 }
259 *va_arg(ap, uint16*) = (uint16) sp->predictor;
260 return 1;
261 }
262 case TIFFTAG_DOTRANGE:
263 *va_arg(ap, uint16 *) = 0;
264 *va_arg(ap, uint16 *) = (1<<td->td_bitspersample)-1;
265 return (1);
266 case TIFFTAG_INKSET:
268 return 1;
270 *va_arg(ap, uint16 *) = 4;
271 return (1);
273 *va_arg(ap, uint16 *) = td->td_extrasamples;
274 *va_arg(ap, uint16 **) = td->td_sampleinfo;
275 return (1);
276 case TIFFTAG_MATTEING:
277 *va_arg(ap, uint16 *) =
278 (td->td_extrasamples == 1 &&
280 return (1);
282 *va_arg(ap, uint32 *) = td->td_tiledepth;
283 return (1);
284 case TIFFTAG_DATATYPE:
285 *va_arg(ap, uint16 *) = td->td_sampleformat-1;
286 return (1);
288 *va_arg(ap, uint16 *) = td->td_sampleformat;
289 return(1);
291 *va_arg(ap, uint32 *) = td->td_imagedepth;
292 return (1);
294 {
295 /* defaults are from CCIR Recommendation 601-1 */
296 static float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f };
297 *va_arg(ap, float **) = ycbcrcoeffs;
298 return 1;
299 }
301 *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0];
302 *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1];
303 return (1);
306 return (1);
308 {
309 static float whitepoint[2];
310
311 /* TIFF 6.0 specification tells that it is no default
312 value for the WhitePoint, but AdobePhotoshop TIFF
313 Technical Note tells that it should be CIE D50. */
314 whitepoint[0] = D50_X0 / (D50_X0 + D50_Y0 + D50_Z0);
315 whitepoint[1] = D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0);
316 *va_arg(ap, float **) = whitepoint;
317 return 1;
318 }
320 if (!td->td_transferfunction[0] &&
322 TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag");
323 return (0);
324 }
325 *va_arg(ap, uint16 **) = td->td_transferfunction[0];
326 if (td->td_samplesperpixel - td->td_extrasamples > 1) {
327 *va_arg(ap, uint16 **) = td->td_transferfunction[1];
328 *va_arg(ap, uint16 **) = td->td_transferfunction[2];
329 }
330 return (1);
333 return (0);
334 *va_arg(ap, float **) = td->td_refblackwhite;
335 return (1);
336 }
337 return 0;
338}
#define va_arg(ap, T)
Definition: acmsvcex.h:89
static const WCHAR sp[]
Definition: suminfo.c:287
uint8 * tif_data
Definition: tiffiop.h:191
static int TIFFDefaultTransferFunction(TIFFDirectory *td)
Definition: tif_aux.c:127
static int TIFFDefaultRefBlackWhite(TIFFDirectory *td)
Definition: tif_aux.c:171
#define TIFFTAG_RESOLUTIONUNIT
Definition: tiff.h:261
#define TIFFTAG_WHITEPOINT
Definition: tiff.h:281
#define TIFFTAG_FILLORDER
Definition: tiff.h:214
#define TIFFTAG_YCBCRCOEFFICIENTS
Definition: tiff.h:361
#define TIFFTAG_MATTEING
Definition: tiff.h:376
#define TIFFTAG_NUMBEROFINKS
Definition: tiff.h:300
#define TIFFTAG_REFERENCEBLACKWHITE
Definition: tiff.h:366
#define TIFFTAG_PREDICTOR
Definition: tiff.h:277
#define TIFFTAG_YCBCRPOSITIONING
Definition: tiff.h:363
#define TIFFTAG_THRESHHOLDING
Definition: tiff.h:208
#define D50_X0
Definition: tiffio.h:130
#define D50_Y0
Definition: tiffio.h:131
#define D50_Z0
Definition: tiffio.h:132

Referenced by TIFFGetFieldDefaulted().

◆ TIFFVSetField()

int TIFFVSetField ( TIFF tif,
uint32  tag,
va_list  ap 
)

Definition at line 866 of file tif_dir.c.

867{
868 return OkToChangeTag(tif, tag) ?
869 (*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0;
870}
TIFFVSetMethod vsetfield
Definition: tiffio.h:333
static int OkToChangeTag(TIFF *tif, uint32 tag)
Definition: tif_dir.c:775

Referenced by TIFFSetField().

◆ TIFFVStripSize()

tmsize_t TIFFVStripSize ( TIFF tif,
uint32  nrows 
)

Definition at line 128 of file tif_strip.c.

129{
130 static const char module[] = "TIFFVStripSize";
131 uint64 m;
132 m=TIFFVStripSize64(tif,nrows);
133 return _TIFFCastUInt64ToSSize(tif, m, module);
134}

Referenced by TIFFReadEncodedStripGetStripSize().

◆ TIFFVStripSize64()

uint64 TIFFVStripSize64 ( TIFF tif,
uint32  nrows 
)

Definition at line 76 of file tif_strip.c.

77{
78 static const char module[] = "TIFFVStripSize64";
79 TIFFDirectory *td = &tif->tif_dir;
80 if (nrows==(uint32)(-1))
81 nrows=td->td_imagelength;
84 (!isUpSampled(tif)))
85 {
86 /*
87 * Packed YCbCr data contain one Cb+Cr for every
88 * HorizontalSampling*VerticalSampling Y values.
89 * Must also roundup width and height when calculating
90 * since images that are not a multiple of the
91 * horizontal/vertical subsampling area include
92 * YCbCr data for the extended image.
93 */
94 uint16 ycbcrsubsampling[2];
95 uint16 samplingblock_samples;
96 uint32 samplingblocks_hor;
97 uint32 samplingblocks_ver;
98 uint64 samplingrow_samples;
99 uint64 samplingrow_size;
100 if(td->td_samplesperpixel!=3)
101 {
103 "Invalid td_samplesperpixel value");
104 return 0;
105 }
106 TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
107 ycbcrsubsampling+1);
108 if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
109 ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
110 {
112 "Invalid YCbCr subsampling (%dx%d)",
113 ycbcrsubsampling[0],
114 ycbcrsubsampling[1] );
115 return 0;
116 }
117 samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
118 samplingblocks_hor=TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]);
119 samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
120 samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
121 samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
122 return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
123 }
124 else
125 return(_TIFFMultiply64(tif,nrows,TIFFScanlineSize64(tif),module));
126}

Referenced by TIFFStripSize64(), TIFFVStripSize(), and TryChopUpUncompressedBigTiff().

◆ TIFFVTileSize()

tmsize_t TIFFVTileSize ( TIFF tif,
uint32  nrows 
)

Definition at line 240 of file tif_tile.c.

241{
242 static const char module[] = "TIFFVTileSize";
243 uint64 m;
244 m=TIFFVTileSize64(tif,nrows);
245 return _TIFFCastUInt64ToSSize(tif, m, module);
246}

◆ TIFFVTileSize64()

uint64 TIFFVTileSize64 ( TIFF tif,
uint32  nrows 
)

Definition at line 192 of file tif_tile.c.

193{
194 static const char module[] = "TIFFVTileSize64";
195 TIFFDirectory *td = &tif->tif_dir;
196 if (td->td_tilelength == 0 || td->td_tilewidth == 0 ||
197 td->td_tiledepth == 0)
198 return (0);
201 (td->td_samplesperpixel==3)&&
202 (!isUpSampled(tif)))
203 {
204 /*
205 * Packed YCbCr data contain one Cb+Cr for every
206 * HorizontalSampling*VerticalSampling Y values.
207 * Must also roundup width and height when calculating
208 * since images that are not a multiple of the
209 * horizontal/vertical subsampling area include
210 * YCbCr data for the extended image.
211 */
212 uint16 ycbcrsubsampling[2];
213 uint16 samplingblock_samples;
214 uint32 samplingblocks_hor;
215 uint32 samplingblocks_ver;
216 uint64 samplingrow_samples;
217 uint64 samplingrow_size;
218 TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
219 ycbcrsubsampling+1);
220 if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
221 ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
222 {
224 "Invalid YCbCr subsampling (%dx%d)",
225 ycbcrsubsampling[0],
226 ycbcrsubsampling[1] );
227 return 0;
228 }
229 samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
230 samplingblocks_hor=TIFFhowmany_32(td->td_tilewidth,ycbcrsubsampling[0]);
231 samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
232 samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
233 samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
234 return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
235 }
236 else
237 return(_TIFFMultiply64(tif,nrows,TIFFTileRowSize64(tif),module));
238}

Referenced by ChopUpSingleUncompressedStrip(), TIFFTileSize64(), and TIFFVTileSize().

◆ TIFFWarning()

void void void TIFFWarning ( const char ,
const char ,
  ... 
)

◆ TIFFWarningExt()

void void void void TIFFWarningExt ( thandle_t  ,
const char ,
const char ,
  ... 
)

◆ TIFFWriteBufferSetup()

int TIFFWriteBufferSetup ( TIFF tif,
void bp,
tmsize_t  size 
)

Definition at line 650 of file tif_write.c.

651{
652 static const char module[] = "TIFFWriteBufferSetup";
653
654 if (tif->tif_rawdata) {
655 if (tif->tif_flags & TIFF_MYBUFFER) {
657 tif->tif_flags &= ~TIFF_MYBUFFER;
658 }
659 tif->tif_rawdata = NULL;
660 }
661 if (size == (tmsize_t)(-1)) {
662 size = (isTiled(tif) ?
663 tif->tif_tilesize : TIFFStripSize(tif));
664 /*
665 * Make raw data buffer at least 8K
666 */
667 if (size < 8*1024)
668 size = 8*1024;
669 bp = NULL; /* NB: force malloc */
670 }
671 if (bp == NULL) {
672 bp = _TIFFmalloc(size);
673 if (bp == NULL) {
674 TIFFErrorExt(tif->tif_clientdata, module, "No space for output buffer");
675 return (0);
676 }
677 tif->tif_flags |= TIFF_MYBUFFER;
678 } else
679 tif->tif_flags &= ~TIFF_MYBUFFER;
680 tif->tif_rawdata = (uint8*) bp;
681 tif->tif_rawdatasize = size;
682 tif->tif_rawcc = 0;
683 tif->tif_rawcp = tif->tif_rawdata;
685 return (1);
686}

Referenced by _TIFFReserveLargeEnoughWriteBuffer().

◆ TIFFWriteCheck()

int TIFFWriteCheck ( TIFF tif,
int  tiles,
const char module 
)

Definition at line 565 of file tif_write.c.

566{
567 if (tif->tif_mode == O_RDONLY) {
568 TIFFErrorExt(tif->tif_clientdata, module, "File not open for writing");
569 return (0);
570 }
571 if (tiles ^ isTiled(tif)) {
572 TIFFErrorExt(tif->tif_clientdata, module, tiles ?
573 "Can not write tiles to a striped image" :
574 "Can not write scanlines to a tiled image");
575 return (0);
576 }
577
578 _TIFFFillStriles( tif );
579
580 /*
581 * On the first write verify all the required information
582 * has been setup and initialize any data structures that
583 * had to wait until directory information was set.
584 * Note that a lot of our work is assumed to remain valid
585 * because we disallow any of the important parameters
586 * from changing after we start writing (i.e. once
587 * TIFF_BEENWRITING is set, TIFFSetField will only allow
588 * the image's length to be changed).
589 */
592 "Must set \"ImageWidth\" before writing data");
593 return (0);
594 }
595 if (tif->tif_dir.td_samplesperpixel == 1) {
596 /*
597 * Planarconfiguration is irrelevant in case of single band
598 * images and need not be included. We will set it anyway,
599 * because this field is used in other parts of library even
600 * in the single band case.
601 */
604 } else {
605 if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) {
607 "Must set \"PlanarConfiguration\" before writing data");
608 return (0);
609 }
610 }
611 if (tif->tif_dir.td_stripoffset_p == NULL && !TIFFSetupStrips(tif)) {
612 tif->tif_dir.td_nstrips = 0;
613 TIFFErrorExt(tif->tif_clientdata, module, "No space for %s arrays",
614 isTiled(tif) ? "tile" : "strip");
615 return (0);
616 }
617 if (isTiled(tif))
618 {
619 tif->tif_tilesize = TIFFTileSize(tif);
620 if (tif->tif_tilesize == 0)
621 return (0);
622 }
623 else
624 tif->tif_tilesize = (tmsize_t)(-1);
626 if (tif->tif_scanlinesize == 0)
627 return (0);
629
630 if( tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 &&
638 !(tif->tif_flags & TIFF_DIRTYDIRECT) )
639 {
641 }
642
643 return (1);
644}

◆ TIFFWriteCustomDirectory()

int TIFFWriteCustomDirectory ( TIFF tif,
uint64 pdiroff 
)

Definition at line 249 of file tif_dirwrite.c.

250{
251 return TIFFWriteDirectorySec(tif,FALSE,FALSE,pdiroff);
252}

◆ TIFFWriteDirectory()

int TIFFWriteDirectory ( TIFF tif)

Definition at line 180 of file tif_dirwrite.c.

181{
183}

Referenced by TIFFRewriteDirectory().

◆ TIFFWriteEncodedStrip()

tmsize_t TIFFWriteEncodedStrip ( TIFF tif,
uint32  strip,
void data,
tmsize_t  cc 
)

Definition at line 212 of file tif_write.c.

213{
214 static const char module[] = "TIFFWriteEncodedStrip";
215 TIFFDirectory *td = &tif->tif_dir;
216 uint16 sample;
217
218 if (!WRITECHECKSTRIPS(tif, module))
219 return ((tmsize_t) -1);
220 /*
221 * Check strip array to make sure there's space.
222 * We don't support dynamically growing files that
223 * have data organized in separate bitplanes because
224 * it's too painful. In that case we require that
225 * the imagelength be set properly before the first
226 * write (so that the strips array will be fully
227 * allocated above).
228 */
229 if (strip >= td->td_nstrips) {
232 "Can not grow image by strips when using separate planes");
233 return ((tmsize_t) -1);
234 }
235 if (!TIFFGrowStrips(tif, 1, module))
236 return ((tmsize_t) -1);
239 }
240 /*
241 * Handle delayed allocation of data buffer. This
242 * permits it to be sized according to the directory
243 * info.
244 */
245 if (!BUFFERCHECK(tif))
246 return ((tmsize_t) -1);
247
249 tif->tif_curstrip = strip;
250
251 if( !_TIFFReserveLargeEnoughWriteBuffer(tif, strip) ) {
252 return ((tmsize_t)(-1));
253 }
254
255 tif->tif_rawcc = 0;
256 tif->tif_rawcp = tif->tif_rawdata;
257
258 if (td->td_stripsperimage == 0) {
259 TIFFErrorExt(tif->tif_clientdata, module, "Zero strips per image");
260 return ((tmsize_t) -1);
261 }
262
263 tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
264 if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
265 if (!(*tif->tif_setupencode)(tif))
266 return ((tmsize_t) -1);
268 }
269
270 tif->tif_flags &= ~TIFF_POSTENCODE;
271
272 /* shortcut to avoid an extra memcpy() */
274 {
275 /* swab if needed - note that source buffer will be altered */
276 tif->tif_postdecode( tif, (uint8*) data, cc );
277
278 if (!isFillOrder(tif, td->td_fillorder) &&
279 (tif->tif_flags & TIFF_NOBITREV) == 0)
281
282 if (cc > 0 &&
283 !TIFFAppendToStrip(tif, strip, (uint8*) data, cc))
284 return ((tmsize_t) -1);
285 return (cc);
286 }
287
288 sample = (uint16)(strip / td->td_stripsperimage);
289 if (!(*tif->tif_preencode)(tif, sample))
290 return ((tmsize_t) -1);
291
292 /* swab if needed - note that source buffer will be altered */
293 tif->tif_postdecode( tif, (uint8*) data, cc );
294
295 if (!(*tif->tif_encodestrip)(tif, (uint8*) data, cc, sample))
296 return ((tmsize_t) -1);
297 if (!(*tif->tif_postencode)(tif))
298 return ((tmsize_t) -1);
299 if (!isFillOrder(tif, td->td_fillorder) &&
300 (tif->tif_flags & TIFF_NOBITREV) == 0)
302 if (tif->tif_rawcc > 0 &&
303 !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc))
304 return ((tmsize_t) -1);
305 tif->tif_rawcc = 0;
306 tif->tif_rawcp = tif->tif_rawdata;
307 return (cc);
308}
uint32_t cc
Definition: isohybrid.c:75
TIFFCodeMethod tif_encodestrip
Definition: tiffiop.h:183
TIFFPreMethod tif_preencode
Definition: tiffiop.h:178
TIFFBoolMethod tif_setupencode
Definition: tiffiop.h:176
static int TIFFAppendToStrip(TIFF *tif, uint32 strip, uint8 *data, tmsize_t cc)
Definition: tif_write.c:728
#define BUFFERCHECK(tif)
Definition: tif_write.c:39
static int TIFFGrowStrips(TIFF *tif, uint32 delta, const char *module)
Definition: tif_write.c:692
#define WRITECHECKSTRIPS(tif, module)
Definition: tif_write.c:35
static int _TIFFReserveLargeEnoughWriteBuffer(TIFF *tif, uint32 strip_or_tile)
Definition: tif_write.c:183
#define TIFF_CODERSETUP
Definition: tiffiop.h:124

◆ TIFFWriteEncodedTile()

tmsize_t TIFFWriteEncodedTile ( TIFF tif,
uint32  tile,
void data,
tmsize_t  cc 
)

Definition at line 391 of file tif_write.c.

392{
393 static const char module[] = "TIFFWriteEncodedTile";
394 TIFFDirectory *td;
395 uint16 sample;
396 uint32 howmany32;
397
398 if (!WRITECHECKTILES(tif, module))
399 return ((tmsize_t)(-1));
400 td = &tif->tif_dir;
401 if (tile >= td->td_nstrips) {
402 TIFFErrorExt(tif->tif_clientdata, module, "Tile %lu out of range, max %lu",
403 (unsigned long) tile, (unsigned long) td->td_nstrips);
404 return ((tmsize_t)(-1));
405 }
406 /*
407 * Handle delayed allocation of data buffer. This
408 * permits it to be sized more intelligently (using
409 * directory information).
410 */
411 if (!BUFFERCHECK(tif))
412 return ((tmsize_t)(-1));
413
415 tif->tif_curtile = tile;
416
417 if( !_TIFFReserveLargeEnoughWriteBuffer(tif, tile) ) {
418 return ((tmsize_t)(-1));
419 }
420
421 tif->tif_rawcc = 0;
422 tif->tif_rawcp = tif->tif_rawdata;
423
424 /*
425 * Compute tiles per row & per column to compute
426 * current row and column
427 */
428 howmany32=TIFFhowmany_32(td->td_imagelength, td->td_tilelength);
429 if (howmany32 == 0) {
430 TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles");
431 return ((tmsize_t)(-1));
432 }
433 tif->tif_row = (tile % howmany32) * td->td_tilelength;
434 howmany32=TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth);
435 if (howmany32 == 0) {
436 TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles");
437 return ((tmsize_t)(-1));
438 }
439 tif->tif_col = (tile % howmany32) * td->td_tilewidth;
440
441 if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
442 if (!(*tif->tif_setupencode)(tif))
443 return ((tmsize_t)(-1));
445 }
446 tif->tif_flags &= ~TIFF_POSTENCODE;
447
448 /*
449 * Clamp write amount to the tile size. This is mostly
450 * done so that callers can pass in some large number
451 * (e.g. -1) and have the tile size used instead.
452 */
453 if ( cc < 1 || cc > tif->tif_tilesize)
454 cc = tif->tif_tilesize;
455
456 /* shortcut to avoid an extra memcpy() */
458 {
459 /* swab if needed - note that source buffer will be altered */
460 tif->tif_postdecode( tif, (uint8*) data, cc );
461
462 if (!isFillOrder(tif, td->td_fillorder) &&
463 (tif->tif_flags & TIFF_NOBITREV) == 0)
465
466 if (cc > 0 &&
467 !TIFFAppendToStrip(tif, tile, (uint8*) data, cc))
468 return ((tmsize_t) -1);
469 return (cc);
470 }
471
472 sample = (uint16)(tile/td->td_stripsperimage);
473 if (!(*tif->tif_preencode)(tif, sample))
474 return ((tmsize_t)(-1));
475 /* swab if needed - note that source buffer will be altered */
476 tif->tif_postdecode( tif, (uint8*) data, cc );
477
478 if (!(*tif->tif_encodetile)(tif, (uint8*) data, cc, sample))
479 return ((tmsize_t) -1);
480 if (!(*tif->tif_postencode)(tif))
481 return ((tmsize_t)(-1));
482 if (!isFillOrder(tif, td->td_fillorder) &&
483 (tif->tif_flags & TIFF_NOBITREV) == 0)
485 if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile,
486 tif->tif_rawdata, tif->tif_rawcc))
487 return ((tmsize_t)(-1));
488 tif->tif_rawcc = 0;
489 tif->tif_rawcp = tif->tif_rawdata;
490 return (cc);
491}
TIFFCodeMethod tif_encodetile
Definition: tiffiop.h:185
#define WRITECHECKTILES(tif, module)
Definition: tif_write.c:37

Referenced by TIFFWriteTile().

◆ TIFFWriteRawStrip()

tmsize_t TIFFWriteRawStrip ( TIFF tif,
uint32  strip,
void data,
tmsize_t  cc 
)

Definition at line 316 of file tif_write.c.

317{
318 static const char module[] = "TIFFWriteRawStrip";
319 TIFFDirectory *td = &tif->tif_dir;
320
321 if (!WRITECHECKSTRIPS(tif, module))
322 return ((tmsize_t) -1);
323 /*
324 * Check strip array to make sure there's space.
325 * We don't support dynamically growing files that
326 * have data organized in separate bitplanes because
327 * it's too painful. In that case we require that
328 * the imagelength be set properly before the first
329 * write (so that the strips array will be fully
330 * allocated above).
331 */
332 if (strip >= td->td_nstrips) {
335 "Can not grow image by strips when using separate planes");
336 return ((tmsize_t) -1);
337 }
338 /*
339 * Watch out for a growing image. The value of
340 * strips/image will initially be 1 (since it
341 * can't be deduced until the imagelength is known).
342 */
343 if (strip >= td->td_stripsperimage)
346 if (!TIFFGrowStrips(tif, 1, module))
347 return ((tmsize_t) -1);
348 }
349 tif->tif_curstrip = strip;
350 if (td->td_stripsperimage == 0) {
351 TIFFErrorExt(tif->tif_clientdata, module,"Zero strips per image");
352 return ((tmsize_t) -1);
353 }
354 tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
355 return (TIFFAppendToStrip(tif, strip, (uint8*) data, cc) ?
356 cc : (tmsize_t) -1);
357}
return
Definition: dirsup.c:529

◆ TIFFWriteRawTile()

tmsize_t TIFFWriteRawTile ( TIFF tif,
uint32  tile,
void data,
tmsize_t  cc 
)

Definition at line 503 of file tif_write.c.

504{
505 static const char module[] = "TIFFWriteRawTile";
506
507 if (!WRITECHECKTILES(tif, module))
508 return ((tmsize_t)(-1));
509 if (tile >= tif->tif_dir.td_nstrips) {
510 TIFFErrorExt(tif->tif_clientdata, module, "Tile %lu out of range, max %lu",
511 (unsigned long) tile,
512 (unsigned long) tif->tif_dir.td_nstrips);
513 return ((tmsize_t)(-1));
514 }
515 return (TIFFAppendToStrip(tif, tile, (uint8*) data, cc) ?
516 cc : (tmsize_t)(-1));
517}

◆ TIFFWriteScanline()

int TIFFWriteScanline ( TIFF tif,
void buf,
uint32  row,
uint16  sample 
)

Definition at line 47 of file tif_write.c.

48{
49 static const char module[] = "TIFFWriteScanline";
50 register TIFFDirectory *td;
51 int status, imagegrew = 0;
52 uint32 strip;
53
54 if (!WRITECHECKSTRIPS(tif, module))
55 return (-1);
56 /*
57 * Handle delayed allocation of data buffer. This
58 * permits it to be sized more intelligently (using
59 * directory information).
60 */
61 if (!BUFFERCHECK(tif))
62 return (-1);
63 tif->tif_flags |= TIFF_BUF4WRITE; /* not strictly sure this is right*/
64
65 td = &tif->tif_dir;
66 /*
67 * Extend image length if needed
68 * (but only for PlanarConfig=1).
69 */
70 if (row >= td->td_imagelength) { /* extend image */
73 "Can not change \"ImageLength\" when using separate planes");
74 return (-1);
75 }
76 td->td_imagelength = row+1;
77 imagegrew = 1;
78 }
79 /*
80 * Calculate strip and check for crossings.
81 */
83 if (sample >= td->td_samplesperpixel) {
85 "%lu: Sample out of range, max %lu",
86 (unsigned long) sample, (unsigned long) td->td_samplesperpixel);
87 return (-1);
88 }
89 strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip;
90 } else
91 strip = row / td->td_rowsperstrip;
92 /*
93 * Check strip array to make sure there's space. We don't support
94 * dynamically growing files that have data organized in separate
95 * bitplanes because it's too painful. In that case we require that
96 * the imagelength be set properly before the first write (so that the
97 * strips array will be fully allocated above).
98 */
99 if (strip >= td->td_nstrips && !TIFFGrowStrips(tif, 1, module))
100 return (-1);
101 if (strip != tif->tif_curstrip) {
102 /*
103 * Changing strips -- flush any data present.
104 */
105 if (!TIFFFlushData(tif))
106 return (-1);
107 tif->tif_curstrip = strip;
108 /*
109 * Watch out for a growing image. The value of strips/image
110 * will initially be 1 (since it can't be deduced until the
111 * imagelength is known).
112 */
113 if (strip >= td->td_stripsperimage && imagegrew)
116 if (td->td_stripsperimage == 0) {
117 TIFFErrorExt(tif->tif_clientdata, module, "Zero strips per image");
118 return (-1);
119 }
120 tif->tif_row =
121 (strip % td->td_stripsperimage) * td->td_rowsperstrip;
122 if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
123 if (!(*tif->tif_setupencode)(tif))
124 return (-1);
126 }
127
128 tif->tif_rawcc = 0;
129 tif->tif_rawcp = tif->tif_rawdata;
130
131 if( td->td_stripbytecount_p[strip] > 0 )
132 {
133 /* if we are writing over existing tiles, zero length */
134 td->td_stripbytecount_p[strip] = 0;
135
136 /* this forces TIFFAppendToStrip() to do a seek */
137 tif->tif_curoff = 0;
138 }
139
140 if (!(*tif->tif_preencode)(tif, sample))
141 return (-1);
143 }
144 /*
145 * Ensure the write is either sequential or at the
146 * beginning of a strip (or that we can randomly
147 * access the data -- i.e. no encoding).
148 */
149 if (row != tif->tif_row) {
150 if (row < tif->tif_row) {
151 /*
152 * Moving backwards within the same strip:
153 * backup to the start and then decode
154 * forward (below).
155 */
156 tif->tif_row = (strip % td->td_stripsperimage) *
157 td->td_rowsperstrip;
158 tif->tif_rawcp = tif->tif_rawdata;
159 }
160 /*
161 * Seek forward to the desired row.
162 */
163 if (!(*tif->tif_seek)(tif, row - tif->tif_row))
164 return (-1);
165 tif->tif_row = row;
166 }
167
168 /* swab if needed - note that source buffer will be altered */
169 tif->tif_postdecode( tif, (uint8*) buf, tif->tif_scanlinesize );
170
171 status = (*tif->tif_encoderow)(tif, (uint8*) buf,
172 tif->tif_scanlinesize, sample);
173
174 /* we are now poised at the beginning of the next row */
175 tif->tif_row = row + 1;
176 return (status);
177}
TIFFSeekMethod tif_seek
Definition: tiffiop.h:187
TIFFCodeMethod tif_encoderow
Definition: tiffiop.h:181

◆ TIFFWriteTile()

tmsize_t TIFFWriteTile ( TIFF tif,
void buf,
uint32  x,
uint32  y,
uint32  z,
uint16  s 
)

Definition at line 364 of file tif_write.c.

365{
366 if (!TIFFCheckTile(tif, x, y, z, s))
367 return ((tmsize_t)(-1));
368 /*
369 * NB: A tile size of -1 is used instead of tif_tilesize knowing
370 * that TIFFWriteEncodedTile will clamp this to the tile size.
371 * This is done because the tile size may not be defined until
372 * after the output buffer is setup in TIFFWriteBufferSetup.
373 */
374 return (TIFFWriteEncodedTile(tif,
375 TIFFComputeTile(tif, x, y, z, s), buf, (tmsize_t)(-1)));
376}
tmsize_t TIFFWriteEncodedTile(TIFF *tif, uint32 tile, void *data, tmsize_t cc)
Definition: tif_write.c:391

◆ TIFFXYZToRGB()

void TIFFXYZToRGB ( TIFFCIELabToRGB cielab,
float  X,
float  Y,
float  Z,
uint32 r,
uint32 g,
uint32 b 
)

Definition at line 76 of file tif_color.c.

78{
79 int i;
80 float Yr, Yg, Yb;
81 float *matrix = &cielab->display.d_mat[0][0];
82
83 /* Multiply through the matrix to get luminosity values. */
84 Yr = matrix[0] * X + matrix[1] * Y + matrix[2] * Z;
85 Yg = matrix[3] * X + matrix[4] * Y + matrix[5] * Z;
86 Yb = matrix[6] * X + matrix[7] * Y + matrix[8] * Z;
87
88 /* Clip input */
89 Yr = TIFFmax(Yr, cielab->display.d_Y0R);
90 Yg = TIFFmax(Yg, cielab->display.d_Y0G);
91 Yb = TIFFmax(Yb, cielab->display.d_Y0B);
92
93 /* Avoid overflow in case of wrong input values */
94 Yr = TIFFmin(Yr, cielab->display.d_YCR);
95 Yg = TIFFmin(Yg, cielab->display.d_YCG);
96 Yb = TIFFmin(Yb, cielab->display.d_YCB);
97
98 /* Turn luminosity to colour value. */
99 i = (int)((Yr - cielab->display.d_Y0R) / cielab->rstep);
100 i = TIFFmin(cielab->range, i);
101 *r = RINT(cielab->Yr2r[i]);
102
103 i = (int)((Yg - cielab->display.d_Y0G) / cielab->gstep);
104 i = TIFFmin(cielab->range, i);
105 *g = RINT(cielab->Yg2g[i]);
106
107 i = (int)((Yb - cielab->display.d_Y0B) / cielab->bstep);
108 i = TIFFmin(cielab->range, i);
109 *b = RINT(cielab->Yb2b[i]);
110
111 /* Clip output. */
112 *r = TIFFmin(*r, cielab->display.d_Vrwr);
113 *g = TIFFmin(*g, cielab->display.d_Vrwg);
114 *b = TIFFmin(*b, cielab->display.d_Vrwb);
115}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLenum matrix
Definition: glext.h:9407
GLboolean GLboolean g
Definition: glext.h:6204
#define Yb
Definition: i386-dis.c:436
float d_mat[3][3]
Definition: tiffio.h:139
float d_YCB
Definition: tiffio.h:142
float d_YCG
Definition: tiffio.h:141
float d_Y0G
Definition: tiffio.h:147
float d_Y0B
Definition: tiffio.h:148
#define RINT(R)
Definition: tif_color.c:71
#define TIFFmax(A, B)
Definition: tiffiop.h:280
#define TIFFmin(A, B)
Definition: tiffiop.h:281

Referenced by DECLAREContigPutFunc().

◆ TIFFYCbCrtoRGB()

void TIFFYCbCrtoRGB ( TIFFYCbCrToRGB ycbcr,
uint32  Y,
int32  Cb,
int32  Cr,
uint32 r,
uint32 g,
uint32 b 
)

Definition at line 181 of file tif_color.c.

183{
184 int32 i;
185
186 /* XXX: Only 8-bit YCbCr input supported for now */
187 Y = HICLAMP(Y, 255);
188 Cb = CLAMP(Cb, 0, 255);
189 Cr = CLAMP(Cr, 0, 255);
190
191 i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr];
192 *r = CLAMP(i, 0, 255);
193 i = ycbcr->Y_tab[Y]
194 + (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT);
195 *g = CLAMP(i, 0, 255);
196 i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb];
197 *b = CLAMP(i, 0, 255);
198}
int32 * Cr_g_tab
Definition: tiffio.h:158
int * Cr_r_tab
Definition: tiffio.h:156
int32 * Cb_g_tab
Definition: tiffio.h:159
int * Cb_b_tab
Definition: tiffio.h:157
int32 * Y_tab
Definition: tiffio.h:160
#define CLAMP(f, min, max)
Definition: tif_color.c:177
#define SHIFT
Definition: tif_color.c:173
#define HICLAMP(f, max)
Definition: tif_color.c:178

Referenced by DECLARESepPutFunc().

◆ TIFFYCbCrToRGBInit()

int TIFFYCbCrToRGBInit ( TIFFYCbCrToRGB ycbcr,
float luma,
float refBlackWhite 
)

Definition at line 234 of file tif_color.c.

235{
236 TIFFRGBValue* clamptab;
237 int i;
238
239#define LumaRed luma[0]
240#define LumaGreen luma[1]
241#define LumaBlue luma[2]
242
243 clamptab = (TIFFRGBValue*)(
244 (uint8*) ycbcr+TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long)));
245 _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */
246 ycbcr->clamptab = (clamptab += 256);
247 for (i = 0; i < 256; i++)
248 clamptab[i] = (TIFFRGBValue) i;
249 _TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */
250 ycbcr->Cr_r_tab = (int*) (clamptab + 3*256);
251 ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256;
252 ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256);
253 ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256;
254 ycbcr->Y_tab = ycbcr->Cb_g_tab + 256;
255
256 { float f1 = 2-2*LumaRed; int32 D1 = FIX(CLAMP(f1,0.0F,2.0F));
257 float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(CLAMP(f2,0.0F,2.0F));
258 float f3 = 2-2*LumaBlue; int32 D3 = FIX(CLAMP(f3,0.0F,2.0F));
259 float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(CLAMP(f4,0.0F,2.0F));
260 int x;
261
262#undef LumaBlue
263#undef LumaGreen
264#undef LumaRed
265
266 /*
267 * i is the actual input pixel value in the range 0..255
268 * Cb and Cr values are in the range -128..127 (actually
269 * they are in a range defined by the ReferenceBlackWhite
270 * tag) so there is some range shifting to do here when
271 * constructing tables indexed by the raw pixel data.
272 */
273 for (i = 0, x = -128; i < 256; i++, x++) {
274 int32 Cr = (int32)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F,
275 refBlackWhite[5] - 128.0F, 127),
276 -128.0F * 32, 128.0F * 32);
277 int32 Cb = (int32)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F,
278 refBlackWhite[3] - 128.0F, 127),
279 -128.0F * 32, 128.0F * 32);
280
281 ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT);
282 ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT);
283 ycbcr->Cr_g_tab[i] = D2*Cr;
284 ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF;
285 ycbcr->Y_tab[i] =
286 (int32)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255),
287 -128.0F * 32, 128.0F * 32);
288 }
289 }
290
291 return 0;
292}
#define f2(x, y, z)
Definition: sha1.c:31
#define f1(x, y, z)
Definition: sha1.c:30
#define f4(x, y, z)
Definition: sha1.c:33
#define f3(x, y, z)
Definition: sha1.c:32
TIFFRGBValue * clamptab
Definition: tiffio.h:155
static float CLAMPw(float v, float vmin, float vmax)
Definition: tif_color.c:202
#define LumaRed
#define LumaBlue
#define FIX(x)
Definition: tif_color.c:174
#define Code2V(c, RB, RW, CR)
Definition: tif_color.c:176
#define ONE_HALF
Definition: tif_color.c:175
#define LumaGreen
unsigned char TIFFRGBValue
Definition: tiffio.h:136
#define TIFFroundup_32(x, y)
Definition: tiffiop.h:272

Referenced by initYCbCrConversion().

◆ uv_decode()

int uv_decode ( double ,
double ,
int   
)

◆ uv_encode()

int uv_encode ( double  ,
double  ,
int   
)

◆ XYZtoRGB24()

void XYZtoRGB24 ( float ,
uint8  
)