ReactOS  0.4.14-dev-342-gdc047f9
tif_dirwrite.c File Reference
#include <precomp.h>
#include <float.h>
Include dependency graph for tif_dirwrite.c:

Go to the source code of this file.

Functions

void TIFFCvtNativeToIEEEFloat (TIFF *tif, uint32 n, float *fp)
 
void TIFFCvtNativeToIEEEDouble (TIFF *tif, uint32 n, double *dp)
 
static int TIFFWriteDirectorySec (TIFF *tif, int isimage, int imagedone, uint64 *pdiroff)
 
static int TIFFWriteDirectoryTagSampleformatArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
 
static int TIFFWriteDirectoryTagAscii (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, char *value)
 
static int TIFFWriteDirectoryTagUndefinedArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
 
static int TIFFWriteDirectoryTagByteArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
 
static int TIFFWriteDirectoryTagSbyteArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int8 *value)
 
static int TIFFWriteDirectoryTagShort (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
 
static int TIFFWriteDirectoryTagShortArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
 
static int TIFFWriteDirectoryTagShortPerSample (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
 
static int TIFFWriteDirectoryTagSshortArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int16 *value)
 
static int TIFFWriteDirectoryTagLong (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
 
static int TIFFWriteDirectoryTagLongArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
 
static int TIFFWriteDirectoryTagSlongArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int32 *value)
 
static int TIFFWriteDirectoryTagLong8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
 
static int TIFFWriteDirectoryTagSlong8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int64 *value)
 
static int TIFFWriteDirectoryTagRational (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, double value)
 
static int TIFFWriteDirectoryTagRationalArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagSrationalArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagFloatArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagDoubleArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
 
static int TIFFWriteDirectoryTagIfdArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
 
static int TIFFWriteDirectoryTagShortLong (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
 
static int TIFFWriteDirectoryTagLongLong8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
 
static int TIFFWriteDirectoryTagIfdIfd8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
 
static int TIFFWriteDirectoryTagColormap (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
 
static int TIFFWriteDirectoryTagTransferfunction (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
 
static int TIFFWriteDirectoryTagSubifd (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
 
static int TIFFWriteDirectoryTagCheckedAscii (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, char *value)
 
static int TIFFWriteDirectoryTagCheckedUndefinedArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
 
static int TIFFWriteDirectoryTagCheckedByteArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
 
static int TIFFWriteDirectoryTagCheckedSbyteArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int8 *value)
 
static int TIFFWriteDirectoryTagCheckedShort (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
 
static int TIFFWriteDirectoryTagCheckedShortArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
 
static int TIFFWriteDirectoryTagCheckedSshortArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int16 *value)
 
static int TIFFWriteDirectoryTagCheckedLong (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
 
static int TIFFWriteDirectoryTagCheckedLongArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
 
static int TIFFWriteDirectoryTagCheckedSlongArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int32 *value)
 
static int TIFFWriteDirectoryTagCheckedLong8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
 
static int TIFFWriteDirectoryTagCheckedSlong8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int64 *value)
 
static int TIFFWriteDirectoryTagCheckedRational (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, double value)
 
static int TIFFWriteDirectoryTagCheckedRationalArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagCheckedSrationalArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagCheckedFloatArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
 
static int TIFFWriteDirectoryTagCheckedDoubleArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
 
static int TIFFWriteDirectoryTagCheckedIfdArray (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
 
static int TIFFWriteDirectoryTagCheckedIfd8Array (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
 
static int TIFFWriteDirectoryTagData (TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
 
static int TIFFLinkDirectory (TIFF *)
 
int TIFFWriteDirectory (TIFF *tif)
 
int TIFFCheckpointDirectory (TIFF *tif)
 
int TIFFWriteCustomDirectory (TIFF *tif, uint64 *pdiroff)
 
int TIFFRewriteDirectory (TIFF *tif)
 
static float TIFFClampDoubleToFloat (double val)
 
static int8 TIFFClampDoubleToInt8 (double val)
 
static int16 TIFFClampDoubleToInt16 (double val)
 
static int32 TIFFClampDoubleToInt32 (double val)
 
static uint8 TIFFClampDoubleToUInt8 (double val)
 
static uint16 TIFFClampDoubleToUInt16 (double val)
 
static uint32 TIFFClampDoubleToUInt32 (double val)
 
int _TIFFRewriteField (TIFF *tif, uint16 tag, TIFFDataType in_datatype, tmsize_t count, void *data)
 

Function Documentation

◆ _TIFFRewriteField()

int _TIFFRewriteField ( TIFF tif,
uint16  tag,
TIFFDataType  in_datatype,
tmsize_t  count,
void data 
)

Definition at line 2683 of file tif_dirwrite.c.

2685 {
2686  static const char module[] = "TIFFResetField";
2687  /* const TIFFField* fip = NULL; */
2688  uint16 dircount;
2689  tmsize_t dirsize;
2690  uint8 direntry_raw[20];
2691  uint16 entry_tag = 0;
2692  uint16 entry_type = 0;
2693  uint64 entry_count = 0;
2694  uint64 entry_offset = 0;
2695  int value_in_entry = 0;
2696  uint64 read_offset;
2697  uint8 *buf_to_write = NULL;
2698  TIFFDataType datatype;
2699 
2700 /* -------------------------------------------------------------------- */
2701 /* Find field definition. */
2702 /* -------------------------------------------------------------------- */
2703  /*fip =*/ TIFFFindField(tif, tag, TIFF_ANY);
2704 
2705 /* -------------------------------------------------------------------- */
2706 /* Do some checking this is a straight forward case. */
2707 /* -------------------------------------------------------------------- */
2708  if( isMapped(tif) )
2709  {
2711  "Memory mapped files not currently supported for this operation." );
2712  return 0;
2713  }
2714 
2715  if( tif->tif_diroff == 0 )
2716  {
2718  "Attempt to reset field on directory not already on disk." );
2719  return 0;
2720  }
2721 
2722 /* -------------------------------------------------------------------- */
2723 /* Read the directory entry count. */
2724 /* -------------------------------------------------------------------- */
2725  if (!SeekOK(tif, tif->tif_diroff)) {
2727  "%s: Seek error accessing TIFF directory",
2728  tif->tif_name);
2729  return 0;
2730  }
2731 
2732  read_offset = tif->tif_diroff;
2733 
2734  if (!(tif->tif_flags&TIFF_BIGTIFF))
2735  {
2736  if (!ReadOK(tif, &dircount, sizeof (uint16))) {
2738  "%s: Can not read TIFF directory count",
2739  tif->tif_name);
2740  return 0;
2741  }
2742  if (tif->tif_flags & TIFF_SWAB)
2743  TIFFSwabShort(&dircount);
2744  dirsize = 12;
2745  read_offset += 2;
2746  } else {
2747  uint64 dircount64;
2748  if (!ReadOK(tif, &dircount64, sizeof (uint64))) {
2750  "%s: Can not read TIFF directory count",
2751  tif->tif_name);
2752  return 0;
2753  }
2754  if (tif->tif_flags & TIFF_SWAB)
2755  TIFFSwabLong8(&dircount64);
2756  dircount = (uint16)dircount64;
2757  dirsize = 20;
2758  read_offset += 8;
2759  }
2760 
2761 /* -------------------------------------------------------------------- */
2762 /* Read through directory to find target tag. */
2763 /* -------------------------------------------------------------------- */
2764  while( dircount > 0 )
2765  {
2766  if (!ReadOK(tif, direntry_raw, dirsize)) {
2768  "%s: Can not read TIFF directory entry.",
2769  tif->tif_name);
2770  return 0;
2771  }
2772 
2773  memcpy( &entry_tag, direntry_raw + 0, sizeof(uint16) );
2774  if (tif->tif_flags&TIFF_SWAB)
2775  TIFFSwabShort( &entry_tag );
2776 
2777  if( entry_tag == tag )
2778  break;
2779 
2780  read_offset += dirsize;
2781  }
2782 
2783  if( entry_tag != tag )
2784  {
2786  "%s: Could not find tag %d.",
2787  tif->tif_name, tag );
2788  return 0;
2789  }
2790 
2791 /* -------------------------------------------------------------------- */
2792 /* Extract the type, count and offset for this entry. */
2793 /* -------------------------------------------------------------------- */
2794  memcpy( &entry_type, direntry_raw + 2, sizeof(uint16) );
2795  if (tif->tif_flags&TIFF_SWAB)
2796  TIFFSwabShort( &entry_type );
2797 
2798  if (!(tif->tif_flags&TIFF_BIGTIFF))
2799  {
2800  uint32 value;
2801 
2802  memcpy( &value, direntry_raw + 4, sizeof(uint32) );
2803  if (tif->tif_flags&TIFF_SWAB)
2804  TIFFSwabLong( &value );
2805  entry_count = value;
2806 
2807  memcpy( &value, direntry_raw + 8, sizeof(uint32) );
2808  if (tif->tif_flags&TIFF_SWAB)
2809  TIFFSwabLong( &value );
2810  entry_offset = value;
2811  }
2812  else
2813  {
2814  memcpy( &entry_count, direntry_raw + 4, sizeof(uint64) );
2815  if (tif->tif_flags&TIFF_SWAB)
2816  TIFFSwabLong8( &entry_count );
2817 
2818  memcpy( &entry_offset, direntry_raw + 12, sizeof(uint64) );
2819  if (tif->tif_flags&TIFF_SWAB)
2820  TIFFSwabLong8( &entry_offset );
2821  }
2822 
2823 /* -------------------------------------------------------------------- */
2824 /* What data type do we want to write this as? */
2825 /* -------------------------------------------------------------------- */
2826  if( TIFFDataWidth(in_datatype) == 8 && !(tif->tif_flags&TIFF_BIGTIFF) )
2827  {
2828  if( in_datatype == TIFF_LONG8 )
2829  datatype = TIFF_LONG;
2830  else if( in_datatype == TIFF_SLONG8 )
2831  datatype = TIFF_SLONG;
2832  else if( in_datatype == TIFF_IFD8 )
2833  datatype = TIFF_IFD;
2834  else
2835  datatype = in_datatype;
2836  }
2837  else
2838  datatype = in_datatype;
2839 
2840 /* -------------------------------------------------------------------- */
2841 /* Prepare buffer of actual data to write. This includes */
2842 /* swabbing as needed. */
2843 /* -------------------------------------------------------------------- */
2844  buf_to_write =
2845  (uint8 *)_TIFFCheckMalloc(tif, count, TIFFDataWidth(datatype),
2846  "for field buffer.");
2847  if (!buf_to_write)
2848  return 0;
2849 
2850  if( datatype == in_datatype )
2851  memcpy( buf_to_write, data, count * TIFFDataWidth(datatype) );
2852  else if( datatype == TIFF_SLONG && in_datatype == TIFF_SLONG8 )
2853  {
2854  tmsize_t i;
2855 
2856  for( i = 0; i < count; i++ )
2857  {
2858  ((int32 *) buf_to_write)[i] =
2859  (int32) ((int64 *) data)[i];
2860  if( (int64) ((int32 *) buf_to_write)[i] != ((int64 *) data)[i] )
2861  {
2862  _TIFFfree( buf_to_write );
2864  "Value exceeds 32bit range of output type." );
2865  return 0;
2866  }
2867  }
2868  }
2869  else if( (datatype == TIFF_LONG && in_datatype == TIFF_LONG8)
2870  || (datatype == TIFF_IFD && in_datatype == TIFF_IFD8) )
2871  {
2872  tmsize_t i;
2873 
2874  for( i = 0; i < count; i++ )
2875  {
2876  ((uint32 *) buf_to_write)[i] =
2877  (uint32) ((uint64 *) data)[i];
2878  if( (uint64) ((uint32 *) buf_to_write)[i] != ((uint64 *) data)[i] )
2879  {
2880  _TIFFfree( buf_to_write );
2882  "Value exceeds 32bit range of output type." );
2883  return 0;
2884  }
2885  }
2886  }
2887 
2888  if( TIFFDataWidth(datatype) > 1 && (tif->tif_flags&TIFF_SWAB) )
2889  {
2890  if( TIFFDataWidth(datatype) == 2 )
2891  TIFFSwabArrayOfShort( (uint16 *) buf_to_write, count );
2892  else if( TIFFDataWidth(datatype) == 4 )
2893  TIFFSwabArrayOfLong( (uint32 *) buf_to_write, count );
2894  else if( TIFFDataWidth(datatype) == 8 )
2895  TIFFSwabArrayOfLong8( (uint64 *) buf_to_write, count );
2896  }
2897 
2898 /* -------------------------------------------------------------------- */
2899 /* Is this a value that fits into the directory entry? */
2900 /* -------------------------------------------------------------------- */
2901  if (!(tif->tif_flags&TIFF_BIGTIFF))
2902  {
2903  if( TIFFDataWidth(datatype) * count <= 4 )
2904  {
2905  entry_offset = read_offset + 8;
2906  value_in_entry = 1;
2907  }
2908  }
2909  else
2910  {
2911  if( TIFFDataWidth(datatype) * count <= 8 )
2912  {
2913  entry_offset = read_offset + 12;
2914  value_in_entry = 1;
2915  }
2916  }
2917 
2918 /* -------------------------------------------------------------------- */
2919 /* If the tag type, and count match, then we just write it out */
2920 /* over the old values without altering the directory entry at */
2921 /* all. */
2922 /* -------------------------------------------------------------------- */
2923  if( entry_count == (uint64)count && entry_type == (uint16) datatype )
2924  {
2925  if (!SeekOK(tif, entry_offset)) {
2926  _TIFFfree( buf_to_write );
2928  "%s: Seek error accessing TIFF directory",
2929  tif->tif_name);
2930  return 0;
2931  }
2932  if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) {
2933  _TIFFfree( buf_to_write );
2935  "Error writing directory link");
2936  return (0);
2937  }
2938 
2939  _TIFFfree( buf_to_write );
2940  return 1;
2941  }
2942 
2943 /* -------------------------------------------------------------------- */
2944 /* Otherwise, we write the new tag data at the end of the file. */
2945 /* -------------------------------------------------------------------- */
2946  if( !value_in_entry )
2947  {
2948  entry_offset = TIFFSeekFile(tif,0,SEEK_END);
2949 
2950  if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) {
2951  _TIFFfree( buf_to_write );
2953  "Error writing directory link");
2954  return (0);
2955  }
2956  }
2957  else
2958  {
2959  memcpy( &entry_offset, buf_to_write, count*TIFFDataWidth(datatype));
2960  }
2961 
2962  _TIFFfree( buf_to_write );
2963  buf_to_write = 0;
2964 
2965 /* -------------------------------------------------------------------- */
2966 /* Adjust the directory entry. */
2967 /* -------------------------------------------------------------------- */
2968  entry_type = datatype;
2969  memcpy( direntry_raw + 2, &entry_type, sizeof(uint16) );
2970  if (tif->tif_flags&TIFF_SWAB)
2971  TIFFSwabShort( (uint16 *) (direntry_raw + 2) );
2972 
2973  if (!(tif->tif_flags&TIFF_BIGTIFF))
2974  {
2975  uint32 value;
2976 
2977  value = (uint32) entry_count;
2978  memcpy( direntry_raw + 4, &value, sizeof(uint32) );
2979  if (tif->tif_flags&TIFF_SWAB)
2980  TIFFSwabLong( (uint32 *) (direntry_raw + 4) );
2981 
2982  value = (uint32) entry_offset;
2983  memcpy( direntry_raw + 8, &value, sizeof(uint32) );
2984  if (tif->tif_flags&TIFF_SWAB)
2985  TIFFSwabLong( (uint32 *) (direntry_raw + 8) );
2986  }
2987  else
2988  {
2989  memcpy( direntry_raw + 4, &entry_count, sizeof(uint64) );
2990  if (tif->tif_flags&TIFF_SWAB)
2991  TIFFSwabLong8( (uint64 *) (direntry_raw + 4) );
2992 
2993  memcpy( direntry_raw + 12, &entry_offset, sizeof(uint64) );
2994  if (tif->tif_flags&TIFF_SWAB)
2995  TIFFSwabLong8( (uint64 *) (direntry_raw + 12) );
2996  }
2997 
2998 /* -------------------------------------------------------------------- */
2999 /* Write the directory entry out to disk. */
3000 /* -------------------------------------------------------------------- */
3001  if (!SeekOK(tif, read_offset )) {
3003  "%s: Seek error accessing TIFF directory",
3004  tif->tif_name);
3005  return 0;
3006  }
3007 
3008  if (!WriteOK(tif, direntry_raw,dirsize))
3009  {
3011  "%s: Can not write TIFF directory entry.",
3012  tif->tif_name);
3013  return 0;
3014  }
3015 
3016  return 1;
3017 }
unsigned long long uint64
Definition: platform.h:18
#define TIFF_ANY
Definition: tiffio.h:312
void TIFFSwabArrayOfShort(register uint16 *wp, tmsize_t n)
Definition: tif_swab.c:71
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:243
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:221
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
long long int64
Definition: platform.h:13
char * tif_name
Definition: tiffiop.h:103
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
#define TIFF_BIGTIFF
Definition: tiffiop.h:125
#define TIFF_SWAB
Definition: tiffiop.h:113
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
void * _TIFFCheckMalloc(TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Definition: tif_aux.c:85
uint32 tif_flags
Definition: tiffiop.h:106
smooth NULL
Definition: ftsmooth.c:416
#define isMapped(tif)
Definition: tiffiop.h:214
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
unsigned char uint8
Definition: types.h:28
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
uint64 tif_diroff
Definition: tiffiop.h:130
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLsizei const GLfloat * value
Definition: glext.h:6069
int TIFFDataWidth(TIFFDataType type)
Definition: tif_dirinfo.c:438
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
unsigned short uint16
Definition: types.h:30
void TIFFSwabArrayOfLong8(register uint64 *lp, tmsize_t n)
Definition: tif_swab.c:120
#define SeekOK(tif, off)
Definition: tiffiop.h:240
long int32
Definition: platform.h:12
#define ReadOK(tif, buf, size)
Definition: tiffiop.h:236
const TIFFField * TIFFFindField(TIFF *tif, uint32 tag, TIFFDataType dt)
Definition: tif_dirinfo.c:506
#define SEEK_END
Definition: cabinet.c:27
Definition: tiff.h:137
void _TIFFfree(void *p)
Definition: tif_unix.c:326
TIFFDataType
Definition: tiff.h:123
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57

Referenced by TIFFFlush().

◆ TIFFCheckpointDirectory()

int TIFFCheckpointDirectory ( TIFF tif)

Definition at line 192 of file tif_dirwrite.c.

193 {
194  int rc;
195  /* Setup the strips arrays, if they haven't already been. */
196  if (tif->tif_dir.td_stripoffset == NULL)
197  (void) TIFFSetupStrips(tif);
199  (void) TIFFSetWriteOffset(tif, TIFFSeekFile(tif, 0, SEEK_END));
200  return rc;
201 }
#define TRUE
Definition: types.h:120
static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, uint64 *pdiroff)
Definition: tif_dirwrite.c:362
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
int TIFFSetupStrips(TIFF *tif)
Definition: tif_write.c:526
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:221
smooth NULL
Definition: ftsmooth.c:416
uint64 * td_stripoffset
Definition: tif_dir.h:100
void TIFFSetWriteOffset(TIFF *tif, toff_t off)
Definition: tif_write.c:823
TIFFDirectory tif_dir
Definition: tiffiop.h:135
#define SEEK_END
Definition: cabinet.c:27

