LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Macros | Functions
tif_dirwrite.c File Reference

Serialise, link, and patch classic TIFF and BigTIFF directories. More...

#include "tiffiop.h"
#include <float.h>
#include <math.h>
Include dependency graph for tif_dirwrite.c:

Go to the source code of this file.

Macros

#define TIFFCvtNativeToIEEEFloat(tif, n, fp)
 Recognise already compatible float storage without conversion.
 
#define TIFFCvtNativeToIEEEDouble(tif, n, dp)
 Recognise already compatible double storage without conversion.
 
#define MAX_ITERATIONS   64
 Bound the rational approximation loop to 64 iterations.
 

Functions

static int TIFFWriteDirectorySec (TIFF *tif, int isimage, int imagedone, uint64_t *pdiroff)
 Serialise the current IFD using image/custom and completion modes.
 
static int TIFFWriteDirectoryTagSampleformatArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value)
 Account for or emit Sampleformat array tag data.
 
static int TIFFWriteDirectoryTagAscii (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, char *value)
 Account for or emit Ascii tag data.
 
static int TIFFWriteDirectoryTagUndefinedArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint8_t *value)
 Account for or emit Undefined array tag data.
 
static int TIFFWriteDirectoryTagByteArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint8_t *value)
 Account for or emit Byte array tag data.
 
static int TIFFWriteDirectoryTagSbyteArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int8_t *value)
 Account for or emit Sbyte array tag data.
 
static int TIFFWriteDirectoryTagShort (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint16_t value)
 Account for or emit Short tag data.
 
static int TIFFWriteDirectoryTagShortArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint16_t *value)
 Account for or emit Short array tag data.
 
static int TIFFWriteDirectoryTagShortPerSample (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint16_t value)
 Account for or emit Short per sample tag data.
 
static int TIFFWriteDirectoryTagSshortArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int16_t *value)
 Account for or emit Sshort array tag data.
 
static int TIFFWriteDirectoryTagLong (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t value)
 Account for or emit Long tag data.
 
static int TIFFWriteDirectoryTagLongArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint32_t *value)
 Account for or emit Long array tag data.
 
static int TIFFWriteDirectoryTagSlongArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int32_t *value)
 Account for or emit Slong array tag data.
 
static int TIFFWriteDirectoryTagLong8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint64_t *value)
 Account for or emit Long8 array tag data.
 
static int TIFFWriteDirectoryTagSlong8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int64_t *value)
 Account for or emit Slong8 array tag data.
 
static int TIFFWriteDirectoryTagRational (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, double value)
 Account for or emit Rational tag data.
 
static int TIFFWriteDirectoryTagRationalArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value)
 Account for or emit Rational array tag data.
 
static int TIFFWriteDirectoryTagSrationalArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value)
 Account for or emit Srational array tag data.
 
static int TIFFWriteDirectoryTagFloatArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value)
 Account for or emit Float array tag data.
 
static int TIFFWriteDirectoryTagDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value)
 Account for or emit Double array tag data.
 
static int TIFFWriteDirectoryTagIfdArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint32_t *value)
 Account for or emit Ifd array tag data.
 
static int TIFFWriteDirectoryTagShortLong (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t value)
 Account for or emit ShortLong tag data.
 
static int TIFFWriteDirectoryTagLongLong8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint64_t *value)
 Account for or emit LongLong8 array tag data.
 
static int TIFFWriteDirectoryTagIfdIfd8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint64_t *value)
 Account for or emit IfdIfd8 array tag data.
 
static int TIFFWriteDirectoryTagColormap (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir)
 Account for or emit Colormap tag data.
 
static int TIFFWriteDirectoryTagTransferfunction (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir)
 Account for or emit Transferfunction tag data.
 
static int TIFFWriteDirectoryTagSubifd (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir)
 Account for or emit Subifd tag data.
 
static int TIFFWriteDirectoryTagCheckedAscii (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, char *value)
 Account for or emit Ascii tag data.
 
static int TIFFWriteDirectoryTagCheckedUndefinedArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint8_t *value)
 Account for or emit Undefined array tag data.
 
static int TIFFWriteDirectoryTagCheckedByteArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint8_t *value)
 Account for or emit Byte array tag data.
 
static int TIFFWriteDirectoryTagCheckedSbyteArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int8_t *value)
 Account for or emit Sbyte array tag data.
 
static int TIFFWriteDirectoryTagCheckedShort (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint16_t value)
 Account for or emit Short tag data.
 
static int TIFFWriteDirectoryTagCheckedShortArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint16_t *value)
 Account for or emit Short array tag data.
 
static int TIFFWriteDirectoryTagCheckedSshortArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int16_t *value)
 Account for or emit Sshort array tag data.
 
static int TIFFWriteDirectoryTagCheckedLong (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t value)
 Account for or emit Long tag data.
 
static int TIFFWriteDirectoryTagCheckedLongArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint32_t *value)
 Account for or emit Long array tag data.
 
