#endif
#include "tiffio.h"
+#include "tiffiop.h"
#ifndef HAVE_GETOPT
extern int getopt(int, char**, char*);
if (photo != (uint16) -1)
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photo);
if (!TIFFRGBAImageBegin(&img, tif, stoponerr, title)) {
- TIFFError(filelist[fileindex], title);
+ TIFFError(filelist[fileindex], "%s", title);
TIFFClose(tif);
tif = NULL;
return -1;
w = xmax;
}
- if (w != width || h != height) {
- if (raster != NULL)
- _TIFFfree(raster), raster = NULL;
- raster = (uint32*) _TIFFmalloc(img.width * img.height * sizeof (uint32));
- if (raster == NULL) {
- width = height = 0;
- TIFFError(filelist[fileindex], "No space for raster buffer");
- cleanup_and_exit();
- }
- width = w;
- height = h;
- }
- TIFFRGBAImageGet(&img, raster, img.width, img.height);
+ if (w != width || h != height) {
+ uint32 rastersize =
+ _TIFFMultiply32(tif, img.width, img.height, "allocating raster buffer");
+ if (raster != NULL)
+ _TIFFfree(raster), raster = NULL;
+ raster = (uint32*) _TIFFCheckMalloc(tif, rastersize, sizeof (uint32),
+ "allocating raster buffer");
+ if (raster == NULL) {
+ width = height = 0;
+ TIFFError(filelist[fileindex], "No space for raster buffer");
+ cleanup_and_exit();
+ }
+ width = w;
+ height = h;
+ }
+ TIFFRGBAImageGet(&img, raster, img.width, img.height);
#if HOST_BIGENDIAN
- TIFFSwabArrayOfLong(raster,img.width*img.height);
+ TIFFSwabArrayOfLong(raster,img.width*img.height);
#endif
return 0;
}
}
/* vim: set ts=8 sts=8 sw=8 noet: */
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 8
+ * fill-column: 78
+ * End:
+ */