◆ TIFFClampDoubleToFloat()

static float TIFFClampDoubleToFloat ( double  val)
static

Definition at line 949 of file tif_dirwrite.c.

950 {
951  if( val > FLT_MAX )
952  return FLT_MAX;
953  if( val < -FLT_MAX )
954  return -FLT_MAX;
955  return (float)val;
956 }
#define FLT_MAX
Definition: gcc_float.h:107
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToInt16()

static int16 TIFFClampDoubleToInt16 ( double  val)
static

Definition at line 967 of file tif_dirwrite.c.

968 {
969  if( val > 32767 )
970  return 32767;
971  if( val < -32768 || val != val )
972  return -32768;
973  return (int16)val;
974 }
GLuint GLfloat * val
Definition: glext.h:7180
short int16
Definition: platform.h:11

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToInt32()

static int32 TIFFClampDoubleToInt32 ( double  val)
static

Definition at line 976 of file tif_dirwrite.c.

977 {
978  if( val > 0x7FFFFFFF )
979  return 0x7FFFFFFF;
980  if( val < -0x7FFFFFFF-1 || val != val )
981  return -0x7FFFFFFF-1;
982  return (int32)val;
983 }
GLuint GLfloat * val
Definition: glext.h:7180
long int32
Definition: platform.h:12

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToInt8()

static int8 TIFFClampDoubleToInt8 ( double  val)
static

Definition at line 958 of file tif_dirwrite.c.

959 {
960  if( val > 127 )
961  return 127;
962  if( val < -128 || val != val )
963  return -128;
964  return (int8)val;
965 }
GLuint GLfloat * val
Definition: glext.h:7180
char int8
Definition: platform.h:10

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToUInt16()

static uint16 TIFFClampDoubleToUInt16 ( double  val)
static

Definition at line 994 of file tif_dirwrite.c.

995 {
996  if( val < 0 )
997  return 0;
998  if( val > 65535 || val != val )
999  return 65535;
1000  return (uint16)val;
1001 }
GLuint GLfloat * val
Definition: glext.h:7180
unsigned short uint16
Definition: types.h:30

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToUInt32()

static uint32 TIFFClampDoubleToUInt32 ( double  val)
static

Definition at line 1003 of file tif_dirwrite.c.

1004 {
1005  if( val < 0 )
1006  return 0;
1007  if( val > 0xFFFFFFFFU || val != val )
1008  return 0xFFFFFFFFU;
1009  return (uint32)val;
1010 }
unsigned int uint32
Definition: types.h:32
#define U(x)
Definition: wordpad.c:44
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFClampDoubleToUInt8()

static uint8 TIFFClampDoubleToUInt8 ( double  val)
static

Definition at line 985 of file tif_dirwrite.c.

986 {
987  if( val < 0 )
988  return 0;
989  if( val > 255 || val != val )
990  return 255;
991  return (uint8)val;
992 }
GLuint GLfloat * val
Definition: glext.h:7180
unsigned char uint8
Definition: types.h:28

Referenced by TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFCvtNativeToIEEEDouble()

void TIFFCvtNativeToIEEEDouble ( TIFF tif,
uint32  n,
double dp 
)

◆ TIFFCvtNativeToIEEEFloat()

void TIFFCvtNativeToIEEEFloat ( TIFF tif,
uint32  n,
float *  fp 
)

◆ TIFFLinkDirectory()

static int TIFFLinkDirectory ( TIFF tif)
static

Definition at line 2481 of file tif_dirwrite.c.