static int TIFFWriteDirectoryTagCheckedSlongArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int32_t *value)
 Account for or emit Slong array tag data.
 
static int TIFFWriteDirectoryTagCheckedLong8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint64_t *value)
 Account for or emit Long8 array tag data.
 
static int TIFFWriteDirectoryTagCheckedSlong8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int64_t *value)
 Account for or emit Slong8 array tag data.
 
static int TIFFWriteDirectoryTagCheckedRational (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, double value)
 Account for or emit Rational tag data.
 
static int TIFFWriteDirectoryTagCheckedRationalArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value)
 Account for or emit Rational array tag data.
 
static int TIFFWriteDirectoryTagCheckedSrationalArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value)
 Account for or emit Srational array tag data.
 
static int TIFFWriteDirectoryTagRationalDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value)
 Account for or emit RationalDouble array tag data.
 
static int TIFFWriteDirectoryTagSrationalDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value)
 Account for or emit SrationalDouble array tag data.
 
static int TIFFWriteDirectoryTagCheckedRationalDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value)
 Account for or emit RationalDouble array tag data.
 
static int TIFFWriteDirectoryTagCheckedSrationalDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value)
 Account for or emit SrationalDouble array tag data.
 
static void DoubleToRational (double value, uint32_t *num, uint32_t *denom)
 Convert a double into unsigned 32-bit rational components.
 
static void DoubleToSrational (double value, int32_t *num, int32_t *denom)
 Convert a non-NaN double into signed rational components.
 
static int TIFFWriteDirectoryTagCheckedFloatArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value)
 Account for or emit Float array tag data.
 
static int TIFFWriteDirectoryTagCheckedDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value)
 Account for or emit Double array tag data.
 
static int TIFFWriteDirectoryTagCheckedIfdArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint32_t *value)
 Account for or emit Ifd array tag data.
 
static int TIFFWriteDirectoryTagCheckedIfd8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint64_t *value)
 Account for or emit Ifd8 array tag data.
 
static int TIFFWriteDirectoryTagData (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint16_t datatype, uint32_t count, uint32_t datalength, void *data)
 Insert one sorted IFD entry and emit its raw payload.
 
static int TIFFLinkDirectory (TIFF *tif)
 Link a new IFD at an even end-of-file offset.
 
int TIFFWriteDirectory (TIFF *tif)
 Finish the current image directory and prepare a fresh one.
 
int TIFFDeferStrileArrayWriting (TIFF *tif)
 Reserve strile-array entries for deferred payload writing.
 
int TIFFCheckpointDirectory (TIFF *tif)
 Write the current image directory while retaining its values.
 
int TIFFWriteCustomDirectory (TIFF *tif, uint64_t *pdiroff)
 Write current custom values and return their IFD offset.
 
static int TIFFRewriteDirectorySec (TIFF *tif, int isimage, int imagedone, uint64_t *pdiroff)
 Detach and relocate an IFD using the requested writer mode.
 
int TIFFRewriteDirectory (TIFF *tif)
 Relocate the current image IFD and repair its main-chain link.
 
static int8_t TIFFClampDoubleToInt8 (double val)
 Clamp and convert a double to int8.
 
static int16_t TIFFClampDoubleToInt16 (double val)
 Clamp and convert a double to int16.
 
static int32_t TIFFClampDoubleToInt32 (double val)
 Clamp and convert a double to int32.
 
static uint8_t TIFFClampDoubleToUInt8 (double val)
 Clamp and convert a double to uint8.
 
static uint16_t TIFFClampDoubleToUInt16 (double val)
 Clamp and convert a double to uint16.
 
static uint32_t TIFFClampDoubleToUInt32 (double val)
 Clamp and convert a double to uint32.
 
static int _WriteAsType (TIFF *tif, uint64_t strile_size, uint64_t uncompressed_threshold)
 Choose whether a strile count needs a wider integer type.
 
static int WriteAsLong8 (TIFF *tif, uint64_t strile_size)
 Choose whether a strile count needs a wider integer type.
 
static int WriteAsLong4 (TIFF *tif, uint64_t strile_size)
 Choose whether a strile count needs a wider integer type.
 
static void EvaluateIFDdatasizeWrite (TIFF *tif, uint32_t count, uint32_t typesize, uint32_t *ndir)
 Accumulate external payload size and one IFD entry.
 
static void ToRationalEuclideanGCD (double value, int blnUseSignedRange, int blnUseSmallRange, uint64_t *ullNum, uint64_t *ullDenom)
 Approximate a nonnegative scalar by bounded rational components.
 
int _TIFFRewriteField (TIFF *tif, uint16_t tag, TIFFDataType in_datatype, tmsize_t count, void *data)
 Patch an existing field in the current on-file IFD.
 

Detailed Description

Serialise, link, and patch classic TIFF and BigTIFF directories.

Definition in file tif_dirwrite.c.