
Thread
2003.11.06 04:30 "[Tiff] TIFFRawStripSize function", by Chris Hanson
As part of what I'm working on, I needed a function to get the size in bytes of a raw strip. I figure that others would find this useful too, so I'm contributing it. I've appended a couple context diffs from the latest CVS, of the libtiff/tiffio.h and libtiff/tif_strip.c files.
-- Chris
Chris Hanson, bDistributed.com, Inc. | Email: cmh@bDistributed.com
Outsourcing Vendor Evaluation | Phone: +1-847-372-3955
Custom Mac OS X Development | Fax: +1-847-589-3738
http://bdistributed.com/ | Personal Email: cmh@mac.com
Index: libtiff/tiffio.h
===================================================================
RCS file: /cvsroot/osrs/libtiff/libtiff/tiffio.h,v
retrieving revision 1.17
diff -c -r1.17 tiffio.h
*** libtiff/tiffio.h 7 Oct 2003 06:19:21 -0000 1.17
--- libtiff/tiffio.h 6 Nov 2003 04:28:43 -0000
***************
*** 244,249 ****
--- 244,250 ----
extern tsize_t TIFFScanlineSize(TIFF*);
extern tsize_t TIFFRasterScanlineSize(TIFF*);
extern tsize_t TIFFStripSize(TIFF*);
+ extern tsize_t TIFFRawStripSize(TIFF* tif, tstrip_t strip);
extern tsize_t TIFFVStripSize(TIFF*, uint32);
extern tsize_t TIFFTileRowSize(TIFF*);
extern tsize_t TIFFTileSize(TIFF*);
Index: libtiff/tif_strip.c
===================================================================
RCS file: /cvsroot/osrs/libtiff/libtiff/tif_strip.c,v
retrieving revision 1.2
diff -c -r1.2 tif_strip.c
*** libtiff/tif_strip.c 31 Jul 2002 21:05:57 -0000 1.2
--- libtiff/tif_strip.c 6 Nov 2003 04:28:43 -0000
***************
*** 112,117 ****
--- 112,136 ----
}
/*
+ * Compute the # bytes in a raw strip.
+ */
+ tsize_t
+ TIFFRawStripSize(TIFF* tif, tstrip_t strip)
+ {
+ TIFFDirectory* td = &tif->tif_dir;
+ tsize_t bytecount = td->td_stripbytecount[strip];
+
+ if (bytecount <= 0) {
+ TIFFError(tif->tif_name,
+ "%lu: Invalid strip byte count, strip %lu",
+ (u_long) bytecount, (u_long) strip);
+ bytecount = (tsize_t) -1;
+ }
+
+ return bytecount;
+ }
+
+ /*
* Compute the # bytes in a (row-aligned) strip.
*
* Note that if RowsPerStrip is larger than the