2482 {
2483  static const char module[] = "TIFFLinkDirectory";
2484 
2485  tif->tif_diroff = (TIFFSeekFile(tif,0,SEEK_END)+1) & (~((toff_t)1));
2486 
2487  /*
2488  * Handle SubIFDs
2489  */
2490  if (tif->tif_flags & TIFF_INSUBIFD)
2491  {
2492  if (!(tif->tif_flags&TIFF_BIGTIFF))
2493  {
2494  uint32 m;
2495  m = (uint32)tif->tif_diroff;
2496  if (tif->tif_flags & TIFF_SWAB)
2497  TIFFSwabLong(&m);
2498  (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET);
2499  if (!WriteOK(tif, &m, 4)) {
2501  "Error writing SubIFD directory link");
2502  return (0);
2503  }
2504  /*
2505  * Advance to the next SubIFD or, if this is
2506  * the last one configured, revert back to the
2507  * normal directory linkage.
2508  */
2509  if (--tif->tif_nsubifd)
2510  tif->tif_subifdoff += 4;
2511  else
2512  tif->tif_flags &= ~TIFF_INSUBIFD;
2513  return (1);
2514  }
2515  else
2516  {
2517  uint64 m;
2518  m = tif->tif_diroff;
2519  if (tif->tif_flags & TIFF_SWAB)
2520  TIFFSwabLong8(&m);
2521  (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET);
2522  if (!WriteOK(tif, &m, 8)) {
2524  "Error writing SubIFD directory link");
2525  return (0);
2526  }
2527  /*
2528  * Advance to the next SubIFD or, if this is
2529  * the last one configured, revert back to the
2530  * normal directory linkage.
2531  */
2532  if (--tif->tif_nsubifd)
2533  tif->tif_subifdoff += 8;
2534  else
2535  tif->tif_flags &= ~TIFF_INSUBIFD;
2536  return (1);
2537  }
2538  }
2539 
2540  if (!(tif->tif_flags&TIFF_BIGTIFF))
2541  {
2542  uint32 m;
2543  uint32 nextdir;
2544  m = (uint32)(tif->tif_diroff);
2545  if (tif->tif_flags & TIFF_SWAB)
2546  TIFFSwabLong(&m);
2547  if (tif->tif_header.classic.tiff_diroff == 0) {
2548  /*
2549  * First directory, overwrite offset in header.
2550  */
2552  (void) TIFFSeekFile(tif,4, SEEK_SET);
2553  if (!WriteOK(tif, &m, 4)) {
2555  "Error writing TIFF header");
2556  return (0);
2557  }
2558  return (1);
2559  }
2560  /*
2561  * Not the first directory, search to the last and append.
2562  */
2563  nextdir = tif->tif_header.classic.tiff_diroff;
2564  while(1) {
2565  uint16 dircount;
2566  uint32 nextnextdir;
2567 
2568  if (!SeekOK(tif, nextdir) ||
2569  !ReadOK(tif, &dircount, 2)) {
2571  "Error fetching directory count");
2572  return (0);
2573  }
2574  if (tif->tif_flags & TIFF_SWAB)
2575  TIFFSwabShort(&dircount);
2576  (void) TIFFSeekFile(tif,
2577  nextdir+2+dircount*12, SEEK_SET);
2578  if (!ReadOK(tif, &nextnextdir, 4)) {
2580  "Error fetching directory link");
2581  return (0);
2582  }
2583  if (tif->tif_flags & TIFF_SWAB)
2584  TIFFSwabLong(&nextnextdir);
2585  if (nextnextdir==0)
2586  {
2587  (void) TIFFSeekFile(tif,
2588  nextdir+2+dircount*12, SEEK_SET);
2589  if (!WriteOK(tif, &m, 4)) {
2591  "Error writing directory link");
2592  return (0);
2593  }
2594  break;
2595  }
2596  nextdir=nextnextdir;
2597  }
2598  }
2599  else
2600  {
2601  uint64 m;
2602  uint64 nextdir;
2603  m = tif->tif_diroff;
2604  if (tif->tif_flags & TIFF_SWAB)
2605  TIFFSwabLong8(&m);
2606  if (tif->tif_header.big.tiff_diroff == 0) {
2607  /*
2608  * First directory, overwrite offset in header.
2609  */
2610  tif->tif_header.big.tiff_diroff = tif->tif_diroff;
2611  (void) TIFFSeekFile(tif,8, SEEK_SET);
2612  if (!WriteOK(tif, &m, 8)) {
2614  "Error writing TIFF header");
2615  return (0);
2616  }
2617  return (1);
2618  }
2619  /*
2620  * Not the first directory, search to the last and append.
2621  */
2622  nextdir = tif->tif_header.big.tiff_diroff;
2623  while(1) {
2624  uint64 dircount64;
2625  uint16 dircount;
2626  uint64 nextnextdir;
2627 
2628  if (!SeekOK(tif, nextdir) ||
2629  !ReadOK(tif, &dircount64, 8)) {
2631  "Error fetching directory count");
2632  return (0);
2633  }
2634  if (tif->tif_flags & TIFF_SWAB)
2635  TIFFSwabLong8(&dircount64);
2636  if (dircount64>0xFFFF)
2637  {
2639  "Sanity check on tag count failed, likely corrupt TIFF");
2640  return (0);
2641  }
2642  dircount=(uint16)dircount64;
2643  (void) TIFFSeekFile(tif,
2644  nextdir+8+dircount*20, SEEK_SET);
2645  if (!ReadOK(tif, &nextnextdir, 8)) {
2647  "Error fetching directory link");
2648  return (0);
2649  }
2650  if (tif->tif_flags & TIFF_SWAB)
2651  TIFFSwabLong8(&nextnextdir);
2652  if (nextnextdir==0)
2653  {
2654  (void) TIFFSeekFile(tif,
2655  nextdir+8+dircount*20, SEEK_SET);
2656  if (!WriteOK(tif, &m, 8)) {
2658  "Error writing directory link");
2659  return (0);
2660  }
2661  break;
2662  }
2663  nextdir=nextnextdir;
2664  }
2665  }
2666  return (1);
2667 }
unsigned long long uint64
Definition: platform.h:18
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:243
unsigned int uint32
Definition: types.h:32
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:221
uint64 toff_t
Definition: tiffio.h:66
thandle_t tif_clientdata
Definition: tiffiop.h:191
char * tif_name
Definition: tiffiop.h:103
const GLfloat * m
Definition: glext.h:10848
#define TIFF_BIGTIFF
Definition: tiffiop.h:125
#define TIFF_SWAB
Definition: tiffiop.h:113
uint16 tif_nsubifd
Definition: tiffiop.h:149
uint32 tif_flags
Definition: tiffiop.h:106
#define SEEK_SET
Definition: jmemansi.c:26
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
uint32 tiff_diroff
Definition: tiff.h:98
if(!(yy_init))
Definition: macro.lex.yy.c:714
uint64 tif_subifdoff
Definition: tiffiop.h:150
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint64 tif_diroff
Definition: tiffiop.h:130
union tiff::@3328 tif_header
TIFFHeaderBig big
Definition: tiffiop.h:140
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
unsigned short uint16
Definition: types.h:30
#define SeekOK(tif, off)
Definition: tiffiop.h:240
#define ReadOK(tif, buf, size)
Definition: tiffiop.h:236
#define SEEK_END
Definition: cabinet.c:27
uint64 tiff_diroff
Definition: tiff.h:105
TIFFHeaderClassic classic
Definition: tiffiop.h:139
#define TIFF_INSUBIFD
Definition: tiffiop.h:119
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57

Referenced by TIFFWriteDirectorySec().

◆ TIFFRewriteDirectory()

int TIFFRewriteDirectory ( TIFF tif)

Definition at line 216 of file tif_dirwrite.c.

217 {
218  static const char module[] = "TIFFRewriteDirectory";
219 
220  /* We don't need to do anything special if it hasn't been written. */
221  if( tif->tif_diroff == 0 )
222  return TIFFWriteDirectory( tif );
223 
224  /*
225  * Find and zero the pointer to this directory, so that TIFFLinkDirectory
226  * will cause it to be added after this directories current pre-link.
227  */
228 
229  if (!(tif->tif_flags&TIFF_BIGTIFF))
230  {
231  if (tif->tif_header.classic.tiff_diroff == tif->tif_diroff)
232  {
233  tif->tif_header.classic.tiff_diroff = 0;
234  tif->tif_diroff = 0;
235 
236  TIFFSeekFile(tif,4,SEEK_SET);
237  if (!WriteOK(tif, &(tif->tif_header.classic.tiff_diroff),4))
238  {
240  "Error updating TIFF header");
241  return (0);
242  }
243  }
244  else
245  {
246  uint32 nextdir;
247  nextdir = tif->tif_header.classic.tiff_diroff;
248  while(1) {
249  uint16 dircount;
250  uint32 nextnextdir;
251 
252  if (!SeekOK(tif, nextdir) ||
253  !ReadOK(tif, &dircount, 2)) {
255  "Error fetching directory count");
256  return (0);
257  }
258  if (tif->tif_flags & TIFF_SWAB)
259  TIFFSwabShort(&dircount);
260  (void) TIFFSeekFile(tif,
261  nextdir+2+dircount*12, SEEK_SET);
262  if (!ReadOK(tif, &nextnextdir, 4)) {
264  "Error fetching directory link");
265  return (0);
266  }
267  if (tif->tif_flags & TIFF_SWAB)
268  TIFFSwabLong(&nextnextdir);
269  if (nextnextdir==tif->tif_diroff)
270  {
271  uint32 m;
272  m=0;
273  (void) TIFFSeekFile(tif,
274  nextdir+2+dircount*12, SEEK_SET);
275  if (!WriteOK(tif, &m, 4)) {
277  "Error writing directory link");
278  return (0);
279  }
280  tif->tif_diroff=0;
281  break;
282  }
283  nextdir=nextnextdir;
284  }
285  }
286  }
287  else
288  {
289  if (tif->tif_header.big.tiff_diroff == tif->tif_diroff)
290  {
291  tif->tif_header.big.tiff_diroff = 0;
292  tif->tif_diroff = 0;
293 
294  TIFFSeekFile(tif,8,SEEK_SET);
295  if (!WriteOK(tif, &(tif->tif_header.big.tiff_diroff),8))
296  {
298  "Error updating TIFF header");
299  return (0);
300  }
301  }
302  else
303  {
304  uint64 nextdir;
305  nextdir = tif->tif_header.big.tiff_diroff;
306  while(1) {
307  uint64 dircount64;
308  uint16 dircount;
309  uint64 nextnextdir;
310 
311  if (!SeekOK(tif, nextdir) ||
312  !ReadOK(tif, &dircount64, 8)) {
314  "Error fetching directory count");
315  return (0);
316  }
317  if (tif->tif_flags & TIFF_SWAB)
318  TIFFSwabLong8(&dircount64);
319  if (dircount64>0xFFFF)
320  {
322  "Sanity check on tag count failed, likely corrupt TIFF");
323  return (0);
324  }
325  dircount=(uint16)dircount64;
326  (void) TIFFSeekFile(tif,
327  nextdir+8+dircount*20, SEEK_SET);
328  if (!ReadOK(tif, &nextnextdir, 8)) {
330  "Error fetching directory link");
331  return (0);
332  }
333  if (tif->tif_flags & TIFF_SWAB)
334  TIFFSwabLong8(&nextnextdir);
335  if (nextnextdir==tif->tif_diroff)
336  {
337  uint64 m;
338  m=0;
339  (void) TIFFSeekFile(tif,
340  nextdir+8+dircount*20, SEEK_SET);
341  if (!WriteOK(tif, &m, 8)) {
343  "Error writing directory link");
344  return (0);
345  }
346  tif->tif_diroff=0;
347  break;
348  }
349  nextdir=nextnextdir;
350  }
351  }
352  }
353 
354  /*
355  * Now use TIFFWriteDirectory() normally.
356  */
357 
358  return TIFFWriteDirectory( tif );
359 }
unsigned long long uint64
Definition: platform.h:18
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:243
unsigned int uint32
Definition: types.h:32
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:221
thandle_t tif_clientdata
Definition: tiffiop.h:191
char * tif_name
Definition: tiffiop.h:103
const GLfloat * m
Definition: glext.h:10848
#define TIFF_BIGTIFF
Definition: tiffiop.h:125
#define TIFF_SWAB
Definition: tiffiop.h:113
int TIFFWriteDirectory(TIFF *tif)
Definition: tif_dirwrite.c:180
uint32 tif_flags
Definition: tiffiop.h:106
#define SEEK_SET
Definition: jmemansi.c:26
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
uint32 tiff_diroff
Definition: tiff.h:98
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint64 tif_diroff
Definition: tiffiop.h:130
union tiff::@3328 tif_header
TIFFHeaderBig big
Definition: tiffiop.h:140
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
unsigned short uint16
Definition: types.h:30
#define SeekOK(tif, off)
Definition: tiffiop.h:240
#define ReadOK(tif, buf, size)
Definition: tiffiop.h:236
uint64 tiff_diroff
Definition: tiff.h:105
TIFFHeaderClassic classic
Definition: tiffiop.h:139
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57

Referenced by TIFFFlush().

◆ TIFFWriteCustomDirectory()

int TIFFWriteCustomDirectory ( TIFF tif,
uint64 pdiroff 
)

Definition at line 204 of file tif_dirwrite.c.

205 {
206  return TIFFWriteDirectorySec(tif,FALSE,FALSE,pdiroff);
207 }
static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, uint64 *pdiroff)
Definition: tif_dirwrite.c:362

◆ TIFFWriteDirectory()

int TIFFWriteDirectory ( TIFF tif)

Definition at line 180 of file tif_dirwrite.c.

181 {
182  return TIFFWriteDirectorySec(tif,TRUE,TRUE,NULL);
183 }
#define TRUE
Definition: types.h:120
static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, uint64 *pdiroff)
Definition: tif_dirwrite.c:362
smooth NULL
Definition: ftsmooth.c:416

Referenced by TIFFRewriteDirectory().

◆ TIFFWriteDirectorySec()

static int TIFFWriteDirectorySec ( TIFF tif,
int  isimage,
int  imagedone,
uint64 pdiroff 
)
static

Definition at line 362 of file tif_dirwrite.c.

