Author: mlytwyn
Date: Wed Apr  6 20:21:29 2016
New Revision: 39632

URL: http://svn.gna.org/viewcvs/gnustep?rev=39632&view=rev
Log:
Merge with revision 39619 of GUI main branch

Modified:
    libs/gui/branches/gnustep_testplant_branch/Source/tiff.m

Modified: libs/gui/branches/gnustep_testplant_branch/Source/tiff.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/tiff.m?rev=39632&r1=39631&r2=39632&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/tiff.m    (original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/tiff.m    Wed Apr  6 
20:21:29 2016
@@ -152,9 +152,10 @@
     case SEEK_SET: chand->position = offset; break;
     case SEEK_CUR: chand->position += offset; break;
     case SEEK_END: 
+      // FIXME: Not sure whether this check is correct
       if (offset > 0 && chand->mode == 'r')
         return 0;
-      chand->position += offset; break;
+      chand->position = chand->size - ((chand->size > 0) ? 1 : 0) + offset;
       break;
     }
   return chand->position;
@@ -260,6 +261,7 @@
     {
       dircount++;
     } 
+  TIFFSetDirectory(image, 0);
   return dircount;
 }
 
@@ -472,17 +474,25 @@
 NSTiffWrite(TIFF *image, NSTiffInfo *info, unsigned char *data)
 {
   void*        buf = (void*)data;
-  uint16        sample_info[2];
+  uint16        sample_info[1];
   int          i;
   unsigned int         row;
   int           error = 0;
   tmsize_t      scan_line_size;
 
+  if (info->numImages > 1)
+    {
+      /* Set the page number */
+      TIFFSetField(image, TIFFTAG_PAGENUMBER, info->imageNumber, 
info->numImages);
+    }
+
   TIFFSetField(image, TIFFTAG_IMAGEWIDTH, info->width);
   TIFFSetField(image, TIFFTAG_IMAGELENGTH, info->height);
   TIFFSetField(image, TIFFTAG_COMPRESSION, info->compression);
   if (info->compression == COMPRESSION_JPEG)
-    TIFFSetField(image, TIFFTAG_JPEGQUALITY, info->quality);
+    {
+      TIFFSetField(image, TIFFTAG_JPEGQUALITY, info->quality);
+    }
   TIFFSetField(image, TIFFTAG_SUBFILETYPE, info->subfileType);
   TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, info->bitsPerSample);
   TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, info->samplesPerPixel);
@@ -549,7 +559,11 @@
        return -1;
        break;
     }
-    
+
+  // Write out the directory as there may be more images comming
+  TIFFWriteDirectory(image);
+  TIFFFlush(image);
+
   return error;
 }
 


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to