本文整理汇总了C++中TIFFNumberOfStrips函数的典型用法代码示例。如果您正苦于以下问题:C++ TIFFNumberOfStrips函数的具体用法?C++ TIFFNumberOfStrips怎么用?C++ TIFFNumberOfStrips使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIFFNumberOfStrips函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_strips
int
write_strips(TIFF *tif, const tdata_t array, const tsize_t size)
{
tstrip_t strip, nstrips;
tsize_t stripsize, offset;
stripsize = TIFFStripSize(tif);
if (!stripsize) {
fprintf (stderr, "Wrong size of strip.\n");
return -1;
}
nstrips = TIFFNumberOfStrips(tif);
for (offset = 0, strip = 0;
offset < size && strip < nstrips;
offset+=stripsize, strip++) {
/*
* Properly write last strip.
*/
tsize_t bufsize = size - offset;
if (bufsize > stripsize)
bufsize = stripsize;
if (TIFFWriteEncodedStrip(tif, strip, (char *)array + offset,
bufsize) != bufsize) {
fprintf (stderr, "Can't write strip %lu.\n",
(unsigned long)strip);
return -1;
}
}
return 0;
}
示例2: cpStrips
static int
cpStrips(TIFF* in, TIFF* out)
{
tsize_t bufsize = TIFFStripSize(in);
unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize);
if (buf) {
tstrip_t s, ns = TIFFNumberOfStrips(in);
tsize_t *bytecounts;
TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts);
for (s = 0; s < ns; s++) {
if (bytecounts[s] > bufsize) {
buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[s]);
if (!buf)
goto bad;
bufsize = bytecounts[s];
}
if (TIFFReadRawStrip(in, s, buf, bytecounts[s]) < 0 ||
TIFFWriteRawStrip(out, s, buf, bytecounts[s]) < 0) {
_TIFFfree(buf);
return 0;
}
}
_TIFFfree(buf);
return 1;
}
bad:
TIFFError(TIFFFileName(in),
"Can't allocate space for strip buffer.");
return 0;
}
示例3: cpStrips
static int
cpStrips(TIFF* in, TIFF* out)
{
tmsize_t bufsize = TIFFStripSize(in);
unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize);
if (buf) {
tstrip_t s, ns = TIFFNumberOfStrips(in);
uint64 *bytecounts;
TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts);
for (s = 0; s < ns; s++) {
if (bytecounts[s] > (uint64)bufsize) {
buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[s]);
if (!buf)
return (0);
bufsize = (tmsize_t)bytecounts[s];
}
if (TIFFReadRawStrip(in, s, buf, (tmsize_t)bytecounts[s]) < 0 ||
TIFFWriteRawStrip(out, s, buf, (tmsize_t)bytecounts[s]) < 0) {
_TIFFfree(buf);
return (0);
}
}
_TIFFfree(buf);
return (1);
}
return (0);
}
示例4: tif_ReadContigStripData
tdata_t tif_ReadContigStripData(TIFF* tif)
{
tdata_t raster = tif_Malloc(tif);
tsize_t result;
tsize_t offset;
tsize_t stripSize = TIFFStripSize(tif);
tstrip_t stripMax = TIFFNumberOfStrips(tif);
tstrip_t istrip;
if (tif == NULL)
return NULL;
offset = 0;
if (raster != NULL) {
for (istrip = 0; istrip < stripMax; istrip++){
result = TIFFReadEncodedStrip (tif, istrip, ((char*)raster)+offset, stripSize);
if (result == -1) {
printf("Read error on input strip number %d\n", istrip);
}
offset += result;
}
}
return raster;
}
示例5: TIFFSetupStrips
int
TIFFSetupStrips(TIFF* tif)
{
TIFFDirectory* td = &tif->tif_dir;
if (isTiled(tif))
td->td_stripsperimage =
isUnspecified(tif, FIELD_TILEDIMENSIONS) ?
td->td_samplesperpixel : TIFFNumberOfTiles(tif);
else
td->td_stripsperimage =
isUnspecified(tif, FIELD_ROWSPERSTRIP) ?
td->td_samplesperpixel : TIFFNumberOfStrips(tif);
td->td_nstrips = td->td_stripsperimage;
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
td->td_stripsperimage /= td->td_samplesperpixel;
td->td_stripoffset = (uint64 *)
_TIFFmalloc(td->td_nstrips * sizeof (uint64));
td->td_stripbytecount = (uint64 *)
_TIFFmalloc(td->td_nstrips * sizeof (uint64));
if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL)
return (0);
/*
* Place data at the end-of-file
* (by setting offsets to zero).
*/
_TIFFmemset(td->td_stripoffset, 0, td->td_nstrips*sizeof (uint64));
_TIFFmemset(td->td_stripbytecount, 0, td->td_nstrips*sizeof (uint64));
TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS);
TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS);
return (1);
}
示例6: cpStrips
static int
cpStrips(TIFF* in, TIFF* out)
{
tsize_t bufsize = TIFFStripSize(in);
unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize);
if (buf) {
tstrip_t s, ns = TIFFNumberOfStrips(in);
uint32 *bytecounts;
if (!TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts)) {
fprintf(stderr, "tiffsplit: strip byte counts are missing\n");
return (0);
}
for (s = 0; s < ns; s++) {
if (bytecounts[s] > (uint32)bufsize) {
buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[s]);
if (!buf)
return (0);
bufsize = bytecounts[s];
}
if (TIFFReadRawStrip(in, s, buf, bytecounts[s]) < 0 ||
TIFFWriteRawStrip(out, s, buf, bytecounts[s]) < 0) {
_TIFFfree(buf);
return (0);
}
}
_TIFFfree(buf);
return (1);
}
return (0);
}
示例7: TIFFOpen
bool CaViewerCore::openTif(ImageInfo info, int nSequence)
{
static const QString sProgressFormat = QObject::tr("Loading... %p%");
TIFF* tif = TIFFOpen(info.fullName(nSequence).toStdString().c_str(), "r");
quint16 bps, spp;
quint32 rps;
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bps);
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &spp);
TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rps);
const quint32 stripSize = TIFFNumberOfStrips(tif);
const quint32 stripLength = TIFFStripSize(tif);
int nPrevImgCount = 0;
for(int count = 0; count < nSequence; ++count)
nPrevImgCount += info.imageSize(count);
if(bps == 16 && spp == 1) // for 16-bit mono channel tif
{
for(int imgCount = 0; imgCount < info.imageSize(nSequence); ++imgCount)
{
const int globalCount = nPrevImgCount + imgCount;
const int height = globalCount % info.heightSize();
const int time = globalCount / info.heightSize();
cv::Mat_<quint16> img = m_lImage->at(height).at(time);
#pragma omp parallel for schedule(static)
for(quint32 stripCount = 0; stripCount < stripSize; ++stripCount)
{
quint16* const stripBuf = reinterpret_cast<quint16*>(new quint8[stripLength]);
#pragma omp critical
TIFFReadEncodedStrip(tif, stripCount, stripBuf, stripLength);
for(quint32 rowInStrip = 0; rowInStrip < rps; ++rowInStrip)
{
const quint32 imgStrip = rowInStrip + rps * stripCount;
quint16* const matData = reinterpret_cast<quint16*>(img.data + img.step * imgStrip);
for(int col = 0; col < info.colSize(); ++col)
{
const quint16 oriValue = stripBuf[col + rowInStrip * info.colSize()];
matData[col] = oriValue;
}
if(imgStrip == info.rowSize() - 1)
break;
}
}
TIFFReadDirectory(tif);
emit changedProgressValue(100.0 * globalCount / m_lImage->size(), sProgressFormat);
}
return true;
}
else
return false;
TIFFClose(tif);
}
示例8: StripBasedXform
static
int StripBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
{
tsize_t BufSizeIn = TIFFStripSize(in);
tsize_t BufSizeOut = TIFFStripSize(out);
unsigned char *BufferIn, *BufferOut;
ttile_t i, StripCount = TIFFNumberOfStrips(in) / nPlanes;
uint32 sw;
uint32 sl;
uint32 iml;
int j;
int PixelCount;
TIFFGetFieldDefaulted(in, TIFFTAG_IMAGEWIDTH, &sw);
TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &sl);
TIFFGetFieldDefaulted(in, TIFFTAG_IMAGELENGTH, &iml);
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 < StripCount; i++) {
for (j=0; j < nPlanes; j++) {
if (TIFFReadEncodedStrip(in, i + (j * StripCount),
BufferIn + (j * BufSizeIn), BufSizeIn) < 0) goto cleanup;
}
PixelCount = (int) sw * (iml < sl ? iml : sl);
iml -= sl;
cmsDoTransform(hXForm, BufferIn, BufferOut, PixelCount);
for (j=0; j < nPlanes; j++) {
if (TIFFWriteEncodedStrip(out, i + (j * StripCount),
BufferOut + j * BufSizeOut, BufSizeOut) < 0) goto cleanup;
}
}
_TIFFfree(BufferIn);
_TIFFfree(BufferOut);
return 1;
cleanup:
_TIFFfree(BufferIn);
_TIFFfree(BufferOut);
return 0;
}
示例9: rut_surface_to_tiff
int
rut_surface_to_tiff (RutSurface *s, const char *filename)
{
TIFF *tif = NULL;
int rows_per_strip, num_strips, strip, row, i;
int result = 1;
char *buffer = NULL;
assert (s);
assert (filename);
/* Open TIFF file */
tif = TIFFOpen (filename, "wb");
if (!tif) goto savefail;
/* Set TIFF tags */
TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, s->cols);
TIFFSetField (tif, TIFFTAG_IMAGELENGTH, s->rows);
TIFFSetField (tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
TIFFSetField (tif, TIFFTAG_BITSPERSAMPLE, 32);
TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, 1);
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
rows_per_strip = TIFFDefaultStripSize (tif, 0);
TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip);
num_strips = TIFFNumberOfStrips (tif);
/* Copy data into TIFF strips */
buffer = malloc (TIFFStripSize (tif));
for (row = 0, strip = 0; strip < num_strips; strip++) {
size_t size = 0;
for (i = 0; (i < rows_per_strip) && (row < s->rows); i++, row++) {
float *src = RUT_SURFACE_PTR (s, row, 0);
char *dest = buffer + i*s->cols*4;
memcpy (dest, src, s->cols * 4);
size += s->cols*4;
}
result = (TIFFWriteEncodedStrip (tif, strip, buffer, size) != -1);
if (!result) {
fprintf (stderr, "Could not write TIFF strip %i/%i to %s\n",
strip+1, num_strips, filename);
}
}
/* Clean up */
free (buffer);
TIFFClose (tif);
return 1;
savefail:
if (tif) TIFFClose (tif);
if (buffer) free (buffer);
fprintf (stderr, "Could not save TIFF to %s\n", filename);
return 0;
}
示例10: JBIGSetupDecode
static int JBIGSetupDecode(TIFF* tif)
{
if (TIFFNumberOfStrips(tif) != 1)
{
TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in decoder");
return 0;
}
return 1;
}
示例11: tiffSize_
int tiffSize_(TIFF *image, int *W, int *H, int *linestep, BufType *Type)
{
uint16 bps, spp, sfm;
uint32 width;
tsize_t stripSize;
unsigned long imageOffset;
int stripMax;
//unsigned long bufferSize, count;
// Check that it is of a type that we support
if((TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bps) == 0) ){
return(42);
}
MyTRACE( "bits per sample(%d)\n", bps);
//float type
if((TIFFGetField(image, TIFFTAG_SAMPLEFORMAT, &sfm) == 0) ){
return(42);
}
MyTRACE( "TIFFTAG_SAMPLEFORMAT(%d)\n", sfm);
if (bps == 32 && sfm == SAMPLEFORMAT_IEEEFP)
*Type = TYPE_32F;
else if (bps == 16 && (sfm == SAMPLEFORMAT_INT))
*Type = TYPE_16S;
else if (bps == 16 && (sfm == SAMPLEFORMAT_UINT))
*Type = TYPE_16U;
else
return 43;
if((TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp) == 0) || (spp != 1)){
MyTRACE( "Either undefined or unsupported number of samples per pixel\n");
return(42);
}
// Read in the possibly multiple strips
stripSize = TIFFStripSize (image);
*linestep = stripSize;
stripMax = TIFFNumberOfStrips (image);
imageOffset = 0;
long height = stripMax;
*H = height;
// Do whatever it is we do with the buffer -- we dump it in hex
if(TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width) == 0){
MyTRACE( "Image does not define its width\n");
return(42);
}
*W = width;
assert(typeSize(*Type)*width <= stripSize);
return 0;
}
示例12: printTIF
void
printTIF(TIFF* tif, int pageNumber)
{
uint32 w, h;
uint16 unit;
float xres, yres;
tstrip_t s, ns;
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres)) {
TIFFWarning(TIFFFileName(tif),
"No x-resolution, assuming %g dpi", defxres);
xres = defxres;
}
if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres)) {
TIFFWarning(TIFFFileName(tif),
"No y-resolution, assuming %g lpi", defyres);
yres = defyres; /* XXX */
}
if (TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &unit) &&
unit == RESUNIT_CENTIMETER) {
xres *= 25.4;
yres *= 25.4;
}
printf("%%%%Page: \"%d\" %d\n", pageNumber, pageNumber);
printf("/$pageTop save def gsave\n");
if (scaleToPage) {
float yscale = pageHeight / (h/yres);
float xscale = pageWidth / (w/xres);
printf("%d %d translate\n",
(int) (((basePageWidth - pageWidth) * points) * half),
(int)((yscale*(h/yres)*points) +
(basePageHeight - pageHeight) * points * half) );
printf("%g %g scale\n", (72.*xscale)/xres, -(72.*yscale)/yres);
} else {
printf("%d %d translate\n",
(int) ((basePageWidth - pageWidth) * points * half),
(int)((72.*h/yres) +
(basePageHeight - pageHeight) * points * half) );
printf("%g %g scale\n", 72./xres, -72./yres);
}
printf("0 setgray\n");
TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, printruns);
ns = TIFFNumberOfStrips(tif);
row = 0;
for (s = 0; s < ns; s++)
(void) TIFFReadEncodedStrip(tif, s, (tdata_t) NULL, (tsize_t) -1);
printf("p\n");
printf("grestore $pageTop restore\n");
totalPages++;
}
示例13: tifinit
int tifinit(Mytiff * mytiff,const char * const filename){
int myerror;
char * Stripbytes=NULL;
u_int32_t stripbytes,estsize,estbytes;
myerror=0;
mytiff->ndata=mytiff->wd * mytiff->ht;
mytiff->nbytes = mytiff->ndata * mytiff->bytes;
mytiff->tiffp= TIFFOpen(filename,"wl");
if (mytiff->tiffp == 0 ){
fprintf(stderr,"ERROR: %s: %i: failed tiff open of %s!\n",__func__,__LINE__,filename);
fprintf(stderr,"ERROR: %s: tried to open with TIFFOpen(%s,\"wl\"); \n",__func__,filename);
return(101);
}
TIFFSetField(mytiff->tiffp,TIFFTAG_IMAGEWIDTH,mytiff->wd);
TIFFSetField(mytiff->tiffp,TIFFTAG_IMAGELENGTH,mytiff->ht);
TIFFSetField(mytiff->tiffp,TIFFTAG_BITSPERSAMPLE,mytiff->bytes * 8);
TIFFSetField(mytiff->tiffp,TIFFTAG_PLANARCONFIG,1);
TIFFSetField(mytiff->tiffp,TIFFTAG_PHOTOMETRIC,1);
/* only 4-byte float or 2-byte int so far */
if (mytiff->bytes == 4){
TIFFSetField(mytiff->tiffp,TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
}else if (mytiff->bytes == 2){
TIFFSetField(mytiff->tiffp,TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
}
/* set the number of rows per strip , default or overridden by the environment variable */
Stripbytes=getenv("I12STRIPBYTES");
if (Stripbytes == NULL ){
stripbytes=(D_STRIPBYTES);
}else{
stripbytes=atoi(Stripbytes);
}
estbytes=(stripbytes / (mytiff->wd * mytiff->bytes));
estsize=TIFFDefaultStripSize(mytiff->tiffp,estbytes);
TIFFSetField(mytiff->tiffp,TIFFTAG_ROWSPERSTRIP,estsize);
mytiff->stripnum=TIFFNumberOfStrips(mytiff->tiffp);
mytiff->bytesperstrip=TIFFVStripSize(mytiff->tiffp,mytiff->stripnum);
if (! mytiff->isalloc){
mytiff->buf=(char *) malloc(mytiff->bytesperstrip);
mytiff->isalloc=1;
}
VBPRINT("stripbytes %s requested, stripsize set to: %i rows\n",Stripbytes,estsize);
VBPRINT("bytes per strip is: %i \n",mytiff->bytesperstrip);
return(0);
}
示例14: read_strips
int
read_strips(TIFF *tif, const tdata_t array, const tsize_t size)
{
tstrip_t strip, nstrips;
tsize_t stripsize, offset;
tdata_t buf = NULL;
stripsize = TIFFStripSize(tif);
if (!stripsize) {
fprintf (stderr, "Wrong size of strip.\n");
return -1;
}
buf = _TIFFmalloc(stripsize);
if (!buf) {
fprintf (stderr, "Can't allocate space for strip buffer.\n");
return -1;
}
nstrips = TIFFNumberOfStrips(tif);
for (offset = 0, strip = 0;
offset < size && strip < nstrips;
offset+=stripsize, strip++) {
/*
* Properly read last strip.
*/
tsize_t bufsize = size - offset;
if (bufsize > stripsize)
bufsize = stripsize;
if (TIFFReadEncodedStrip(tif, strip, buf, -1) != bufsize) {
fprintf (stderr, "Can't read strip %lu.\n",
(unsigned long)strip);
return -1;
}
if (memcmp(buf, (char *)array + offset, bufsize) != 0) {
fprintf (stderr, "Wrong data read for strip %lu.\n",
(unsigned long)strip);
_TIFFfree(buf);
return -1;
}
}
_TIFFfree(buf);
return 0;
}
示例15: 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;
}