363 {
364  static const char module[] = "TIFFWriteDirectorySec";
365  uint32 ndir;
366  TIFFDirEntry* dir;
367  uint32 dirsize;
368  void* dirmem;
369  uint32 m;
370  if (tif->tif_mode == O_RDONLY)
371  return (1);
372 
373  _TIFFFillStriles( tif );
374 
375  /*
376  * Clear write state so that subsequent images with
377  * different characteristics get the right buffers
378  * setup for them.
379  */
380  if (imagedone)
381  {
382  if (tif->tif_flags & TIFF_POSTENCODE)
383  {
384  tif->tif_flags &= ~TIFF_POSTENCODE;
385  if (!(*tif->tif_postencode)(tif))
386  {
388  "Error post-encoding before directory write");
389  return (0);
390  }
391  }
392  (*tif->tif_close)(tif); /* shutdown encoder */
393  /*
394  * Flush any data that might have been written
395  * by the compression close+cleanup routines. But
396  * be careful not to write stuff if we didn't add data
397  * in the previous steps as the "rawcc" data may well be
398  * a previously read tile/strip in mixed read/write mode.
399  */
400  if (tif->tif_rawcc > 0
401  && (tif->tif_flags & TIFF_BEENWRITING) != 0 )
402  {
403  if( !TIFFFlushData1(tif) )
404  {
406  "Error flushing data before directory write");
407  return (0);
408  }
409  }
410  if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
411  {
412  _TIFFfree(tif->tif_rawdata);
413  tif->tif_rawdata = NULL;
414  tif->tif_rawcc = 0;
415  tif->tif_rawdatasize = 0;
416  tif->tif_rawdataoff = 0;
417  tif->tif_rawdataloaded = 0;
418  }
420  }
421  dir=NULL;
422  dirmem=NULL;
423  dirsize=0;
424  while (1)
425  {
426  ndir=0;
427  if (isimage)
428  {
430  {
432  goto bad;
434  goto bad;
435  }
437  {
439  goto bad;
441  goto bad;
442  }
444  {
446  goto bad;
448  goto bad;
449  }
450  if (TIFFFieldSet(tif,FIELD_POSITION))
451  {
453  goto bad;
455  goto bad;
456  }
458  {
460  goto bad;
461  }
463  {
465  goto bad;
466  }
468  {
470  goto bad;
471  }
473  {
475  goto bad;
476  }
478  {
480  goto bad;
481  }
482  if (TIFFFieldSet(tif,FIELD_FILLORDER))
483  {
485  goto bad;
486  }
488  {
490  goto bad;
491  }
493  {
495  goto bad;
496  }
498  {
500  goto bad;
501  }
503  {
505  goto bad;
506  }
508  {
510  goto bad;
511  }
513  {
515  goto bad;
516  }
518  {
520  goto bad;
521  }
523  {
525  goto bad;
526  }
528  {
529  if (!isTiled(tif))
530  {
532  goto bad;
533  }
534  else
535  {
537  goto bad;
538  }
539  }
541  {
542  if (!isTiled(tif))
543  {
544  /* td_stripoffset might be NULL in an odd OJPEG case. See
545  * tif_dirread.c around line 3634.
546  * XXX: OJPEG hack.
547  * If a) compression is OJPEG, b) it's not a tiled TIFF,
548  * and c) the number of strips is 1,
549  * then we tolerate the absence of stripoffsets tag,
550  * because, presumably, all required data is in the
551  * JpegInterchangeFormat stream.
552  * We can get here when using tiffset on such a file.
553  * See http://bugzilla.maptools.org/show_bug.cgi?id=2500
554  */
555  if (tif->tif_dir.td_stripoffset != NULL &&
557  goto bad;
558  }
559  else
560  {
562  goto bad;
563  }
564  }
565  if (TIFFFieldSet(tif,FIELD_COLORMAP))
566  {
567  if (!TIFFWriteDirectoryTagColormap(tif,&ndir,dir))
568  goto bad;
569  }
571  {
572  if (tif->tif_dir.td_extrasamples)
573  {
574  uint16 na;
575  uint16* nb;
578  goto bad;
579  }
580  }
582  {
584  goto bad;
585  }
587  {
589  goto bad;
590  }
592  {
594  goto bad;
595  }
597  {
599  goto bad;
600  }
601  if (TIFFFieldSet(tif,FIELD_TILEDEPTH))
602  {
604  goto bad;
605  }
607  {
609  goto bad;
610  }
612  {
614  goto bad;
615  }
617  {
619  goto bad;
620  }
622  {
624  goto bad;
625  }
627  {
629  goto bad;
630  }
631  if (TIFFFieldSet(tif,FIELD_INKNAMES))
632  {
634  goto bad;
635  }
636  if (TIFFFieldSet(tif,FIELD_SUBIFD))
637  {
638  if (!TIFFWriteDirectoryTagSubifd(tif,&ndir,dir))
639  goto bad;
640  }
641  {
642  uint32 n;
643  for (n=0; n<tif->tif_nfields; n++) {
644  const TIFFField* o;
645  o = tif->tif_fields[n];
646  if ((o->field_bit>=FIELD_CODEC)&&(TIFFFieldSet(tif,o->field_bit)))
647  {
648  switch (o->get_field_type)
649  {
650  case TIFF_SETGET_ASCII:
651  {
652  uint32 pa;
653  char* pb;
656  assert(o->field_passcount==0);
657  TIFFGetField(tif,o->field_tag,&pb);
658  pa=(uint32)(strlen(pb));
659  if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,(uint16)o->field_tag,pa,pb))
660  goto bad;
661  }
662  break;
663  case TIFF_SETGET_UINT16:
664  {
665  uint16 p;
667  assert(o->field_readcount==1);
668  assert(o->field_passcount==0);
669  TIFFGetField(tif,o->field_tag,&p);
670  if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,(uint16)o->field_tag,p))
671  goto bad;
672  }
673  break;
674  case TIFF_SETGET_UINT32:
675  {
676  uint32 p;
678  assert(o->field_readcount==1);
679  assert(o->field_passcount==0);
680  TIFFGetField(tif,o->field_tag,&p);
681  if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,(uint16)o->field_tag,p))
682  goto bad;
683  }
684  break;
686  {
687  uint32 pa;
688  void* pb;
691  assert(o->field_passcount==1);
692  TIFFGetField(tif,o->field_tag,&pa,&pb);
693  if (!TIFFWriteDirectoryTagUndefinedArray(tif,&ndir,dir,(uint16)o->field_tag,pa,pb))
694  goto bad;
695  }
696  break;
697  default:
699  "Cannot write tag %d (%s)",
700  TIFFFieldTag(o),
701  o->field_name ? o->field_name : "unknown");
702  goto bad;
703  }
704  }
705  }
706  }
707  }
708  for (m=0; m<(uint32)(tif->tif_dir.td_customValueCount); m++)
709  {
713  {
714  case TIFF_ASCII:
716  goto bad;
717  break;
718  case TIFF_UNDEFINED:
720  goto bad;
721  break;
722  case TIFF_BYTE:
724  goto bad;
725  break;
726  case TIFF_SBYTE:
728  goto bad;
729  break;
730  case TIFF_SHORT:
732  goto bad;
733  break;
734  case TIFF_SSHORT:
736  goto bad;
737  break;
738  case TIFF_LONG:
740  goto bad;
741  break;
742  case TIFF_SLONG:
744  goto bad;
745  break;
746  case TIFF_LONG8:
748  goto bad;
749  break;
750  case TIFF_SLONG8:
752  goto bad;
753  break;
754  case TIFF_RATIONAL:
756  goto bad;
757  break;
758  case TIFF_SRATIONAL:
760  goto bad;
761  break;
762  case TIFF_FLOAT:
764  goto bad;
765  break;
766  case TIFF_DOUBLE:
768  goto bad;
769  break;
770  case TIFF_IFD:
772  goto bad;
773  break;
774  case TIFF_IFD8:
776  goto bad;
777  break;
778  default:
779  assert(0); /* we should never get here */
780  break;
781  }
782  }
783  if (dir!=NULL)
784  break;
785  dir=_TIFFmalloc(ndir*sizeof(TIFFDirEntry));
786  if (dir==NULL)
787  {
788  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
789  goto bad;
790  }
791  if (isimage)
792  {
793  if ((tif->tif_diroff==0)&&(!TIFFLinkDirectory(tif)))
794  goto bad;
795  }
796  else
797  tif->tif_diroff=(TIFFSeekFile(tif,0,SEEK_END)+1)&(~((toff_t)1));
798  if (pdiroff!=NULL)
799  *pdiroff=tif->tif_diroff;
800  if (!(tif->tif_flags&TIFF_BIGTIFF))
801  dirsize=2+ndir*12+4;
802  else
803  dirsize=8+ndir*20+8;
804  tif->tif_dataoff=tif->tif_diroff+dirsize;
805  if (!(tif->tif_flags&TIFF_BIGTIFF))
806  tif->tif_dataoff=(uint32)tif->tif_dataoff;
807  if ((tif->tif_dataoff<tif->tif_diroff)||(tif->tif_dataoff<(uint64)dirsize))
808  {
809  TIFFErrorExt(tif->tif_clientdata,module,"Maximum TIFF file size exceeded");
810  goto bad;
811  }
812  if (tif->tif_dataoff&1)
813  tif->tif_dataoff++;
814  if (isimage)
815  tif->tif_curdir++;
816  }
817  if (isimage)
818  {
819  if (TIFFFieldSet(tif,FIELD_SUBIFD)&&(tif->tif_subifdoff==0))
820  {
821  uint32 na;
822  TIFFDirEntry* nb;
823  for (na=0, nb=dir; ; na++, nb++)
824  {
825  if( na == ndir )
826  {
828  "Cannot find SubIFD tag");
829  goto bad;
830  }
831  if (nb->tdir_tag==TIFFTAG_SUBIFD)
832  break;
833  }
834  if (!(tif->tif_flags&TIFF_BIGTIFF))
835  tif->tif_subifdoff=tif->tif_diroff+2+na*12+8;
836  else
837  tif->tif_subifdoff=tif->tif_diroff+8+na*20+12;
838  }
839  }
840  dirmem=_TIFFmalloc(dirsize);
841  if (dirmem==NULL)
842  {
843  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
844  goto bad;
845  }
846  if (!(tif->tif_flags&TIFF_BIGTIFF))
847  {
848  uint8* n;
849  uint32 nTmp;
850  TIFFDirEntry* o;
851  n=dirmem;
852  *(uint16*)n=(uint16)ndir;
853  if (tif->tif_flags&TIFF_SWAB)
855  n+=2;
856  o=dir;
857  for (m=0; m<ndir; m++)
858  {
859  *(uint16*)n=o->tdir_tag;
860  if (tif->tif_flags&TIFF_SWAB)
862  n+=2;
863  *(uint16*)n=o->tdir_type;
864  if (tif->tif_flags&TIFF_SWAB)
866  n+=2;
867  nTmp = (uint32)o->tdir_count;
868  _TIFFmemcpy(n,&nTmp,4);
869  if (tif->tif_flags&TIFF_SWAB)
870  TIFFSwabLong((uint32*)n);
871  n+=4;
872  /* This is correct. The data has been */
873  /* swabbed previously in TIFFWriteDirectoryTagData */
874  _TIFFmemcpy(n,&o->tdir_offset,4);
875  n+=4;
876  o++;
877  }
878  nTmp = (uint32)tif->tif_nextdiroff;
879  if (tif->tif_flags&TIFF_SWAB)
880  TIFFSwabLong(&nTmp);
881  _TIFFmemcpy(n,&nTmp,4);
882  }
883  else
884  {
885  uint8* n;
886  TIFFDirEntry* o;
887  n=dirmem;
888  *(uint64*)n=ndir;
889  if (tif->tif_flags&TIFF_SWAB)
891  n+=8;
892  o=dir;
893  for (m=0; m<ndir; m++)
894  {
895  *(uint16*)n=o->tdir_tag;
896  if (tif->tif_flags&TIFF_SWAB)
898  n+=2;
899  *(uint16*)n=o->tdir_type;
900  if (tif->tif_flags&TIFF_SWAB)
902  n+=2;
903  _TIFFmemcpy(n,&o->tdir_count,8);
904  if (tif->tif_flags&TIFF_SWAB)
906  n+=8;
907  _TIFFmemcpy(n,&o->tdir_offset,8);
908  n+=8;
909  o++;
910  }
911  _TIFFmemcpy(n,&tif->tif_nextdiroff,8);
912  if (tif->tif_flags&TIFF_SWAB)
914  }
915  _TIFFfree(dir);
916  dir=NULL;
917  if (!SeekOK(tif,tif->tif_diroff))
918  {
919  TIFFErrorExt(tif->tif_clientdata,module,"IO error writing directory");
920  goto bad;
921  }
922  if (!WriteOK(tif,dirmem,(tmsize_t)dirsize))
923  {
924  TIFFErrorExt(tif->tif_clientdata,module,"IO error writing directory");
925  goto bad;
926  }
927  _TIFFfree(dirmem);
928  if (imagedone)
929  {
930  TIFFFreeDirectory(tif);
931  tif->tif_flags &= ~TIFF_DIRTYDIRECT;
932  tif->tif_flags &= ~TIFF_DIRTYSTRIP;
933  (*tif->tif_cleanup)(tif);
934  /*
935  * Reset directory-related state for subsequent
936  * directories.
937  */
938  TIFFCreateDirectory(tif);
939  }
940  return(1);
941 bad:
942  if (dir!=NULL)
943  _TIFFfree(dir);
944  if (dirmem!=NULL)
945  _TIFFfree(dirmem);
946  return(0);
947 }
unsigned long long uint64
Definition: platform.h:18
static int TIFFWriteDirectoryTagTransferfunction(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
#define TIFFTAG_SUBFILETYPE
Definition: tiff.h:146
#define TIFF_BEENWRITING
Definition: tiffiop.h:112
#define TIFF_VARIABLE
Definition: tiffio.h:313
static int TIFFWriteDirectoryTagShortLong(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
uint16 td_ycbcrpositioning
Definition: tif_dir.h:111
uint32 TIFFFieldTag(const TIFFField *fip)
Definition: tif_dirinfo.c:582
float td_yposition
Definition: tif_dir.h:89
uint16 td_bitspersample
Definition: tif_dir.h:74
uint32 td_tiledepth
Definition: tif_dir.h:72
#define FIELD_MINSAMPLEVALUE
Definition: tif_dir.h:152
#define FIELD_RESOLUTION
Definition: tif_dir.h:139
#define TIFFTAG_BITSPERSAMPLE
Definition: tiff.h:156
#define TIFFTAG_ROWSPERSTRIP
Definition: tiff.h:233
char * td_inknames
Definition: tif_dir.h:117
int td_inknameslen
Definition: tif_dir.h:116
#define FIELD_STRIPOFFSETS
Definition: tif_dir.h:158
#define TIFFTAG_STRIPBYTECOUNTS
Definition: tiff.h:234
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TIFFTAG_EXTRASAMPLES
Definition: tiff.h:304
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:243
#define TIFFTAG_ORIENTATION
Definition: tiff.h:223
#define FIELD_IMAGEDIMENSIONS
Definition: tif_dir.h:137
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:221
#define TIFFTAG_IMAGEWIDTH
Definition: tiff.h:154
#define FIELD_THRESHHOLDING
Definition: tif_dir.h:147
#define TIFFTAG_YRESOLUTION
Definition: tiff.h:238
#define TIFFTAG_MINSAMPLEVALUE
Definition: tiff.h:235
#define TIFFTAG_INKNAMES
Definition: tiff.h:300
#define TIFFTAG_FILLORDER
Definition: tiff.h:215
uint64 toff_t
Definition: tiffio.h:66
TIFFTagValue * td_customValues
Definition: tif_dir.h:120
uint16 td_halftonehints[2]
Definition: tif_dir.h:92
GLdouble n
Definition: glext.h:7729
static int TIFFWriteDirectoryTagRationalArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
int count
Definition: tif_dir.h:37
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define FIELD_HALFTONEHINTS
Definition: tif_dir.h:166
TIFFVoidMethod tif_close
Definition: tiffiop.h:170
uint8 * tif_rawdata
Definition: tiffiop.h:179
uint32 td_imagedepth
Definition: tif_dir.h:71
int td_customValueCount
Definition: tif_dir.h:119
#define TIFFTAG_STRIPOFFSETS
Definition: tiff.h:222
#define TIFFTAG_SUBIFD
Definition: tiff.h:296
#define TIFFTAG_THRESHHOLDING
Definition: tiff.h:209
#define TIFFTAG_YCBCRSUBSAMPLING
Definition: tiff.h:367
thandle_t tif_clientdata
Definition: tiffiop.h:191
tmsize_t tif_rawdataoff
Definition: tiffiop.h:181
#define FIELD_RESOLUTIONUNIT
Definition: tif_dir.h:155
#define TIFFTAG_YPOSITION
Definition: tiff.h:244
#define TIFFTAG_SMINSAMPLEVALUE
Definition: tiff.h:315
#define TIFFTAG_REFERENCEBLACKWHITE
Definition: tiff.h:371
tmsize_t tif_rawcc
Definition: tiffiop.h:184
uint16 tif_curdir
Definition: tiffiop.h:144
#define TIFFTAG_PLANARCONFIG
Definition: tiff.h:239
#define TIFF_DIRTYDIRECT
Definition: tiffiop.h:109
const GLfloat * m
Definition: glext.h:10848
static int TIFFWriteDirectoryTagSrationalArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
#define FIELD_YCBCRSUBSAMPLING
Definition: tif_dir.h:167
#define FIELD_SMAXSAMPLEVALUE
Definition: tif_dir.h:163
float td_xresolution
Definition: tif_dir.h:86
#define TIFFTAG_TILEBYTECOUNTS
Definition: tiff.h:289
uint32 td_tilelength
Definition: tif_dir.h:72
unsigned short field_bit
Definition: tif_dir.h:286
#define FIELD_SUBIFD
Definition: tif_dir.h:172
#define FIELD_TRANSFERFUNCTION
Definition: tif_dir.h:170
#define FIELD_FILLORDER
Definition: tif_dir.h:148
static int TIFFWriteDirectoryTagShort(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
#define FIELD_MAXSAMPLEVALUE
Definition: tif_dir.h:153
int TIFFGetField(TIFF *tif, uint32 tag,...)
Definition: tif_dir.c:1215
static int TIFFWriteDirectoryTagShortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
static int TIFFWriteDirectoryTagLongLong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
float td_xposition
Definition: tif_dir.h:89
#define FIELD_BITSPERSAMPLE
Definition: tif_dir.h:144
#define TIFF_BIGTIFF
Definition: tiffiop.h:125
#define TIFF_SWAB
Definition: tiffiop.h:113
#define TIFFTAG_YCBCRPOSITIONING
Definition: tiff.h:368
#define TIFFTAG_TILEWIDTH
Definition: tiff.h:286
char * field_name
Definition: tif_dir.h:289
#define FIELD_STRIPBYTECOUNTS
Definition: tif_dir.h:157
uint32 td_subfiletype
Definition: tif_dir.h:73
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
uint16 td_resolutionunit
Definition: tif_dir.h:87
#define TIFFTAG_TILELENGTH
Definition: tiff.h:287
int tif_mode
Definition: tiffiop.h:105
uint32 tif_flags
Definition: tiffiop.h:106
smooth NULL
Definition: ftsmooth.c:416
static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
#define TIFFTAG_IMAGELENGTH
Definition: tiff.h:155
#define FIELD_PLANARCONFIG
Definition: tif_dir.h:154
size_t tif_nfields
Definition: tiffiop.h:201
#define TIFFTAG_TILEOFFSETS
Definition: tiff.h:288
#define TIFFTAG_SAMPLESPERPIXEL
Definition: tiff.h:232
uint16 td_planarconfig
Definition: tif_dir.h:88
switch(r->id)
Definition: btrfs.c:2904
unsigned int dir
Definition: maze.c:112
double * td_sminsamplevalue
Definition: tif_dir.h:84
uint64 tif_nextdiroff
Definition: tiffiop.h:131
#define TIFF_POSTENCODE
Definition: tiffiop.h:118
static int TIFFWriteDirectoryTagSshortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int16 *value)
static int TIFFWriteDirectoryTagSubifd(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
uint16 td_orientation
Definition: tif_dir.h:80
uint16 td_minsamplevalue
Definition: tif_dir.h:83
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
TIFFSetGetFieldType get_field_type
Definition: tif_dir.h:285
void TIFFFreeDirectory(TIFF *tif)
Definition: tif_dir.c:1251
unsigned char field_passcount
Definition: tif_dir.h:288
uint32 td_nstrips
Definition: tif_dir.h:99
static int TIFFWriteDirectoryTagByteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
int TIFFGetFieldDefaulted(TIFF *tif, uint32 tag,...)
Definition: tif_aux.c:309
TIFFBoolMethod tif_postencode
Definition: tiffiop.h:163
const TIFFField * info
Definition: tif_dir.h:36
if(!(yy_init))
Definition: macro.lex.yy.c:714
uint16 td_extrasamples
Definition: tif_dir.h:93
uint32 td_imagelength
Definition: tif_dir.h:71
uint32 field_tag
Definition: tif_dir.h:279
#define TIFFTAG_XPOSITION
Definition: tiff.h:243
uint16 td_photometric
Definition: tif_dir.h:77
uint16 tdir_tag
Definition: tif_dir.h:53
#define TIFFTAG_HALFTONEHINTS
Definition: tiff.h:285
uint64 tif_subifdoff
Definition: tiffiop.h:150
unsigned char uint8
Definition: types.h:28
#define FIELD_PHOTOMETRIC
Definition: tif_dir.h:146
uint64 tif_dataoff
Definition: tiffiop.h:147
static int TIFFWriteDirectoryTagShortPerSample(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
static int TIFFWriteDirectoryTagLong(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
static int TIFFLinkDirectory(TIFF *)
double * td_smaxsamplevalue
Definition: tif_dir.h:85
#define TIFFTAG_PHOTOMETRIC
Definition: tiff.h:195
tmsize_t tif_rawdatasize
Definition: tiffiop.h:180
#define TIFFFieldSet(tif, field)
Definition: tif_dir.h:192
uint16 td_fillorder
Definition: tif_dir.h:79
#define TIFFTAG_PAGENUMBER
Definition: tiff.h:266
static int TIFFWriteDirectoryTagIfdArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
#define FIELD_COMPRESSION
Definition: tif_dir.h:145
uint64 * td_stripoffset
Definition: tif_dir.h:100
#define FIELD_SMINSAMPLEVALUE
Definition: tif_dir.h:162
union TIFFDirEntry::@3326 tdir_offset
#define FIELD_ROWSPERSTRIP
Definition: tif_dir.h:151
uint64 tdir_count
Definition: tif_dir.h:55
#define TIFF_DIRTYSTRIP
Definition: tiffiop.h:127
tmsize_t tif_rawdataloaded
Definition: tiffiop.h:182
static int TIFFWriteDirectoryTagLong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
#define FIELD_INKNAMES
Definition: tif_dir.h:171
uint64 tif_diroff
Definition: tiffiop.h:130
#define TIFFTAG_COMPRESSION
Definition: tiff.h:157
uint32 td_tilewidth
Definition: tif_dir.h:72
#define FIELD_ORIENTATION
Definition: tif_dir.h:149
uint16 td_sampleformat
Definition: tif_dir.h:75
uint16 td_threshholding
Definition: tif_dir.h:78
uint64 * td_stripbytecount
Definition: tif_dir.h:101
TIFFVoidMethod tif_cleanup
Definition: tiffiop.h:172
uint16 td_pagenumber[2]
Definition: tif_dir.h:90
static int TIFFWriteDirectoryTagRational(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, double value)
#define FIELD_IMAGEDEPTH
Definition: tif_dir.h:164
static int TIFFWriteDirectoryTagFloatArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
#define isTiled(tif)
Definition: tiffiop.h:213
#define TIFFTAG_SMAXSAMPLEVALUE
Definition: tiff.h:316
#define TIFF_BUFFERSETUP
Definition: tiffiop.h:110
#define FIELD_YCBCRPOSITIONING
Definition: tif_dir.h:168
TIFFField ** tif_fields
Definition: tiffiop.h:200
#define FIELD_CODEC
Definition: tif_dir.h:175
#define FIELD_EXTRASAMPLES
Definition: tif_dir.h:160
#define TIFF_VARIABLE2
Definition: tiffio.h:315
uint16 td_maxsamplevalue
Definition: tif_dir.h:83
void * value
Definition: tif_dir.h:38
uint32 td_rowsperstrip
Definition: tif_dir.h:82
TIFFDataType field_type
Definition: tif_dir.h:282
#define TIFFTAG_TILEDEPTH
Definition: tiff.h:387
#define TIFFTAG_IMAGEDEPTH
Definition: tiff.h:386
#define TIFFTAG_RESOLUTIONUNIT
Definition: tiff.h:262
static int TIFFWriteDirectoryTagLongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
uint16 td_ycbcrsubsampling[2]
Definition: tif_dir.h:110
#define TIFFTAG_XRESOLUTION
Definition: tiff.h:237
unsigned short uint16
Definition: types.h:30
#define FIELD_POSITION
Definition: tif_dir.h:140
TIFFDirectory tif_dir
Definition: tiffiop.h:135
static int TIFFWriteDirectoryTagAscii(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, char *value)
#define FIELD_PAGENUMBER
Definition: tif_dir.h:156
#define FIELD_TILEDEPTH
Definition: tif_dir.h:165
static int TIFFWriteDirectoryTagSbyteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int8 *value)
#define FIELD_TILEDIMENSIONS
Definition: tif_dir.h:138
#define SeekOK(tif, off)
Definition: tiffiop.h:240
float * td_refblackwhite
Definition: tif_dir.h:114
static int TIFFWriteDirectoryTagColormap(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir)
static int TIFFWriteDirectoryTagSlong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int64 *value)
#define FIELD_COLORMAP
Definition: tif_dir.h:159
#define FIELD_SAMPLESPERPIXEL
Definition: tif_dir.h:150
float td_yresolution
Definition: tif_dir.h:86
#define SEEK_END
Definition: cabinet.c:27
uint16 td_samplesperpixel
Definition: tif_dir.h:81
static int TIFFWriteDirectoryTagSampleformatArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
#define FIELD_REFBLACKWHITE
Definition: tif_dir.h:169
Definition: tiff.h:137
int TIFFCreateDirectory(TIFF *tif)
Definition: tif_dir.c:1311
uint16 td_compression
Definition: tif_dir.h:76
void _TIFFfree(void *p)
Definition: tif_unix.c:326
#define TIFFTAG_SAMPLEFORMAT
Definition: tiff.h:308
GLfloat GLfloat p
Definition: glext.h:8902
#define FIELD_SAMPLEFORMAT
Definition: tif_dir.h:161
uint32 td_imagewidth
Definition: tif_dir.h:71
int TIFFFlushData1(TIFF *tif)
Definition: tif_write.c:792
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344
#define TIFFTAG_MAXSAMPLEVALUE
Definition: tiff.h:236
#define TIFF_MYBUFFER
Definition: tiffiop.h:115
static int TIFFWriteDirectoryTagUndefinedArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57
int _TIFFFillStriles(TIFF *tif)
Definition: tif_dirread.c:5812
#define FIELD_SUBFILETYPE
Definition: tif_dir.h:143
static int TIFFWriteDirectoryTagDoubleArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
uint16 tdir_type
Definition: tif_dir.h:54
short field_readcount
Definition: tif_dir.h:280
#define O_RDONLY
Definition: acwin.h:108
static int TIFFWriteDirectoryTagSlongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int32 *value)

Referenced by TIFFCheckpointDirectory(), TIFFWriteCustomDirectory(), and TIFFWriteDirectory().

◆ TIFFWriteDirectoryTagAscii()

static int TIFFWriteDirectoryTagAscii ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
char value 
)
static

Definition at line 1120 of file tif_dirwrite.c.

1121 {
1122  if (dir==NULL)
1123  {
1124  (*ndir)++;
1125  return(1);
1126  }
1128 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedAscii(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, char *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagByteArray()

static int TIFFWriteDirectoryTagByteArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint8 value 
)
static

Definition at line 1155 of file tif_dirwrite.c.

1156 {
1157  if (dir==NULL)
1158  {
1159  (*ndir)++;
1160  return(1);
1161  }
1163 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedByteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagCheckedAscii()

static int TIFFWriteDirectoryTagCheckedAscii ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
char value 
)
static

Definition at line 1988 of file tif_dirwrite.c.

1989 {
1990  assert(sizeof(char)==1);
1992 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectoryTagAscii().

◆ TIFFWriteDirectoryTagCheckedByteArray()

static int TIFFWriteDirectoryTagCheckedByteArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint8 value 
)
static

Definition at line 2011 of file tif_dirwrite.c.

2012 {
2013  assert(sizeof(uint8)==1);
2015 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
unsigned int dir
Definition: maze.c:112
unsigned char uint8
Definition: types.h:28

Referenced by TIFFWriteDirectoryTagByteArray().

◆ TIFFWriteDirectoryTagCheckedDoubleArray()

static int TIFFWriteDirectoryTagCheckedDoubleArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
double value 
)
static

Definition at line 2376 of file tif_dirwrite.c.

2377 {
2378  assert(count<0x20000000);
2379  assert(sizeof(double)==8);
2381  if (tif->tif_flags&TIFF_SWAB)
2384 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
void TIFFCvtNativeToIEEEDouble(TIFF *tif, uint32 n, double *dp)
void TIFFSwabArrayOfDouble(double *dp, tmsize_t n)
Definition: tif_swab.c:182

Referenced by TIFFWriteDirectoryTagDoubleArray().

◆ TIFFWriteDirectoryTagCheckedFloatArray()

static int TIFFWriteDirectoryTagCheckedFloatArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float *  value 
)
static

Definition at line 2351 of file tif_dirwrite.c.

2352 {
2353  assert(count<0x40000000);
2354  assert(sizeof(float)==4);
2356  if (tif->tif_flags&TIFF_SWAB)
2359 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
void TIFFSwabArrayOfFloat(register float *fp, tmsize_t n)
Definition: tif_swab.c:151
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
void TIFFCvtNativeToIEEEFloat(TIFF *tif, uint32 n, float *fp)

Referenced by TIFFWriteDirectoryTagFloatArray().

◆ TIFFWriteDirectoryTagCheckedIfd8Array()

static int TIFFWriteDirectoryTagCheckedIfd8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint64 value 
)
static

Definition at line 2397 of file tif_dirwrite.c.

2398 {
2399  assert(count<0x20000000);
2400  assert(sizeof(uint64)==8);
2402  if (tif->tif_flags&TIFF_SWAB)
2405 }
unsigned long long uint64
Definition: platform.h:18
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_BIGTIFF
Definition: tiffiop.h:125
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
void TIFFSwabArrayOfLong8(register uint64 *lp, tmsize_t n)
Definition: tif_swab.c:120

Referenced by TIFFWriteDirectoryTagIfdIfd8Array(), and TIFFWriteDirectoryTagSubifd().

◆ TIFFWriteDirectoryTagCheckedIfdArray()

static int TIFFWriteDirectoryTagCheckedIfdArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint32 value 
)
static

Definition at line 2387 of file tif_dirwrite.c.

2388 {
2389  assert(count<0x40000000);
2390  assert(sizeof(uint32)==4);
2391  if (tif->tif_flags&TIFF_SWAB)
2394 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
Definition: tiff.h:137

Referenced by TIFFWriteDirectoryTagIfdArray(), TIFFWriteDirectoryTagIfdIfd8Array(), and TIFFWriteDirectoryTagSubifd().

◆ TIFFWriteDirectoryTagCheckedLong()

static int TIFFWriteDirectoryTagCheckedLong ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  value 
)
static

Definition at line 2078 of file tif_dirwrite.c.

2079 {
2080  uint32 m;
2081  assert(sizeof(uint32)==4);
2082  m=value;
2083  if (tif->tif_flags&TIFF_SWAB)
2084  TIFFSwabLong(&m);
2085  return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG,1,4,&m));
2086 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
const GLfloat * m
Definition: glext.h:10848
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
GLsizei const GLfloat * value
Definition: glext.h:6069
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45

