]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Tue, 3 Jun 2014 01:09:12 +0000 (01:09 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Tue, 3 Jun 2014 01:09:12 +0000 (01:09 +0000)
coders/tiff.c

index 400f9f267cc20b4680f313b6f664d248687be5da..bab1f76457eaf4ba3567840c63208932e599ee94 100644 (file)
@@ -684,10 +684,10 @@ static void TIFFGetEXIFProperties(TIFF *tiff,Image *image,
     Read EXIF properties.
   */
   offset=0;
-  if (TIFFGetField(tiff,TIFFTAG_EXIFIFD,&offset) == 0)
+  if (TIFFGetField(tiff,TIFFTAG_EXIFIFD,&offset) != 1)
     return;
   directory=TIFFCurrentDirectory(tiff);
-  if (TIFFReadEXIFDirectory(tiff,offset) == 0)
+  if (TIFFReadEXIFDirectory(tiff,offset) != 1)
     {
       directory=TIFFCurrentDirectory(tiff);
       return;
@@ -704,7 +704,7 @@ static void TIFFGetEXIFProperties(TIFF *tiff,Image *image,
           *ascii;
 
         ascii=(char *) NULL;
-        if ((TIFFGetField(tiff,exif_info[i].tag,&ascii,&sans,&sans) != 0) &&
+        if ((TIFFGetField(tiff,exif_info[i].tag,&ascii,&sans,&sans) == 1) &&
             (ascii != (char *) NULL) && (*ascii != '\0'))
           (void) CopyMagickString(value,ascii,MaxTextExtent);
         break;
@@ -716,7 +716,7 @@ static void TIFFGetEXIFProperties(TIFF *tiff,Image *image,
             uint16
               *shorty;
 
-            if (TIFFGetField(tiff,exif_info[i].tag,&sans,&shorty,&sans,&sans) != 0)
+            if (TIFFGetField(tiff,exif_info[i].tag,&sans,&shorty,&sans,&sans) == 1)
               (void) FormatLocaleString(value,MaxTextExtent,"%d",shorty[0]);
           }
         else
@@ -725,7 +725,7 @@ static void TIFFGetEXIFProperties(TIFF *tiff,Image *image,
               shorty;
 
             shorty=0;
-            if (TIFFGetField(tiff,exif_info[i].tag,&shorty,&sans,&sans) != 0)
+            if (TIFFGetField(tiff,exif_info[i].tag,&shorty,&sans,&sans) == 1)
               (void) FormatLocaleString(value,MaxTextExtent,"%d",shorty);
           }
         break;
@@ -736,7 +736,7 @@ static void TIFFGetEXIFProperties(TIFF *tiff,Image *image,
           longy;
 
         longy=0;
-        if (TIFFGetField(tiff,exif_info[i].tag,&longy,&sans,&sans) != 0)
+        if (TIFFGetField(tiff,exif_info[i].tag,&longy,&sans,&sans) == 1)
           (void) FormatLocaleString(value,MaxTextExtent,"%d",longy);
         break;
       }
@@ -747,7 +747,7 @@ static void TIFFGetEXIFProperties(TIFF *tiff,Image *image,
           long8y;
 
         long8y=0;
-        if (TIFFGetField(tiff,exif_info[i].tag,&long8y,&sans,&sans) != 0)
+        if (TIFFGetField(tiff,exif_info[i].tag,&long8y,&sans,&sans) == 1)
           (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
             ((MagickOffsetType) long8y));
         break;
@@ -761,7 +761,7 @@ static void TIFFGetEXIFProperties(TIFF *tiff,Image *image,
           floaty;
 
         floaty=0.0;
-        if (TIFFGetField(tiff,exif_info[i].tag,&floaty,&sans,&sans) != 0)
+        if (TIFFGetField(tiff,exif_info[i].tag,&floaty,&sans,&sans) == 1)
           (void) FormatLocaleString(value,MaxTextExtent,"%g",(double) floaty);
         break;
       }
@@ -771,7 +771,7 @@ static void TIFFGetEXIFProperties(TIFF *tiff,Image *image,
           doubley;
 
         doubley=0.0;
-        if (TIFFGetField(tiff,exif_info[i].tag,&doubley,&sans,&sans) != 0)
+        if (TIFFGetField(tiff,exif_info[i].tag,&doubley,&sans,&sans) == 1)
           (void) FormatLocaleString(value,MaxTextExtent,"%g",doubley);
         break;
       }
@@ -1118,37 +1118,39 @@ RestoreMSCWarning
     (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_SAMPLESPERPIXEL,
       &samples_per_pixel);
     (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units);
-    x_resolution=(float) image->resolution.x;
-    y_resolution=(float) image->resolution.y;
-    (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution);
-    (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution);
-    image->resolution.x=x_resolution;
-    image->resolution.y=y_resolution;
-    x_position=(float) PerceptibleReciprocal(x_resolution)*image->page.x;
-    y_position=(float) PerceptibleReciprocal(y_resolution)*image->page.y;
-    (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position);
-    (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position);
-    image->page.x=(ssize_t) ceil(x_position*x_resolution-0.5);
-    image->page.y=(ssize_t) ceil(y_position*y_resolution-0.5);
-    (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation);
-    image->orientation=(OrientationType) orientation;
-    chromaticity=(float *) NULL;
-    (void) TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity);
-    if (chromaticity != (float *) NULL)
-      {
-        image->chromaticity.white_point.x=chromaticity[0];
-        image->chromaticity.white_point.y=chromaticity[1];
-      }
-    chromaticity=(float *) NULL;
-    (void) TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity);
-    if (chromaticity != (float *) NULL)
-      {
-        image->chromaticity.red_primary.x=chromaticity[0];
-        image->chromaticity.red_primary.y=chromaticity[1];
-        image->chromaticity.green_primary.x=chromaticity[2];
-        image->chromaticity.green_primary.y=chromaticity[3];
-        image->chromaticity.blue_primary.x=chromaticity[4];
-        image->chromaticity.blue_primary.y=chromaticity[5];
+    if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XRESOLUTION,&x_resolution) == 1) &&
+        (TIFFGetFieldDefaulted(tiff,TIFFTAG_YRESOLUTION,&y_resolution) == 1))
+      {
+        image->resolution.x=x_resolution;
+        image->resolution.y=y_resolution;
+      }
+    if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position) == 1) &&
+        (TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position) == 1))
+      {
+        image->page.x=(ssize_t) ceil(x_position*x_resolution-0.5);
+        image->page.y=(ssize_t) ceil(y_position*y_resolution-0.5);
+      }
+    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation) == 1)
+      image->orientation=(OrientationType) orientation;
+    if (TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity) == 1)
+      {
+        if (chromaticity != (float *) NULL)
+          {
+            image->chromaticity.white_point.x=chromaticity[0];
+            image->chromaticity.white_point.y=chromaticity[1];
+          }
+      }
+    if (TIFFGetField(tiff,TIFFTAG_PRIMARYCHROMATICITIES,&chromaticity) == 1)
+      {
+        if (chromaticity != (float *) NULL)
+          {
+            image->chromaticity.red_primary.x=chromaticity[0];
+            image->chromaticity.red_primary.y=chromaticity[1];
+            image->chromaticity.green_primary.x=chromaticity[2];
+            image->chromaticity.green_primary.y=chromaticity[3];
+            image->chromaticity.blue_primary.x=chromaticity[4];
+            image->chromaticity.blue_primary.y=chromaticity[5];
+          }
       }
 #if defined(MAGICKCORE_HAVE_TIFFISCODECCONFIGURED) || (TIFFLIB_VERSION > 20040919)
     if ((compress_tag != COMPRESSION_NONE) &&
@@ -1175,14 +1177,15 @@ RestoreMSCWarning
              horizontal,
              vertical;
 
-           (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YCBCRSUBSAMPLING,
-             &horizontal,&vertical);
-           (void) FormatLocaleString(sampling_factor,MaxTextExtent,"%dx%d",
-             horizontal,vertical);
-           (void) SetImageProperty(image,"jpeg:sampling-factor",
-             sampling_factor,exception);
-           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-             "Sampling Factors: %s",sampling_factor);
+           if (TIFFGetFieldDefaulted(tiff,TIFFTAG_YCBCRSUBSAMPLING,&horizontal,&vertical) == 1)
+             {
+               (void) FormatLocaleString(sampling_factor,MaxTextExtent,"%dx%d",
+                 horizontal,vertical);
+               (void) SetImageProperty(image,"jpeg:sampling-factor",
+                 sampling_factor,exception);
+               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                 "Sampling Factors: %s",sampling_factor);
+             }
          }
 #endif
         break;
