本文整理汇总了C++中TIFFTileSize函数的典型用法代码示例。如果您正苦于以下问题:C++ TIFFTileSize函数的具体用法?C++ TIFFTileSize怎么用?C++ TIFFTileSize使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIFFTileSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TileBasedXform
static
int TileBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
{
tsize_t BufSizeIn = TIFFTileSize(in);
tsize_t BufSizeOut = TIFFTileSize(out);
unsigned char *BufferIn, *BufferOut;
ttile_t i, TileCount = TIFFNumberOfTiles(in) / nPlanes;
uint32 tw, tl;
int PixelCount, j;
TIFFGetFieldDefaulted(in, TIFFTAG_TILEWIDTH, &tw);
TIFFGetFieldDefaulted(in, TIFFTAG_TILELENGTH, &tl);
PixelCount = (int) tw * tl;
BufferIn = (unsigned char *) _TIFFmalloc(BufSizeIn * nPlanes);
if (!BufferIn) OutOfMem(BufSizeIn * nPlanes);
BufferOut = (unsigned char *) _TIFFmalloc(BufSizeOut * nPlanes);
if (!BufferOut) OutOfMem(BufSizeOut * nPlanes);
for (i = 0; i < TileCount; i++) {
for (j=0; j < nPlanes; j++) {
if (TIFFReadEncodedTile(in, i + (j* TileCount),
BufferIn + (j*BufSizeIn), BufSizeIn) < 0) goto cleanup;
}
cmsDoTransform(hXForm, BufferIn, BufferOut, PixelCount);
for (j=0; j < nPlanes; j++) {
if (TIFFWriteEncodedTile(out, i + (j*TileCount),
BufferOut + (j*BufSizeOut), BufSizeOut) < 0) goto cleanup;
}
}
_TIFFfree(BufferIn);
_TIFFfree(BufferOut);
return 1;
cleanup:
_TIFFfree(BufferIn);
_TIFFfree(BufferOut);
return 0;
}
示例2: TIFFBufferSetup
/*
* Setup the raw data buffer used for encoding.
*/
static int
TIFFBufferSetup(TIFF* tif, const char* module)
{
tsize_t size;
if (isTiled(tif))
tif->tif_tilesize = size = TIFFTileSize(tif);
else
tif->tif_scanlinesize = size = TIFFScanlineSize(tif);
/*
* Make raw data buffer at least 8K
*/
if (size < 8*1024)
size = 8*1024;
tif->tif_rawdata = (tidata_t)_TIFFmalloc(size);
if (tif->tif_rawdata == NULL) {
TIFFError(module, "%s: No space for output buffer",
tif->tif_name);
return (0);
}
tif->tif_flags |= TIFF_MYBUFFER;
tif->tif_rawdatasize = size;
tif->tif_rawcc = 0;
tif->tif_rawcp = tif->tif_rawdata;
return (1);
}
示例3: cpTiles
static int
cpTiles(TIFF* in, TIFF* out)
{
tsize_t bufsize = TIFFTileSize(in);
unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize);
if (buf) {
ttile_t t, nt = TIFFNumberOfTiles(in);
tsize_t *bytecounts;
TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts);
for (t = 0; t < nt; t++) {
if (bytecounts[t] > bufsize) {
buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[t]);
if (!buf)
goto bad;
bufsize = bytecounts[t];
}
if (TIFFReadRawTile(in, t, buf, bytecounts[t]) < 0 ||
TIFFWriteRawTile(out, t, buf, bytecounts[t]) < 0) {
_TIFFfree(buf);
return 0;
}
}
_TIFFfree(buf);
return 1;
}
bad:
TIFFError(TIFFFileName(in),
"Can't allocate space for tile buffer.");
return (0);
}
示例4: tiletoimg
static bool tiletoimg(img *d, TIFF *T, bool c, int e, int k)
{
int n = 1 << (d->n - e);
int m = 1 << d->m;
int s = 1 << k;
int y = 0;
int x = 0;
float *p;
if ((p = (float *) malloc(TIFFTileSize(T))))
{
for (y = 0; y < n; y += s)
for (x = 0; x < m; x += s)
{
if (TIFFReadTile(T, p, x, y, 0, 0) == -1)
return false;
if (c) tiletoimgz(y, x, d, s, p);
else tiletoimgr(y, x, d, s, p);
if (e)
{
reverse(p, c ? d->p * 2 : d->p, s * s);
if (c) tiletoimgz(2 * n - y - s, m - x - s, d, s, p);
else tiletoimgr(2 * n - y - s, m - x - s, d, s, p);
}
}
free(p);
}
return (y == n && x == m);
}
示例5: read_tile_from_file
static void read_tile_from_file(struct tiff_tile *t, char *filename, int tidx)
{
TIFF *tif = tiffopen_fancy(filename, "r");
if (!tif) fail("could not open TIFF file \"%s\" for reading", filename);
uint32_t w, h;
uint16_t spp, bps, fmt, planarity;
TIFFGetFieldDefaulted(tif, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetFieldDefaulted(tif, TIFFTAG_IMAGELENGTH, &h);
TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &spp);
TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bps);
TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLEFORMAT, &fmt);
TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarity);
t->spp = spp;
t->bps = bps;
t->fmt = fmt;
t->broken = false;
if (planarity != PLANARCONFIG_CONTIG)
fail("broken pixels not supported yet");
if (TIFFIsTiled(tif)) {
int nt = TIFFNumberOfTiles(tif);
if (tidx < 0 || tidx >= nt)
fail("bad tile index %d", tidx);
t->w = tiff_tilewidth(tif);;
t->h = tiff_tilelength(tif);
int ii[2];
tiff_tile_corner(ii, tif, tidx);
//int ii = tw*i;
//int jj = th*j;
int tbytes = TIFFTileSize(tif);
t->data = xmalloc(tbytes);
memset(t->data, 0, tbytes);
int r = my_readtile(tif, t->data, ii[0], ii[1], 0, 0);
if (r != tbytes) fail("could not read tile");
} else { // not tiled, read the whole image into 0th tile
read_scanlines(t, tif);
}
TIFFClose(tif);
}
示例6: my_readtile
static tsize_t my_readtile(TIFF *tif, tdata_t buf,
uint32 x, uint32 y, uint32 z, tsample_t sample)
{
tsize_t r = TIFFReadTile(tif, buf, x, y, z, sample);
if (r == -1) memset(buf, 0, r = TIFFTileSize(tif));
return r;
}
示例7: cpTiles
static int
cpTiles(TIFF* in, TIFF* out)
{
tmsize_t bufsize = TIFFTileSize(in);
unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize);
if (buf) {
ttile_t t, nt = TIFFNumberOfTiles(in);
uint64 *bytecounts;
TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts);
for (t = 0; t < nt; t++) {
if (bytecounts[t] > (uint64) bufsize) {
buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[t]);
if (!buf)
return (0);
bufsize = (tmsize_t)bytecounts[t];
}
if (TIFFReadRawTile(in, t, buf, (tmsize_t)bytecounts[t]) < 0 ||
TIFFWriteRawTile(out, t, buf, (tmsize_t)bytecounts[t]) < 0) {
_TIFFfree(buf);
return (0);
}
}
_TIFFfree(buf);
return (1);
}
return (0);
}
示例8: gtTileSeparate
/*
* Get an tile-organized image that has
* SamplesPerPixel > 1
* PlanarConfiguration separated
* We assume that all such images are RGB.
*/
static int
gtTileSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
{
TIFF* tif = img->tif;
ImageIterTileSeparateRoutine callback = img->callback.separate;
uint16 orientation;
uint32 col, row;
uint32 tw, th;
u_char* buf;
u_char* r;
u_char* g;
u_char* b;
u_char* a;
tsize_t tilesize;
int32 fromskew;
int alpha = img->alpha;
uint32 nrow;
tilesize = TIFFTileSize(tif);
buf = (u_char*) _TIFFmalloc(4*tilesize);
if (buf == 0) {
TIFFError(TIFFFileName(tif), "No space for tile buffer");
return (0);
}
r = buf;
g = r + tilesize;
b = g + tilesize;
a = b + tilesize;
if (!alpha)
memset(a, 0xff, tilesize);
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
orientation = img->orientation;
for (row = 0; row < h; row += th) {
nrow = (row + th > h ? h - row : th);
for (col = 0; col < w; col += tw) {
if (TIFFReadTile(tif, r, col, row,0,0) < 0 && img->stoponerr)
break;
if (TIFFReadTile(tif, g, col, row,0,1) < 0 && img->stoponerr)
break;
if (TIFFReadTile(tif, b, col, row,0,2) < 0 && img->stoponerr)
break;
if (alpha && TIFFReadTile(tif,a,col,row,0,3) < 0 && img->stoponerr)
break;
if (col + tw > w) {
/*
* Tile is clipped horizontally. Calculate
* visible portion and skewing factors.
*/
uint32 npix = w - col;
fromskew = tw - npix;
(*callback)(img, udata, col, row, npix, nrow, fromskew, r, g, b, a);
} else {
(*callback)(img, udata, col, row, tw, nrow, 0, r, g, b, a);
}
}
}
_TIFFfree(buf);
return (1);
}
示例9: cpTiles
static int
cpTiles(TIFF* in, TIFF* out)
{
tsize_t bufsize = TIFFTileSize(in);
unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize);
if (buf) {
ttile_t t, nt = TIFFNumberOfTiles(in);
uint32 *bytecounts;
if (!TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts)) {
fprintf(stderr, "tiffsplit: tile byte counts are missing\n");
return (0);
}
for (t = 0; t < nt; t++) {
if (bytecounts[t] > (uint32) bufsize) {
buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[t]);
if (!buf)
return (0);
bufsize = bytecounts[t];
}
if (TIFFReadRawTile(in, t, buf, bytecounts[t]) < 0 ||
TIFFWriteRawTile(out, t, buf, bytecounts[t]) < 0) {
_TIFFfree(buf);
return (0);
}
}
_TIFFfree(buf);
return (1);
}
return (0);
}
示例10: TIFFWriteCheck
/*
* Verify file is writable and that the directory
* information is setup properly. In doing the latter
* we also "freeze" the state of the directory so
* that important information is not changed.
*/
int
TIFFWriteCheck(TIFF* tif, int tiles, const char* module)
{
if (tif->tif_mode == O_RDONLY) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: File not open for writing",
tif->tif_name);
return (0);
}
if (tiles ^ isTiled(tif)) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, tiles ?
"Can not write tiles to a stripped image" :
"Can not write scanlines to a tiled image");
return (0);
}
/*
* On the first write verify all the required information
* has been setup and initialize any data structures that
* had to wait until directory information was set.
* Note that a lot of our work is assumed to remain valid
* because we disallow any of the important parameters
* from changing after we start writing (i.e. once
* TIFF_BEENWRITING is set, TIFFSetField will only allow
* the image's length to be changed).
*/
if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Must set \"ImageWidth\" before writing data",
tif->tif_name);
return (0);
}
if (tif->tif_dir.td_samplesperpixel == 1) {
/*
* Planarconfiguration is irrelevant in case of single band
* images and need not be included. We will set it anyway,
* because this field is used in other parts of library even
* in the single band case.
*/
if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG))
tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG;
} else {
if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Must set \"PlanarConfiguration\" before writing data",
tif->tif_name);
return (0);
}
}
if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) {
tif->tif_dir.td_nstrips = 0;
TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for %s arrays",
tif->tif_name, isTiled(tif) ? "tile" : "strip");
return (0);
}
tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1;
tif->tif_scanlinesize = TIFFScanlineSize(tif);
tif->tif_flags |= TIFF_BEENWRITING;
return (1);
}
示例11: TIFFTileSize
/*
* Get an tile-organized image that has
* SamplesPerPixel > 1
* PlanarConfiguration separated
* We assume that all such images are RGB.
*/
boolean TIFFRasterImpl::gtTileSeparate(
const RGBvalue* Map, u_long h, u_long w
) {
u_long tilesize = TIFFTileSize(tif_);
u_char* buf = new u_char[3*tilesize];
if (buf == nil) {
TIFFError(TIFFFileName(tif_), "No space for tile buffer");
return false;
}
u_char* r = buf;
u_char* g = r + tilesize;
u_char* b = g + tilesize;
tileSeparateRoutine put = pickTileSeparateCase(Map);
u_long tw;
TIFFGetField(tif_, TIFFTAG_TILEWIDTH, &tw);
u_long th;
TIFFGetField(tif_, TIFFTAG_TILELENGTH, &th);
u_long y = setorientation(h);
int toskew = (int)(orientation_ == ORIENTATION_TOPLEFT ? -tw+-w : -tw+w);
for (u_long row = 0; row < h; row += th) {
u_long nrow = (row + th > h ? h - row : th);
for (u_long col = 0; col < w; col += tw) {
if (TIFFReadTile(tif_, r, col, row, 0, 0) < 0) {
break;
}
if (TIFFReadTile(tif_, g, col, row, 0, 1) < 0) {
break;
}
if (TIFFReadTile(tif_, b, col, row, 0, 2) < 0) {
break;
}
if (col + tw > w) {
/*
* Tile is clipped horizontally. Calculate
* visible portion and skewing factors.
*/
u_long npix = w - col;
int fromskew = (int)(tw - npix);
(this->*put)(
raster_ + y*w + col, r, g, b, Map,
npix, nrow, fromskew, toskew + fromskew
);
} else
(this->*put)(
raster_ + y*w + col, r, g, b, Map,
tw, nrow, 0, toskew
);
}
y += (orientation_ == ORIENTATION_TOPLEFT ? -nrow : nrow);
}
delete buf;
return true;
}
示例12: TIFFWriteCheck
/*
* Verify file is writable and that the directory
* information is setup properly. In doing the latter
* we also "freeze" the state of the directory so
* that important information is not changed.
*/
static int
TIFFWriteCheck(TIFF* tif, int tiles, const char* module)
{
if (tif->tif_mode == O_RDONLY) {
TIFFError(module, "%s: File not open for writing",
tif->tif_name);
return (0);
}
if (tiles ^ isTiled(tif)) {
TIFFError(tif->tif_name, tiles ?
"Can not write tiles to a stripped image" :
"Can not write scanlines to a tiled image");
return (0);
}
/*
* On the first write verify all the required information
* has been setup and initialize any data structures that
* had to wait until directory information was set.
* Note that a lot of our work is assumed to remain valid
* because we disallow any of the important parameters
* from changing after we start writing (i.e. once
* TIFF_BEENWRITING is set, TIFFSetField will only allow
* the image's length to be changed).
*/
if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) {
TIFFError(module,
"%s: Must set \"ImageWidth\" before writing data",
tif->tif_name);
return (0);
}
if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) {
TIFFError(module,
"%s: Must set \"PlanarConfiguration\" before writing data",
tif->tif_name);
return (0);
}
if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) {
tif->tif_dir.td_nstrips = 0;
TIFFError(module, "%s: No space for %s arrays",
tif->tif_name, isTiled(tif) ? "tile" : "strip");
return (0);
}
tif->tif_tilesize = TIFFTileSize(tif);
tif->tif_scanlinesize = TIFFScanlineSize(tif);
tif->tif_flags |= TIFF_BEENWRITING;
return (1);
}
示例13: gtTileContig
/*
* Get an tile-organized image that has
* PlanarConfiguration contiguous if SamplesPerPixel > 1
* or
* SamplesPerPixel == 1
*/
static int
gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
{
TIFF* tif = img->tif;
tileContigRoutine put = img->put.contig;
uint16 orientation;
uint32 col, row, y;
uint32 tw, th;
u_char* buf;
int32 fromskew, toskew;
uint32 nrow;
buf = (u_char*) _TIFFmalloc(TIFFTileSize(tif));
if (buf == 0) {
TIFFError(TIFFFileName(tif), "No space for tile buffer");
return (0);
}
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
y = setorientation(img, h);
orientation = img->orientation;
toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? tw+w : tw-w);
for (row = 0; row < h; row += th) {
nrow = (row + th > h ? h - row : th);
for (col = 0; col < w; col += tw) {
if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0 && img->stoponerr)
break;
if (col + tw > w) {
/*
* Tile is clipped horizontally. Calculate
* visible portion and skewing factors.
*/
uint32 npix = w - col;
fromskew = tw - npix;
(*put)(img, raster+y*w+col, col, y,
npix, nrow, fromskew, toskew + fromskew, buf);
} else {
(*put)(img, raster+y*w+col, col, y, tw, nrow, 0, toskew, buf);
}
}
y += (orientation == ORIENTATION_TOPLEFT ?
-(int32) nrow : (int32) nrow);
}
_TIFFfree(buf);
return (1);
}
示例14: Impl
/**
* Constructor.
*
* @param ifd the directory the tile belongs to.
*/
Impl(std::shared_ptr<IFD>& ifd):
ifd(ifd),
tilewidth(),
tileheight(),
planarconfig(),
samples(),
tilecount(),
nrows(),
ncols(),
ntiles(),
buffersize()
{
Sentry sentry;
::TIFF *tiff = getTIFF();
// Get basic image metadata.
uint32_t imagewidth = ifd->getImageWidth();
uint32_t imageheight = ifd->getImageHeight();
planarconfig = ifd->getPlanarConfiguration();
samples = ifd->getSamplesPerPixel();
tilewidth = ifd->getTileWidth();
tileheight = ifd->getTileHeight();
type = ifd->getTileType();
// Get tile-specific metadata, falling back to
// strip-specific metadata if not present.
if (type == TILE)
{
tilecount = TIFFNumberOfTiles(tiff);
buffersize = TIFFTileSize(tiff);
}
else
{
tilecount = TIFFNumberOfStrips(tiff);
buffersize = TIFFStripSize(tiff);
}
// Compute row and column counts.
nrows = imageheight / tileheight;
if (imageheight % tileheight)
++nrows;
ncols = imagewidth / tilewidth;
if (imagewidth % tilewidth)
++ncols;
ntiles = nrows * ncols;
}
示例15: gtTileContig
/*
* Get an tile-organized image that has
* PlanarConfiguration contiguous if SamplesPerPixel > 1
* or
* SamplesPerPixel == 1
*/
static int
gtTileContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
{
TIFF* tif = img->tif;
ImageIterTileContigRoutine callback = img->callback.contig;
uint16 orientation;
uint32 col, row;
uint32 tw, th;
u_char* buf;
int32 fromskew;
uint32 nrow;
buf = (u_char*) _TIFFmalloc(TIFFTileSize(tif));
if (buf == 0) {
TIFFError(TIFFFileName(tif), "No space for tile buffer");
return (0);
}
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
orientation = img->orientation;
for (row = 0; row < h; row += th) {
nrow = (row + th > h ? h - row : th);
for (col = 0; col < w; col += tw) {
if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0 && img->stoponerr)
break;
if (col + tw > w) {
/*
* Tile is clipped horizontally. Calculate
* visible portion and skewing factors.
*/
uint32 npix = w - col;
fromskew = tw - npix;
(*callback)(img, udata, col, row, npix, nrow, fromskew, buf);
} else {
(*callback)(img, udata, col, row, tw, nrow, 0, buf);
}
}
}
_TIFFfree(buf);
return (1);
}