Referenced by TIFFWriteDirectoryTagLong(), and TIFFWriteDirectoryTagShortLong().

◆ TIFFWriteDirectoryTagCheckedLong8Array()

static int TIFFWriteDirectoryTagCheckedLong8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint64 value 
)
static

Definition at line 2139 of file tif_dirwrite.c.

2140 {
2141  assert(count<0x20000000);
2142  assert(sizeof(uint64)==8);
2143  if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
2144  TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8Array","LONG8 not allowed for ClassicTIFF");
2145  return(0);
2146  }
2147  if (tif->tif_flags&TIFF_SWAB)
2150 }
unsigned long long uint64
Definition: platform.h:18
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
#define TIFF_BIGTIFF
Definition: tiffiop.h:125
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
void TIFFSwabArrayOfLong8(register uint64 *lp, tmsize_t n)
Definition: tif_swab.c:120

Referenced by TIFFWriteDirectoryTagLong8Array(), and TIFFWriteDirectoryTagLongLong8Array().

◆ TIFFWriteDirectoryTagCheckedLongArray()

static int TIFFWriteDirectoryTagCheckedLongArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint32 value 
)
static

Definition at line 2089 of file tif_dirwrite.c.

2090 {
2091  assert(count<0x40000000);
2092  assert(sizeof(uint32)==4);
2093  if (tif->tif_flags&TIFF_SWAB)
2096 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103

Referenced by TIFFWriteDirectoryTagLongArray(), and TIFFWriteDirectoryTagLongLong8Array().

◆ TIFFWriteDirectoryTagCheckedRational()

static int TIFFWriteDirectoryTagCheckedRational ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
double  value 
)
static