@@ -1234,20 +1237,20 @@ RestoreMSCWarning
         break;
     }
     associated_alpha=MagickFalse;
-    extra_samples=0;
-    (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples,
-      &sample_info);
-    if (extra_samples == 0)
+    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_EXTRASAMPLES,&extra_samples,&sample_info) == 1)
       {
-        if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB))
-          image->alpha_trait=BlendPixelTrait;
-      }
-    else
-      for (i=0; i < extra_samples; i++)
-      {
-        image->alpha_trait=BlendPixelTrait;
-        if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA)
-          SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);
+        if (extra_samples == 0)
+          {
+            if ((samples_per_pixel == 4) && (photometric == PHOTOMETRIC_RGB))
+              image->alpha_trait=BlendPixelTrait;
+          }
+        else
+          for (i=0; i < extra_samples; i++)
+          {
+            image->alpha_trait=BlendPixelTrait;
+            if (sample_info[i] == EXTRASAMPLE_ASSOCALPHA)
+              SetQuantumAlphaType(quantum_info,DisassociatedQuantumAlpha);
+          }
       }
     option=GetImageOption(image_info,"tiff:alpha");
     if (option != (const char *) NULL)
@@ -1275,8 +1278,8 @@ RestoreMSCWarning
     if (units == RESUNIT_CENTIMETER)
       image->units=PixelsPerCentimeterResolution;
     value=(unsigned short) image->scene;
