本文整理汇总了C++中TIFFStripSize函数的典型用法代码示例。如果您正苦于以下问题:C++ TIFFStripSize函数的具体用法?C++ TIFFStripSize怎么用?C++ TIFFStripSize使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIFFStripSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
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] > (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);
}
示例2: 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;
}
示例3: 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;
TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts);
for (s = 0; s < ns; s++) {
if (bytecounts[s] > 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);
}
示例4: gtStripContig
/*
* Get a strip-organized image that has
* PlanarConfiguration contiguous if SamplesPerPixel > 1
* or
* SamplesPerPixel == 1
*/
boolean TIFFRasterImpl::gtStripContig(
const RGBvalue* Map, u_long h, u_long w
) {
u_char* buf = new u_char[TIFFStripSize(tif_)];
if (buf == nil) {
TIFFError(TIFFFileName(tif_), "No space for strip buffer");
return (false);
}
tileContigRoutine put = pickTileContigCase(Map);
u_long y = setorientation(h);
int toskew = (int)(orientation_ == ORIENTATION_TOPLEFT ? -w + -w : -w + w);
u_long rowsperstrip = (u_long) -1L;
TIFFGetField(tif_, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
u_long imagewidth;
TIFFGetField(tif_, TIFFTAG_IMAGEWIDTH, &imagewidth);
int scanline = TIFFScanlineSize(tif_);
int fromskew = (int)(w < imagewidth ? imagewidth - w : 0);
for (u_long row = 0; row < h; row += rowsperstrip) {
u_int nrow = u_int(row + rowsperstrip > h ? h - row : rowsperstrip);
if (TIFFReadEncodedStrip(
tif_, TIFFComputeStrip(tif_, row, 0), buf, nrow*scanline) < 0
) {
break;
}
(this->*put)(raster_ + y*w, buf, Map, w, nrow, fromskew, toskew);
y += (orientation_ == ORIENTATION_TOPLEFT ? -nrow : nrow);
}
delete buf;
return true;
}
示例5: gtStripContig
/*
* Get a strip-organized image that has
* PlanarConfiguration contiguous if SamplesPerPixel > 1
* or
* SamplesPerPixel == 1
*/
static int
gtStripContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
{
TIFF* tif = img->tif;
ImageIterTileContigRoutine callback = img->callback.contig;
uint16 orientation;
uint32 row, nrow;
u_char* buf;
uint32 rowsperstrip;
uint32 imagewidth = img->width;
tsize_t scanline;
int32 fromskew;
buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif));
if (buf == 0) {
TIFFError(TIFFFileName(tif), "No space for strip buffer");
return (0);
}
orientation = img->orientation;
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
scanline = TIFFScanlineSize(tif);
fromskew = (w < imagewidth ? imagewidth - w : 0);
for (row = 0; row < h; row += rowsperstrip) {
nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
buf, nrow*scanline) < 0 && img->stoponerr)
break;
(*callback)(img, udata, 0, row, w, nrow, fromskew, buf);
}
_TIFFfree(buf);
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);
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)
goto bad;
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;
}
bad:
TIFFError(TIFFFileName(in),
"Can't allocate space for strip buffer.");
return 0;
}
示例7: 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;
}
示例8: svRGBContig
static void
svRGBContig(TIFF* tif, uint32* ss, int xsize, int ysize)
{
register int x, y;
tsize_t stripsize = TIFFStripSize(tif);
unsigned char *strip = (unsigned char *)_TIFFmalloc(stripsize);
for (y = 0; y <= ysize; y += rowsperstrip) {
register unsigned char *pp = strip;
register uint32 n;
n = rowsperstrip;
if (n > ysize-y+1)
n = ysize-y+1;
do {
for (x = 0; x <= xsize; x++) {
uint32 v = ss[x];
pp[0] = v;
pp[1] = v >> 8;
pp[2] = v >> 16;
pp += 3;
}
ss += xsize+1;
} while (--n);
if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,0),
strip, stripsize) < 0)
break;
}
_TIFFfree(strip);
}
示例9: asynPrint
/** Writes single NDArray to the TIFF file.
* \param[in] pArray Pointer to the NDArray to be written
*/
asynStatus NDFileTIFF::writeFile(NDArray *pArray)
{
unsigned long stripSize;
tsize_t nwrite=0;
int strip, sizeY;
unsigned char *pRed, *pGreen, *pBlue;
static const char *functionName = "writeFile";
asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW,
"%s:%s: %lu, %lu\n",
driverName, functionName, (unsigned long)pArray->dims[0].size, (unsigned long)pArray->dims[1].size);
if (this->output == NULL) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s NULL TIFF file\n",
driverName, functionName);
return(asynError);
}
stripSize = (unsigned long)TIFFStripSize(this->output);
TIFFGetField(this->output, TIFFTAG_IMAGELENGTH, &sizeY);
switch (this->colorMode) {
case NDColorModeMono:
case NDColorModeRGB1:
nwrite = TIFFWriteEncodedStrip(this->output, 0, pArray->pData, stripSize);
break;
case NDColorModeRGB2:
/* TIFF readers don't support row interleave, put all the red strips first, then all the blue, then green. */
for (strip=0; strip<sizeY; strip++) {
pRed = (unsigned char *)pArray->pData + 3*strip*stripSize;
pGreen = pRed + stripSize;
pBlue = pRed + 2*stripSize;
nwrite = TIFFWriteEncodedStrip(this->output, strip, pRed, stripSize);
nwrite = TIFFWriteEncodedStrip(this->output, sizeY+strip, pBlue, stripSize);
nwrite = TIFFWriteEncodedStrip(this->output, 2*sizeY+strip, pGreen, stripSize);
}
break;
case NDColorModeRGB3:
for (strip=0; strip<3; strip++) {
nwrite = TIFFWriteEncodedStrip(this->output, strip, (unsigned char *)pArray->pData+stripSize*strip, stripSize);
}
break;
default:
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: unknown color mode %d\n",
driverName, functionName, this->colorMode);
return(asynError);
break;
}
if (nwrite <= 0) {
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR,
"%s:%s: error writing data to file\n",
driverName, functionName);
return(asynError);
}
return(asynSuccess);
}
示例10: 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);
}
示例11: 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;
}
示例12: Close
bool CTiffImg::Create(const char *szFname, unsigned long nWidth, unsigned long nHeight,
unsigned long nBPS, unsigned long nPhoto, unsigned long nSamples,
float fXRes, float fYRes, bool bCompress)
{
Close();
m_bRead = false;
m_nWidth = nWidth;
m_nHeight = nHeight;
m_nBitsPerSample = (unsigned short)nBPS;
m_nSamples = (unsigned short)nSamples;
switch(nPhoto) {
case PHOTO_MINISBLACK:
if (m_nSamples==3)
m_nPhoto = PHOTOMETRIC_RGB;
else
m_nPhoto = PHOTOMETRIC_MINISBLACK;
break;
case PHOTO_MINISWHITE:
if (m_nSamples==4)
m_nPhoto = PHOTOMETRIC_SEPARATED;
else
m_nPhoto = PHOTOMETRIC_MINISWHITE;
break;
case PHOTO_CIELAB:
m_nPhoto = PHOTOMETRIC_CIELAB;
break;
}
m_hTif = TIFFOpen(szFname, "w");
if (!m_hTif) {
TIFFError(szFname,"Can not open output image");
return false;
}
TIFFSetField(m_hTif, TIFFTAG_IMAGEWIDTH, (uint32) m_nWidth);
TIFFSetField(m_hTif, TIFFTAG_IMAGELENGTH, (uint32) m_nHeight);
TIFFSetField(m_hTif, TIFFTAG_PHOTOMETRIC, m_nPhoto);
TIFFSetField(m_hTif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(m_hTif, TIFFTAG_SAMPLESPERPIXEL, m_nSamples);
TIFFSetField(m_hTif, TIFFTAG_BITSPERSAMPLE, m_nBitsPerSample);
TIFFSetField(m_hTif, TIFFTAG_ROWSPERSTRIP, 1);
TIFFSetField(m_hTif, TIFFTAG_COMPRESSION, bCompress ? COMPRESSION_LZW : COMPRESSION_NONE);
TIFFSetField(m_hTif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(m_hTif, TIFFTAG_XRESOLUTION, fXRes);
TIFFSetField(m_hTif, TIFFTAG_YRESOLUTION, fYRes);
m_nCurLine = 0;
m_nCurStrip = 0;
m_nBytesPerLine = TIFFStripSize(m_hTif);
return true;
}
示例13: gtStripSeparate
/*
* Get a strip-organized image with
* SamplesPerPixel > 1
* PlanarConfiguration separated
* We assume that all such images are RGB.
*/
static int
gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
{
TIFF* tif = img->tif;
tileSeparateRoutine put = img->put.separate;
uint16 orientation;
u_char *buf;
u_char *r, *g, *b, *a;
uint32 row, y, nrow;
tsize_t scanline;
uint32 rowsperstrip;
uint32 imagewidth = img->width;
tsize_t stripsize;
int32 fromskew, toskew;
int alpha = img->alpha;
stripsize = TIFFStripSize(tif);
r = buf = (u_char *)_TIFFmalloc(4*stripsize);
if (buf == 0) {
TIFFError(TIFFFileName(tif), "No space for tile buffer");
return (0);
}
g = r + stripsize;
b = g + stripsize;
a = b + stripsize;
if (!alpha)
memset(a, 0xff, stripsize);
y = setorientation(img, h);
orientation = img->orientation;
toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? w+w : w-w);
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
scanline = TIFFScanlineSize(tif);
fromskew = (w < imagewidth ? imagewidth - w : 0);
for (row = 0; row < h; row += rowsperstrip) {
nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
r, nrow*scanline) < 0 && img->stoponerr)
break;
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 1),
g, nrow*scanline) < 0 && img->stoponerr)
break;
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 2),
b, nrow*scanline) < 0 && img->stoponerr)
break;
if (alpha &&
(TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 3),
a, nrow*scanline) < 0 && img->stoponerr))
break;
(*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, r, g, b, a);
y += (orientation == ORIENTATION_TOPLEFT ?
-(int32) nrow : (int32) nrow);
}
_TIFFfree(buf);
return (1);
}
示例14: 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;
}
示例15: TIFFWriteBufferSetup
/*
* Setup the raw data buffer used for encoding.
*/
int
TIFFWriteBufferSetup(TIFF *tif, tdata_t bp, tsize_t size)
{
static const char module[] = "TIFFWriteBufferSetup";
if (tif->tif_rawdata)
{
if (tif->tif_flags & TIFF_MYBUFFER)
{
_TIFFfree(tif->tif_rawdata);
tif->tif_flags &= ~TIFF_MYBUFFER;
}
tif->tif_rawdata = NULL;
}
if (size == (tsize_t) -1)
{
size = (isTiled(tif) ?
tif->tif_tilesize : TIFFStripSize(tif));
/*
* Make raw data buffer at least 8K
*/
if (size < 8 * 1024)
size = 8 * 1024;
bp = NULL; /* NB: force malloc */
}
if (bp == NULL)
{
bp = _TIFFmalloc(size);
if (bp == NULL)
{
TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for output buffer",
tif->tif_name);
return (0);
}
tif->tif_flags |= TIFF_MYBUFFER;
}
else
tif->tif_flags &= ~TIFF_MYBUFFER;
tif->tif_rawdata = (tidata_t) bp;
tif->tif_rawdatasize = size;
tif->tif_rawcc = 0;
tif->tif_rawcp = tif->tif_rawdata;
tif->tif_flags |= TIFF_BUFFERSETUP;
return (1);
}