Definition at line 2184 of file tif_dirwrite.c.

2185 {
2186  static const char module[] = "TIFFWriteDirectoryTagCheckedRational";
2187  uint32 m[2];
2188  assert(sizeof(uint32)==4);
2189  if( value < 0 )
2190  {
2191  TIFFErrorExt(tif->tif_clientdata,module,"Negative value is illegal");
2192  return 0;
2193  }
2194  else if( value != value )
2195  {
2196  TIFFErrorExt(tif->tif_clientdata,module,"Not-a-number value is illegal");
2197  return 0;
2198  }
2199  else if (value==0.0)
2200  {
2201  m[0]=0;
2202  m[1]=1;
2203  }
2204  else if (value <= 0xFFFFFFFFU && value==(double)(uint32)value)
2205  {
2206  m[0]=(uint32)value;
2207  m[1]=1;
2208  }
2209  else if (value<1.0)
2210  {
2211  m[0]=(uint32)(value*0xFFFFFFFF);
2212  m[1]=0xFFFFFFFF;
2213  }
2214  else
2215  {
2216  m[0]=0xFFFFFFFF;
2217  m[1]=(uint32)(0xFFFFFFFF/value);
2218  }
2219  if (tif->tif_flags&TIFF_SWAB)
2220  {
2221  TIFFSwabLong(&m[0]);
2222  TIFFSwabLong(&m[1]);
2223  }
2224  return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_RATIONAL,1,8,&m[0]));
2225 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
const GLfloat * m
Definition: glext.h:10848
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45

Referenced by TIFFWriteDirectoryTagRational().

◆ TIFFWriteDirectoryTagCheckedRationalArray()

static int TIFFWriteDirectoryTagCheckedRationalArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float *  value 
)
static

Definition at line 2228 of file tif_dirwrite.c.

2229 {
2230  static const char module[] = "TIFFWriteDirectoryTagCheckedRationalArray";
2231  uint32* m;
2232  float* na;
2233  uint32* nb;
2234  uint32 nc;
2235  int o;
2236  assert(sizeof(uint32)==4);
2237  m=_TIFFmalloc(count*2*sizeof(uint32));
2238  if (m==NULL)
2239  {
2240  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
2241  return(0);
2242  }
2243  for (na=value, nb=m, nc=0; nc<count; na++, nb+=2, nc++)
2244  {
2245  if (*na<=0.0 || *na != *na)
2246  {
2247  nb[0]=0;
2248  nb[1]=1;
2249  }
2250  else if (*na >= 0 && *na <= (float)0xFFFFFFFFU &&
2251  *na==(float)(uint32)(*na))
2252  {
2253  nb[0]=(uint32)(*na);
2254  nb[1]=1;
2255  }
2256  else if (*na<1.0)
2257  {
2258  nb[0]=(uint32)((double)(*na)*0xFFFFFFFF);
2259  nb[1]=0xFFFFFFFF;
2260  }
2261  else
2262  {
2263  nb[0]=0xFFFFFFFF;
2264  nb[1]=(uint32)((double)0xFFFFFFFF/(*na));
2265  }
2266  }
2267  if (tif->tif_flags&TIFF_SWAB)
2270  _TIFFfree(m);
2271  return(o);
2272 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
const GLfloat * m
Definition: glext.h:10848
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
void _TIFFfree(void *p)
Definition: tif_unix.c:326

Referenced by TIFFWriteDirectoryTagRationalArray().

◆ TIFFWriteDirectoryTagCheckedSbyteArray()

static int TIFFWriteDirectoryTagCheckedSbyteArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int8 value 
)
static

Definition at line 2027 of file tif_dirwrite.c.

2028 {
2029  assert(sizeof(int8)==1);
2031 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
unsigned int dir
Definition: maze.c:112
char int8
Definition: platform.h:10

Referenced by TIFFWriteDirectoryTagSbyteArray().

◆ TIFFWriteDirectoryTagCheckedShort()

static int TIFFWriteDirectoryTagCheckedShort ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint16  value 
)
static

Definition at line 2034 of file tif_dirwrite.c.

2035 {
2036  uint16 m;
2037  assert(sizeof(uint16)==2);
2038  m=value;
2039  if (tif->tif_flags&TIFF_SWAB)
2040  TIFFSwabShort(&m);
2041  return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SHORT,1,2,&m));
2042 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
const GLfloat * m
Definition: glext.h:10848
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:34
GLsizei const GLfloat * value
Definition: glext.h:6069
unsigned short uint16
Definition: types.h:30

Referenced by TIFFWriteDirectoryTagShort(), and TIFFWriteDirectoryTagShortLong().

◆ TIFFWriteDirectoryTagCheckedShortArray()

static int TIFFWriteDirectoryTagCheckedShortArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint16 value 
)
static

Definition at line 2045 of file tif_dirwrite.c.

2046 {
2047  assert(count<0x80000000);
2048  assert(sizeof(uint16)==2);
2049  if (tif->tif_flags&TIFF_SWAB)
2052 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
void TIFFSwabArrayOfShort(register uint16 *wp, tmsize_t n)
Definition: tif_swab.c:71
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
unsigned short uint16
Definition: types.h:30

Referenced by TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagShortArray(), TIFFWriteDirectoryTagShortPerSample(), and TIFFWriteDirectoryTagTransferfunction().

◆ TIFFWriteDirectoryTagCheckedSlong8Array()

static int TIFFWriteDirectoryTagCheckedSlong8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int64 value 
)
static

Definition at line 2170 of file tif_dirwrite.c.

2171 {
2172  assert(count<0x20000000);
2173  assert(sizeof(int64)==8);
2174  if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
2175  TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedSlong8Array","SLONG8 not allowed for ClassicTIFF");
2176  return(0);
2177  }
2178  if (tif->tif_flags&TIFF_SWAB)
2181 }
unsigned long long uint64
Definition: platform.h:18
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
long long int64
Definition: platform.h:13
#define TIFF_BIGTIFF
Definition: tiffiop.h:125
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
void TIFFSwabArrayOfLong8(register uint64 *lp, tmsize_t n)
Definition: tif_swab.c:120

Referenced by TIFFWriteDirectoryTagSlong8Array().

◆ TIFFWriteDirectoryTagCheckedSlongArray()

static int TIFFWriteDirectoryTagCheckedSlongArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int32 value 
)
static

Definition at line 2112 of file tif_dirwrite.c.

2113 {
2114  assert(count<0x40000000);
2115  assert(sizeof(int32)==4);
2116  if (tif->tif_flags&TIFF_SWAB)
2119 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
long int32
Definition: platform.h:12

Referenced by TIFFWriteDirectoryTagSlongArray().

◆ TIFFWriteDirectoryTagCheckedSrationalArray()

static int TIFFWriteDirectoryTagCheckedSrationalArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float *  value 
)
static

Definition at line 2275 of file tif_dirwrite.c.

