/* * Compute how many tiles are in an image. */ uint32 TIFFNumberOfTiles(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; uint32 dx = td->td_tilewidth; uint32 dy = td->td_tilelength; uint32 dz = td->td_tiledepth; uint32 ntiles; if (dx == (uint32) -1) dx = td->td_imagewidth; if (dy == (uint32) -1) dy = td->td_imagelength; if (dz == (uint32) -1) dz = td->td_imagedepth; ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 : _TIFFMultiply32(tif, _TIFFMultiply32(tif, TIFFhowmany_32(td->td_imagewidth, dx), TIFFhowmany_32(td->td_imagelength, dy), "TIFFNumberOfTiles"), TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles"); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel, "TIFFNumberOfTiles"); return (ntiles); }
/* * Compute how many strips are in an image. */ uint32 TIFFNumberOfStrips(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; uint32 nstrips; nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 : TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip)); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel, "TIFFNumberOfStrips"); return (nstrips); }
static int initImage(void) { uint32 w, h; if (order) TIFFSetField(tif, TIFFTAG_FILLORDER, order); if (photo != (uint16) -1) TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photo); if (!TIFFRGBAImageBegin(&img, tif, stoponerr, title)) { TIFFError(filelist[fileindex], "%s", title); TIFFClose(tif); tif = NULL; return -1; } /* * Setup the image raster as required. */ h = img.height; w = img.width; if (h > ymax) { w = (int)(w * ((float)ymax / h)); h = ymax; } if (w > xmax) { h = (int)(h * ((float)xmax / w)); w = xmax; } 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); #endif return 0; }
/* * Compute how many strips are in an image. */ uint32 TIFFNumberOfStrips(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; uint32 nstrips; /* If the value was already computed and store in td_nstrips, then return it, since ChopUpSingleUncompressedStrip might have altered and resized the since the td_stripbytecount and td_stripoffset arrays to the new value after the initial affectation of td_nstrips = TIFFNumberOfStrips() in tif_dirread.c ~line 3612. See http://bugzilla.maptools.org/show_bug.cgi?id=2587 */ if( td->td_nstrips ) return td->td_nstrips; nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 : TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip)); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel, "TIFFNumberOfStrips"); return (nstrips); }