-    (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages);
-    image->scene=value;
+    if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&value,&pages) == 1)
+      image->scene=value;
     if (image_info->ping != MagickFalse)
       {
         if (image_info->number_scenes != 0)
@@ -1285,7 +1288,7 @@ RestoreMSCWarning
         goto next_tiff_frame;
       }
     method=ReadGenericMethod;
-    if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) != 0)
+    if (TIFFGetField(tiff,TIFFTAG_ROWSPERSTRIP,&rows_per_strip) == 1)
       {
         char
           value[MaxTextExtent];
@@ -1339,32 +1342,31 @@ RestoreMSCWarning
             /*
               Initialize colormap.
             */
-            red_colormap=(uint16 *) NULL;
-            green_colormap=(uint16 *) NULL;
-            blue_colormap=(uint16 *) NULL;
-            (void) TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,
-              &green_colormap,&blue_colormap);
-            if ((red_colormap != (uint16 *) NULL) &&
-                (green_colormap != (uint16 *) NULL) &&
-                (blue_colormap != (uint16 *) NULL))
+            if (TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,&green_colormap,&blue_colormap) == 1)
               {
-                range=255;  /* might be old style 8-bit colormap */
-                for (i=0; i < (ssize_t) image->colors; i++)
-                  if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) ||
-                      (blue_colormap[i] >= 256))
+                if ((red_colormap != (uint16 *) NULL) &&
+                    (green_colormap != (uint16 *) NULL) &&
+                    (blue_colormap != (uint16 *) NULL))
+                  {
+                    range=255;  /* might be old style 8-bit colormap */
+                    for (i=0; i < (ssize_t) image->colors; i++)
+                      if ((red_colormap[i] >= 256) ||
+                          (green_colormap[i] >= 256) ||
+                          (blue_colormap[i] >= 256))
+                        {
+                          range=65535;
+                          break;
+                        }
+                    for (i=0; i < (ssize_t) image->colors; i++)
                     {
-                      range=65535;
-                      break;
+                      image->colormap[i].red=ClampToQuantum(((double)
+                        QuantumRange*red_colormap[i])/range);
+                      image->colormap[i].green=ClampToQuantum(((double)
+                        QuantumRange*green_colormap[i])/range);
+                      image->colormap[i].blue=ClampToQuantum(((double)
+                        QuantumRange*blue_colormap[i])/range);
                     }
-                for (i=0; i < (ssize_t) image->colors; i++)
-                {
-                  image->colormap[i].red=ClampToQuantum(((double)
-                    QuantumRange*red_colormap[i])/range);
-                  image->colormap[i].green=ClampToQuantum(((double)
-                    QuantumRange*green_colormap[i])/range);
-                  image->colormap[i].blue=ClampToQuantum(((double)
-                    QuantumRange*blue_colormap[i])/range);
-                }
+                  }
               }
           }
         quantum_type=IndexQuantum;
@@ -1610,8 +1612,8 @@ RestoreMSCWarning
         /*
           Convert tiled TIFF image to DirectClass MIFF image.
         */
-        if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) == 0) ||
-            (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) == 0))
+        if ((TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&columns) != 1) ||
+            (TIFFGetField(tiff,TIFFTAG_TILELENGTH,&rows) != 1))
           {
             TIFFClose(tiff);
             ThrowReaderException(CoderError,"ImageIsNotTiled");