2276 {
2277  static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalArray";
2278  int32* m;
2279  float* na;
2280  int32* nb;
2281  uint32 nc;
2282  int o;
2283  assert(sizeof(int32)==4);
2284  m=_TIFFmalloc(count*2*sizeof(int32));
2285  if (m==NULL)
2286  {
2287  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
2288  return(0);
2289  }
2290  for (na=value, nb=m, nc=0; nc<count; na++, nb+=2, nc++)
2291  {
2292  if (*na<0.0)
2293  {
2294  if (*na==(int32)(*na))
2295  {
2296  nb[0]=(int32)(*na);
2297  nb[1]=1;
2298  }
2299  else if (*na>-1.0)
2300  {
2301  nb[0]=-(int32)((double)(-*na)*0x7FFFFFFF);
2302  nb[1]=0x7FFFFFFF;
2303  }
2304  else
2305  {
2306  nb[0]=-0x7FFFFFFF;
2307  nb[1]=(int32)((double)0x7FFFFFFF/(-*na));
2308  }
2309  }
2310  else
2311  {
2312  if (*na==(int32)(*na))
2313  {
2314  nb[0]=(int32)(*na);
2315  nb[1]=1;
2316  }
2317  else if (*na<1.0)
2318  {
2319  nb[0]=(int32)((double)(*na)*0x7FFFFFFF);
2320  nb[1]=0x7FFFFFFF;
2321  }
2322  else
2323  {
2324  nb[0]=0x7FFFFFFF;
2325  nb[1]=(int32)((double)0x7FFFFFFF/(*na));
2326  }
2327  }
2328  }
2329  if (tif->tif_flags&TIFF_SWAB)
2332  _TIFFfree(m);
2333  return(o);
2334 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
const GLfloat * m
Definition: glext.h:10848
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
long int32
Definition: platform.h:12
void _TIFFfree(void *p)
Definition: tif_unix.c:326

Referenced by TIFFWriteDirectoryTagSrationalArray().

◆ TIFFWriteDirectoryTagCheckedSshortArray()

static int TIFFWriteDirectoryTagCheckedSshortArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int16 value 
)
static

Definition at line 2068 of file tif_dirwrite.c.

2069 {
2070  assert(count<0x80000000);
2071  assert(sizeof(int16)==2);
2072  if (tif->tif_flags&TIFF_SWAB)
2075 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
void TIFFSwabArrayOfShort(register uint16 *wp, tmsize_t n)
Definition: tif_swab.c:71
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define TIFF_SWAB
Definition: tiffiop.h:113
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
unsigned short uint16
Definition: types.h:30
short int16
Definition: platform.h:11

Referenced by TIFFWriteDirectoryTagSshortArray().

◆ TIFFWriteDirectoryTagCheckedUndefinedArray()

static int TIFFWriteDirectoryTagCheckedUndefinedArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint8 value 
)
static

Definition at line 1995 of file tif_dirwrite.c.

1996 {
1997  assert(sizeof(uint8)==1);
1999 }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void *data)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
unsigned int dir
Definition: maze.c:112
unsigned char uint8
Definition: types.h:28

Referenced by TIFFWriteDirectoryTagUndefinedArray().

◆ TIFFWriteDirectoryTagColormap()

static int TIFFWriteDirectoryTagColormap ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir 
)
static

Definition at line 1845 of file tif_dirwrite.c.

1846 {
1847  static const char module[] = "TIFFWriteDirectoryTagColormap";
1848  uint32 m;
1849  uint16* n;
1850  int o;
1851  if (dir==NULL)
1852  {
1853  (*ndir)++;
1854  return(1);
1855  }
1856  m=(1<<tif->tif_dir.td_bitspersample);
1857  n=_TIFFmalloc(3*m*sizeof(uint16));
1858  if (n==NULL)
1859  {
1860  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
1861  return(0);
1862  }
1863  _TIFFmemcpy(&n[0],tif->tif_dir.td_colormap[0],m*sizeof(uint16));
1864  _TIFFmemcpy(&n[m],tif->tif_dir.td_colormap[1],m*sizeof(uint16));
1865  _TIFFmemcpy(&n[2*m],tif->tif_dir.td_colormap[2],m*sizeof(uint16));
1867  _TIFFfree(n);
1868  return(o);
1869 }
uint16 td_bitspersample
Definition: tif_dir.h:74
#define TIFFTAG_COLORMAP
Definition: tiff.h:284
unsigned int uint32
Definition: types.h:32
GLdouble n
Definition: glext.h:7729
thandle_t tif_clientdata
Definition: tiffiop.h:191
const GLfloat * m
Definition: glext.h:10848
static int TIFFWriteDirectoryTagCheckedShortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
uint16 * td_colormap[3]
Definition: tif_dir.h:91
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
unsigned short uint16
Definition: types.h:30
TIFFDirectory tif_dir
Definition: tiffiop.h:135
void _TIFFfree(void *p)
Definition: tif_unix.c:326
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagData()

static int TIFFWriteDirectoryTagData ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint16  datatype,
uint32  count,
uint32  datalength,
void data 
)
static

Definition at line 2408 of file tif_dirwrite.c.

2409 {
2410  static const char module[] = "TIFFWriteDirectoryTagData";
2411  uint32 m;
2412  m=0;
2413  while (m<(*ndir))
2414  {
2415  assert(dir[m].tdir_tag!=tag);
2416  if (dir[m].tdir_tag>tag)
2417  break;
2418  m++;
2419  }
2420  if (m<(*ndir))
2421  {
2422  uint32 n;
2423  for (n=*ndir; n>m; n--)
2424  dir[n]=dir[n-1];
2425  }
2426  dir[m].tdir_tag=tag;
2427  dir[m].tdir_type=datatype;
2428  dir[m].tdir_count=count;
2429  dir[m].tdir_offset.toff_long8 = 0;
2430  if (datalength<=((tif->tif_flags&TIFF_BIGTIFF)?0x8U:0x4U))
2431  _TIFFmemcpy(&dir[m].tdir_offset,data,datalength);
2432  else
2433  {
2434  uint64 na,nb;
2435  na=tif->tif_dataoff;
2436  nb=na+datalength;
2437  if (!(tif->tif_flags&TIFF_BIGTIFF))
2438  nb=(uint32)nb;
2439  if ((nb<na)||(nb<datalength))
2440  {
2441  TIFFErrorExt(tif->tif_clientdata,module,"Maximum TIFF file size exceeded");
2442  return(0);
2443  }
2444  if (!SeekOK(tif,na))
2445  {
2446  TIFFErrorExt(tif->tif_clientdata,module,"IO error writing tag data");
2447  return(0);
2448  }
2449  assert(datalength<0x80000000UL);
2450  if (!WriteOK(tif,data,(tmsize_t)datalength))
2451  {
2452  TIFFErrorExt(tif->tif_clientdata,module,"IO error writing tag data");
2453  return(0);
2454  }
2455  tif->tif_dataoff=nb;
2456  if (tif->tif_dataoff&1)
2457  tif->tif_dataoff++;
2458  if (!(tif->tif_flags&TIFF_BIGTIFF))
2459  {
2460  uint32 o;
2461  o=(uint32)na;
2462  if (tif->tif_flags&TIFF_SWAB)
2463  TIFFSwabLong(&o);
2464  _TIFFmemcpy(&dir[m].tdir_offset,&o,4);
2465  }
2466  else
2467  {
2468  dir[m].tdir_offset.toff_long8 = na;
2469  if (tif->tif_flags&TIFF_SWAB)
2470  TIFFSwabLong8(&dir[m].tdir_offset.toff_long8);
2471  }
2472  }
2473  (*ndir)++;
2474  return(1);
2475 }
unsigned long long uint64
Definition: platform.h:18
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:243
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
GLdouble n
Definition: glext.h:7729
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
const GLfloat * m
Definition: glext.h:10848
#define TIFF_BIGTIFF
Definition: tiffiop.h:125
#define TIFF_SWAB
Definition: tiffiop.h:113
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
uint32 tif_flags
Definition: tiffiop.h:106
unsigned int dir
Definition: maze.c:112
uint64 tif_dataoff
Definition: tiffiop.h:147
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:45
#define SeekOK(tif, off)
Definition: tiffiop.h:240
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344
void TIFFSwabLong8(uint64 *lp)
Definition: tif_swab.c:57
char * tag
Definition: main.c:59

Referenced by TIFFWriteDirectoryTagCheckedAscii(), TIFFWriteDirectoryTagCheckedByteArray(), TIFFWriteDirectoryTagCheckedDoubleArray(), TIFFWriteDirectoryTagCheckedFloatArray(), TIFFWriteDirectoryTagCheckedIfd8Array(), TIFFWriteDirectoryTagCheckedIfdArray(), TIFFWriteDirectoryTagCheckedLong(), TIFFWriteDirectoryTagCheckedLong8Array(), TIFFWriteDirectoryTagCheckedLongArray(), TIFFWriteDirectoryTagCheckedRational(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedSbyteArray(), TIFFWriteDirectoryTagCheckedShort(), TIFFWriteDirectoryTagCheckedShortArray(), TIFFWriteDirectoryTagCheckedSlong8Array(), TIFFWriteDirectoryTagCheckedSlongArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagCheckedSshortArray(), and TIFFWriteDirectoryTagCheckedUndefinedArray().

◆ TIFFWriteDirectoryTagDoubleArray()

static int TIFFWriteDirectoryTagDoubleArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
double value 
)
static

Definition at line 1589 of file tif_dirwrite.c.

1590 {
1591  if (dir==NULL)
1592  {
1593  (*ndir)++;
1594  return(1);
1595  }
1597 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagFloatArray()

static int TIFFWriteDirectoryTagFloatArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float *  value 
)
static

Definition at line 1540 of file tif_dirwrite.c.

1541 {
1542  if (dir==NULL)
1543  {
1544  (*ndir)++;
1545  return(1);
1546  }
1548 }
static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagIfdArray()

static int TIFFWriteDirectoryTagIfdArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint32 value 
)
static

Definition at line 1627 of file tif_dirwrite.c.

1628 {
1629  if (dir==NULL)
1630  {
1631  (*ndir)++;
1632  return(1);
1633  }
1635 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagIfdIfd8Array()

static int TIFFWriteDirectoryTagIfdIfd8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint64 value 
)
static

Definition at line 1730 of file tif_dirwrite.c.

1731 {
1732  static const char module[] = "TIFFWriteDirectoryTagIfdIfd8Array";
1733  uint64* ma;
1734  uint32 mb;
1735  uint32* p;
1736  uint32* q;
1737  int o;
1738 
1739  /* is this just a counting pass? */
1740  if (dir==NULL)
1741  {
1742  (*ndir)++;
1743  return(1);
1744  }
1745 
1746  /* We always write IFD8 for BigTIFF, no checking needed. */
1747  if( tif->tif_flags&TIFF_BIGTIFF )
1749  tag,count,value);
1750 
1751  /*
1752  ** For classic tiff we want to verify everything is in range for IFD
1753  ** and convert to long format.
1754  */
1755 
1756  p = _TIFFmalloc(count*sizeof(uint32));
1757  if (p==NULL)
1758  {
1759  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
1760  return(0);
1761  }
1762 
1763  for (q=p, ma=value, mb=0; mb<count; ma++, mb++, q++)
1764  {
1765  if (*ma>0xFFFFFFFF)
1766  {
1768  "Attempt to write value larger than 0xFFFFFFFF in Classic TIFF file.");
1769  _TIFFfree(p);
1770  return(0);
1771  }
1772  *q= (uint32)(*ma);
1773  }
1774 
1776  _TIFFfree(p);
1777 
1778  return(o);
1779 }
unsigned long long uint64
Definition: platform.h:18
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
#define TIFF_BIGTIFF
Definition: tiffiop.h:125
static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
uint32 tif_flags
Definition: tiffiop.h:106
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
void _TIFFfree(void *p)
Definition: tif_unix.c:326
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagLong()

static int TIFFWriteDirectoryTagLong ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  value 
)
static

Definition at line 1346 of file tif_dirwrite.c.

1347 {
1348  if (dir==NULL)
1349  {
1350  (*ndir)++;
1351  return(1);
1352  }
1353  return(TIFFWriteDirectoryTagCheckedLong(tif,ndir,dir,tag,value));
1354 }
static int TIFFWriteDirectoryTagCheckedLong(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagLong8Array()

static int TIFFWriteDirectoryTagLong8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint64 value 
)
static

Definition at line 1461 of file tif_dirwrite.c.

1462 {
1463  if (dir==NULL)
1464  {
1465  (*ndir)++;
1466  return(1);
1467  }
1469 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagLongArray()

static int TIFFWriteDirectoryTagLongArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint32 value 
)
static

Definition at line 1357 of file tif_dirwrite.c.

1358 {
1359  if (dir==NULL)
1360  {
1361  (*ndir)++;
1362  return(1);
1363  }
1365 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedLongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagLongLong8Array()

static int TIFFWriteDirectoryTagLongLong8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint64 value 
)
static

Definition at line 1672 of file tif_dirwrite.c.

1673 {
1674  static const char module[] = "TIFFWriteDirectoryTagLongLong8Array";
1675  uint64* ma;
1676  uint32 mb;
1677  uint32* p;
1678  uint32* q;
1679  int o;
1680 
1681  /* is this just a counting pass? */
1682  if (dir==NULL)
1683  {
1684  (*ndir)++;
1685  return(1);
1686  }
1687 
1688  /* We always write LONG8 for BigTIFF, no checking needed. */
1689  if( tif->tif_flags&TIFF_BIGTIFF )
1691  tag,count,value);
1692 
1693  /*
1694  ** For classic tiff we want to verify everything is in range for LONG
1695  ** and convert to long format.
1696  */
1697 
1698  p = _TIFFmalloc(count*sizeof(uint32));
1699  if (p==NULL)
1700  {
1701  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
1702  return(0);
1703  }
1704 
1705  for (q=p, ma=value, mb=0; mb<count; ma++, mb++, q++)
1706  {
1707  if (*ma>0xFFFFFFFF)
1708  {
1710  "Attempt to write value larger than 0xFFFFFFFF in Classic TIFF file.");
1711  _TIFFfree(p);
1712  return(0);
1713  }
1714  *q= (uint32)(*ma);
1715  }
1716 
1718  _TIFFfree(p);
1719 
1720  return(o);
1721 }
unsigned long long uint64
Definition: platform.h:18
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
#define TIFF_BIGTIFF
Definition: tiffiop.h:125
uint32 tif_flags
Definition: tiffiop.h:106
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint64 *value)
void _TIFFfree(void *p)
Definition: tif_unix.c:326
GLfloat GLfloat p
Definition: glext.h:8902
static int TIFFWriteDirectoryTagCheckedLongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagRational()

static int TIFFWriteDirectoryTagRational ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
double  value 
)
static

Definition at line 1496 of file tif_dirwrite.c.

1497 {
1498  if (dir==NULL)
1499  {
1500  (*ndir)++;
1501  return(1);
1502  }
1504 }
Definition: ecma_167.h:138
static int TIFFWriteDirectoryTagCheckedRational(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, double value)
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagRationalArray()

static int TIFFWriteDirectoryTagRationalArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float *  value 
)
static

Definition at line 1507 of file tif_dirwrite.c.

1508 {
1509  if (dir==NULL)
1510  {
1511  (*ndir)++;
1512  return(1);
1513  }
1515 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagSampleformatArray()

static int TIFFWriteDirectoryTagSampleformatArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
double value 
)
static

Definition at line 1013 of file tif_dirwrite.c.

1014 {
1015  static const char module[] = "TIFFWriteDirectoryTagSampleformatArray";
1016  void* conv;
1017  uint32 i;
1018  int ok;
1019  conv = _TIFFmalloc(count*sizeof(double));
1020  if (conv == NULL)
1021  {
1022  TIFFErrorExt(tif->tif_clientdata, module, "Out of memory");
1023  return (0);
1024  }
1025 
1026  switch (tif->tif_dir.td_sampleformat)
1027  {
1028  case SAMPLEFORMAT_IEEEFP:
1029  if (tif->tif_dir.td_bitspersample<=32)
1030  {
1031  for (i = 0; i < count; ++i)
1032  ((float*)conv)[i] = TIFFClampDoubleToFloat(value[i]);
1033  ok = TIFFWriteDirectoryTagFloatArray(tif,ndir,dir,tag,count,(float*)conv);
1034  }
1035  else
1036  {
1038  }
1039  break;
1040  case SAMPLEFORMAT_INT:
1041  if (tif->tif_dir.td_bitspersample<=8)
1042  {
1043  for (i = 0; i < count; ++i)
1044  ((int8*)conv)[i] = TIFFClampDoubleToInt8(value[i]);
1045  ok = TIFFWriteDirectoryTagSbyteArray(tif,ndir,dir,tag,count,(int8*)conv);
1046  }
1047  else if (tif->tif_dir.td_bitspersample<=16)
1048  {
1049  for (i = 0; i < count; ++i)
1050  ((int16*)conv)[i] = TIFFClampDoubleToInt16(value[i]);
1052  }
1053  else
1054  {
1055  for (i = 0; i < count; ++i)
1056  ((int32*)conv)[i] = TIFFClampDoubleToInt32(value[i]);
1057  ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32*)conv);
1058  }
1059  break;
1060  case SAMPLEFORMAT_UINT:
1061  if (tif->tif_dir.td_bitspersample<=8)
1062  {
1063  for (i = 0; i < count; ++i)
1064  ((uint8*)conv)[i] = TIFFClampDoubleToUInt8(value[i]);
1065  ok = TIFFWriteDirectoryTagByteArray(tif,ndir,dir,tag,count,(uint8*)conv);
1066  }
1067  else if (tif->tif_dir.td_bitspersample<=16)
1068  {
1069  for (i = 0; i < count; ++i)
1070  ((uint16*)conv)[i] = TIFFClampDoubleToUInt16(value[i]);
1072  }
1073  else
1074  {
1075  for (i = 0; i < count; ++i)
1076  ((uint32*)conv)[i] = TIFFClampDoubleToUInt32(value[i]);
1077  ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32*)conv);
1078  }
1079  break;
1080  default:
1081  ok = 0;
1082  }
1083 
1084  _TIFFfree(conv);
1085  return (ok);
1086 }
static uint16 TIFFClampDoubleToUInt16(double val)
Definition: tif_dirwrite.c:994
uint16 td_bitspersample
Definition: tif_dir.h:74
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
static int32 TIFFClampDoubleToInt32(double val)
Definition: tif_dirwrite.c:976
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
#define SAMPLEFORMAT_INT
Definition: tiff.h:310
static int TIFFWriteDirectoryTagShortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
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
smooth NULL
Definition: ftsmooth.c:416
static uint32 TIFFClampDoubleToUInt32(double val)
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagSshortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int16 *value)
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
static uint8 TIFFClampDoubleToUInt8(double val)
Definition: tif_dirwrite.c:985
static int TIFFWriteDirectoryTagByteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint8 *value)
#define SAMPLEFORMAT_UINT
Definition: tiff.h:309
#define SAMPLEFORMAT_IEEEFP
Definition: tiff.h:311
unsigned char uint8
Definition: types.h:28
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
static int8 TIFFClampDoubleToInt8(double val)
Definition: tif_dirwrite.c:958
uint16 td_sampleformat
Definition: tif_dir.h:75
static int TIFFWriteDirectoryTagFloatArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)
static int TIFFWriteDirectoryTagLongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint32 *value)
unsigned short uint16
Definition: types.h:30
short int16
Definition: platform.h:11
#define ok(value,...)
Definition: atltest.h:57
TIFFDirectory tif_dir
Definition: tiffiop.h:135
static int TIFFWriteDirectoryTagSbyteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int8 *value)
static int16 TIFFClampDoubleToInt16(double val)
Definition: tif_dirwrite.c:967
long int32
Definition: platform.h:12
static float TIFFClampDoubleToFloat(double val)
Definition: tif_dirwrite.c:949
void _TIFFfree(void *p)
Definition: tif_unix.c:326
char int8
Definition: platform.h:10
static int TIFFWriteDirectoryTagDoubleArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, double *value)
static int TIFFWriteDirectoryTagSlongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int32 *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagSbyteArray()

static int TIFFWriteDirectoryTagSbyteArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int8 value 
)
static

Definition at line 1207 of file tif_dirwrite.c.

1208 {
1209  if (dir==NULL)
1210  {
1211  (*ndir)++;
1212  return(1);
1213  }
1215 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int8 *value)

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagShort()

static int TIFFWriteDirectoryTagShort ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint16  value 
)
static

Definition at line 1246 of file tif_dirwrite.c.

1247 {
1248  if (dir==NULL)
1249  {
1250  (*ndir)++;
1251  return(1);
1252  }
1253  return(TIFFWriteDirectoryTagCheckedShort(tif,ndir,dir,tag,value));
1254 }
Definition: ecma_167.h:138
static int TIFFWriteDirectoryTagCheckedShort(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagShortArray()

static int TIFFWriteDirectoryTagShortArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
uint16 value 
)
static

Definition at line 1257 of file tif_dirwrite.c.

1258 {
1259  if (dir==NULL)
1260  {
1261  (*ndir)++;
1262  return(1);
1263  }
1265 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
static int TIFFWriteDirectoryTagCheckedShortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagShortLong()

static int TIFFWriteDirectoryTagShortLong ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  value 
)
static

Definition at line 1651 of file tif_dirwrite.c.

1652 {
1653  if (dir==NULL)
1654  {
1655  (*ndir)++;
1656  return(1);
1657  }
1658  if (value<=0xFFFF)
1660  else
1661  return(TIFFWriteDirectoryTagCheckedLong(tif,ndir,dir,tag,value));
1662 }
static int TIFFWriteDirectoryTagCheckedLong(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 value)
Definition: ecma_167.h:138
static int TIFFWriteDirectoryTagCheckedShort(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint16 value)
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
unsigned short uint16
Definition: types.h:30

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagShortPerSample()

static int TIFFWriteDirectoryTagShortPerSample ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint16  value 
)
static

Definition at line 1268 of file tif_dirwrite.c.

1269 {
1270  static const char module[] = "TIFFWriteDirectoryTagShortPerSample";
1271  uint16* m;
1272  uint16* na;
1273  uint16 nb;
1274  int o;
1275  if (dir==NULL)
1276  {
1277  (*ndir)++;
1278  return(1);
1279  }
1281  if (m==NULL)
1282  {
1283  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
1284  return(0);
1285  }
1286  for (na=m, nb=0; nb<tif->tif_dir.td_samplesperpixel; na++, nb++)
1287  *na=value;
1289  _TIFFfree(m);
1290  return(o);
1291 }
Definition: ecma_167.h:138
thandle_t tif_clientdata
Definition: tiffiop.h:191
const GLfloat * m
Definition: glext.h:10848
static int TIFFWriteDirectoryTagCheckedShortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, uint16 *value)
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
unsigned short uint16
Definition: types.h:30
TIFFDirectory tif_dir
Definition: tiffiop.h:135
uint16 td_samplesperpixel
Definition: tif_dir.h:81
void _TIFFfree(void *p)
Definition: tif_unix.c:326

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagSlong8Array()

static int TIFFWriteDirectoryTagSlong8Array ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int64 value 
)
static

Definition at line 1485 of file tif_dirwrite.c.

1486 {
1487  if (dir==NULL)
1488  {
1489  (*ndir)++;
1490  return(1);
1491  }
1493 }
static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int64 *value)
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagSlongArray()

static int TIFFWriteDirectoryTagSlongArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int32 value 
)
static

Definition at line 1409 of file tif_dirwrite.c.

1410 {
1411  if (dir==NULL)
1412  {
1413  (*ndir)++;
1414  return(1);
1415  }
1417 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int32 *value)

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagSrationalArray()

static int TIFFWriteDirectoryTagSrationalArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
float *  value 
)
static

Definition at line 1518 of file tif_dirwrite.c.

1519 {
1520  if (dir==NULL)
1521  {
1522  (*ndir)++;
1523  return(1);
1524  }
1526 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, float *value)

Referenced by TIFFWriteDirectorySec().

◆ TIFFWriteDirectoryTagSshortArray()

static int TIFFWriteDirectoryTagSshortArray ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir,
uint16  tag,
uint32  count,
int16 value 
)
static

Definition at line 1307 of file tif_dirwrite.c.

1308 {
1309  if (dir==NULL)
1310  {
1311  (*ndir)++;
1312  return(1);
1313  }
1315 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
Definition: ecma_167.h:138
static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF *tif, uint32 *ndir, TIFFDirEntry *dir, uint16 tag, uint32 count, int16 *value)
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112

Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().

◆ TIFFWriteDirectoryTagSubifd()

static int TIFFWriteDirectoryTagSubifd ( TIFF tif,
uint32 ndir,
TIFFDirEntry dir 
)
static

Definition at line 1923 of file tif_dirwrite.c.

1924 {
1925  static const char module[] = "TIFFWriteDirectoryTagSubifd";
1926  uint64 m;
1927  int n;
1928  if (tif->tif_dir.td_nsubifd==0)
1929  return(1);
1930  if (dir==NULL)
1931  {
1932  (*ndir)++;
1933  return(1);
1934  }
1935  m=tif->tif_dataoff;
1936  if (!(tif->tif_flags&TIFF_BIGTIFF))
1937  {
1938  uint32* o;
1939  uint64* pa;
1940  uint32* pb;
1941  uint16 p;
1942  o=_TIFFmalloc(tif->tif_dir.td_nsubifd*sizeof(uint32));
1943  if (o==NULL)
1944  {
1945  TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
1946  return(0);
1947  }
1948  pa=tif->tif_dir.td_subifd;
1949  pb=o;
1950  for (p=0; p < tif->tif_dir.td_nsubifd; p++)
1951  {
1952  assert(pa != 0);
1953 
1954  /* Could happen if an classicTIFF has a SubIFD of type LONG8 (which is illegal) */
1955  if( *pa > 0xFFFFFFFFUL)
1956  {
1957  TIFFErrorExt(tif->tif_clientdata,module,"Illegal value for SubIFD tag");
1958  _TIFFfree(o);
1959  return(0);
1960  }
1961  *pb++=(uint32)(*pa++);
1962  }
1964  _TIFFfree(o);
1965  }
1966  else
1968  if (!n)
1969  return(0);
1970  /*
1971  * Total hack: if this directory includes a SubIFD
1972  * tag then force the next <n> directories to be
1973  * written as ``sub directories'' of this one. This
1974  * is used to write things like thumbnails and
1975  * image masks that one wants to keep out of the
1976  * normal directory linkage access mechanism.
1977  */
1978  tif->tif_flags|=TIFF_INSUBIFD;
1979  tif->tif_nsubifd=tif->tif_dir.td_nsubifd;
1980  if (tif->tif_dir.td_nsubifd==1)
1981  tif->tif_subifdoff=0;
1982  else
1983  tif->tif_subifdoff=