本文整理汇总了C++中TIFFWarning函数的典型用法代码示例。如果您正苦于以下问题:C++ TIFFWarning函数的具体用法?C++ TIFFWarning怎么用?C++ TIFFWarning使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIFFWarning函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
u_long TIFFRasterImpl::setorientation(u_long h) {
u_long y;
if (!TIFFGetField(tif_, TIFFTAG_ORIENTATION, &orientation_)) {
orientation_ = ORIENTATION_TOPLEFT;
}
switch (orientation_) {
case ORIENTATION_BOTRIGHT:
case ORIENTATION_RIGHTBOT: /* XXX */
case ORIENTATION_LEFTBOT: /* XXX */
TIFFWarning(TIFFFileName(tif_), "using bottom-left orientation");
orientation_ = ORIENTATION_BOTLEFT;
/* fall thru... */
case ORIENTATION_BOTLEFT:
y = 0;
break;
case ORIENTATION_TOPRIGHT:
case ORIENTATION_RIGHTTOP: /* XXX */
case ORIENTATION_LEFTTOP: /* XXX */
default:
TIFFWarning(TIFFFileName(tif_), "using top-left orientation");
orientation_ = ORIENTATION_TOPLEFT;
/* fall thru... */
case ORIENTATION_TOPLEFT:
y = h-1;
break;
}
return y;
}
示例2: setorientation
/*
* Hacked from the tif_getimage.c file.
*/
static uint32
setorientation(TIFFRGBAImage* img, uint32 h)
{
TIFF* tif = img->tif;
uint32 y;
switch (img->orientation) {
case ORIENTATION_BOTRIGHT:
case ORIENTATION_RIGHTBOT: /* XXX */
case ORIENTATION_LEFTBOT: /* XXX */
TIFFWarning(TIFFFileName(tif), "using bottom-left orientation");
img->orientation = ORIENTATION_BOTLEFT;
/* fall thru... */
case ORIENTATION_BOTLEFT:
y = 0;
break;
case ORIENTATION_TOPRIGHT:
case ORIENTATION_RIGHTTOP: /* XXX */
case ORIENTATION_LEFTTOP: /* XXX */
default:
TIFFWarning(TIFFFileName(tif), "using top-left orientation");
img->orientation = ORIENTATION_TOPLEFT;
/* fall thru... */
case ORIENTATION_TOPLEFT:
y = h-1;
break;
}
return (y);
}
示例3: PackBitsDecode
static int
PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
{
char *bp;
tsize_t cc;
long n;
int b;
(void) s;
bp = (char*) tif->tif_rawcp;
cc = tif->tif_rawcc;
while (cc > 0 && (long)occ > 0) {
n = (long) *bp++, cc--;
/*
* Watch out for compilers that
* don't sign extend chars...
*/
if (n >= 128)
n -= 256;
if (n < 0) { /* replicate next byte -n+1 times */
if (n == -128) /* nop */
continue;
n = -n + 1;
if( occ < n )
{
TIFFWarning(tif->tif_name,
"PackBitsDecode: discarding %d bytes "
"to avoid buffer overrun",
n - occ);
n = occ;
}
occ -= n;
b = *bp++, cc--;
while (n-- > 0)
*op++ = b;
} else { /* copy next n+1 bytes literally */
if (occ < n + 1)
{
TIFFWarning(tif->tif_name,
"PackBitsDecode: discarding %d bytes "
"to avoid buffer overrun",
n - occ + 1);
n = occ - 1;
}
_TIFFmemcpy(op, bp, ++n);
op += n; occ -= n;
bp += n; cc -= n;
}
}
tif->tif_rawcp = (tidata_t) bp;
tif->tif_rawcc = cc;
if (occ > 0) {
TIFFError(tif->tif_name,
"PackBitsDecode: Not enough data for scanline %ld",
(long) tif->tif_row);
return (0);
}
return (1);
}
示例4: 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++;
}
示例5: buildMap
/*
* Construct any mapping table used
* by the associated put routine.
*/
static int
buildMap(TIFFRGBAImage* img)
{
switch (img->photometric) {
case PHOTOMETRIC_RGB:
case PHOTOMETRIC_YCBCR:
case PHOTOMETRIC_SEPARATED:
if (img->bitspersample == 8)
break;
/* fall thru... */
case PHOTOMETRIC_MINISBLACK:
case PHOTOMETRIC_MINISWHITE:
if (!setupMap(img))
return (0);
break;
case PHOTOMETRIC_PALETTE:
/*
* Convert 16-bit colormap to 8-bit (unless it looks
* like an old-style 8-bit colormap).
*/
if (checkcmap(img) == 16)
cvtcmap(img);
else
TIFFWarning(TIFFFileName(img->tif), "Assuming 8-bit colormap");
/*
* Use mapping table and colormap to construct
* unpacking tables for samples < 8 bits.
*/
if (img->bitspersample <= 8 && !makecmap(img))
return (0);
break;
}
return (1);
}
示例6: checkcmap
static int
checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b)
{
while (n-- > 0)
if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256)
return (16);
TIFFWarning(TIFFFileName(tif), "Assuming 8-bit colormap");
return (8);
}
示例7: TIFFWriteRationalArray
/*
* Setup a directory entry of an array of RATIONAL
* or SRATIONAL and write the associated indirect values.
*/
static int
TIFFWriteRationalArray(TIFF* tif,
TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v)
{
uint32 i;
uint32* t;
int status;
dir->tdir_tag = tag;
dir->tdir_type = (short) type;
dir->tdir_count = n;
t = (uint32*) _TIFFmalloc(2*n * sizeof (uint32));
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
# pragma ivdep
# pragma swp
# pragma unroll
# pragma prefetch
# if 0
# pragma simd noassert
# endif
#endif /* VDM auto patch */
for (i = 0; i < n; i++) {
float fv = v[i];
int sign = 1;
uint32 den;
if (fv < 0) {
if (type == TIFF_RATIONAL) {
TIFFWarning(tif->tif_name,
"\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL",
_TIFFFieldWithTag(tif,tag)->field_name, v);
fv = 0;
} else
fv = -fv, sign = -1;
}
den = 1L;
if (fv > 0) {
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
# pragma ivdep
# pragma swp
# pragma unroll
# pragma prefetch
# if 0
# pragma simd noassert
# endif
#endif /* VDM auto patch */
while (fv < 1L<<(31-3) && den < 1L<<(31-3))
fv *= 1<<3, den *= 1L<<3;
}
t[2*i+0] = sign * (fv + 0.5);
t[2*i+1] = den;
}
status = TIFFWriteData(tif, dir, (char *)t);
_TIFFfree((char*) t);
return (status);
}
示例8: CheckDirCount
/*
* Check the count field of a directory
* entry against a known value. The caller
* is expected to skip/ignore the tag if
* there is a mismatch.
*/
static int
CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count)
{
if (count != dir->tdir_count) {
TIFFWarning(tif->tif_name,
"incorrect count for field \"%s\" (%lu, expecting %lu); tag ignored",
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name,
dir->tdir_count, count);
return (0);
}
return (1);
}
示例9: CheckAndCorrectColormap
static void
CheckAndCorrectColormap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b)
{
int i;
for (i = 0; i < n; i++)
if (r[i] >= 256 || g[i] >= 256 || b[i] >= 256)
return;
TIFFWarning(TIFFFileName(tif), "Scaling 8-bit colormap");
#define CVT(x) (((x) * ((1L<<16)-1)) / 255)
for (i = 0; i < n; i++) {
r[i] = CVT(r[i]);
g[i] = CVT(g[i]);
b[i] = CVT(b[i]);
}
#undef CVT
}
示例10: TIFFWriteRationalArray
/*
* Setup a directory entry of an array of RATIONAL
* or SRATIONAL and write the associated indirect values.
*/
static int
TIFFWriteRationalArray(TIFF* tif,
TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v)
{
uint32 i;
uint32* t;
int status;
dir->tdir_tag = (uint16) tag;
dir->tdir_type = (short) type;
dir->tdir_count = n;
t = (uint32*) _TIFFmalloc(2*n * sizeof (uint32));
if (t == NULL) {
TIFFError(tif->tif_name,
"No space to write RATIONAL array");
return (0);
}
for (i = 0; i < n; i++) {
float fv = v[i];
int sign = 1;
uint32 den;
if (fv < 0) {
if (type == TIFF_RATIONAL) {
TIFFWarning(tif->tif_name,
"\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL",
_TIFFFieldWithTag(tif,tag)->field_name, fv);
fv = 0;
} else
fv = -fv, sign = -1;
}
den = 1L;
if (fv > 0) {
while (fv < 1L<<(31-3) && den < 1L<<(31-3))
fv *= 1<<3, den *= 1L<<3;
}
t[2*i+0] = (uint32) (sign * (fv + 0.5));
t[2*i+1] = den;
}
status = TIFFWriteData(tif, dir, (char *)t);
_TIFFfree((char*) t);
return (status);
}
示例11: _TIFFVSetField
//.........这里部分代码省略.........
case TIFFTAG_FILLORDER:
v = va_arg(ap, int);
if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB)
goto badvalue;
td->td_fillorder = (uint16) v;
break;
case TIFFTAG_DOCUMENTNAME:
_TIFFsetString(&td->td_documentname, va_arg(ap, char*));
break;
case TIFFTAG_ARTIST:
_TIFFsetString(&td->td_artist, va_arg(ap, char*));
break;
case TIFFTAG_DATETIME:
_TIFFsetString(&td->td_datetime, va_arg(ap, char*));
break;
case TIFFTAG_HOSTCOMPUTER:
_TIFFsetString(&td->td_hostcomputer, va_arg(ap, char*));
break;
case TIFFTAG_IMAGEDESCRIPTION:
_TIFFsetString(&td->td_imagedescription, va_arg(ap, char*));
break;
case TIFFTAG_MAKE:
_TIFFsetString(&td->td_make, va_arg(ap, char*));
break;
case TIFFTAG_MODEL:
_TIFFsetString(&td->td_model, va_arg(ap, char*));
break;
case TIFFTAG_COPYRIGHT:
_TIFFsetString(&td->td_copyright, va_arg(ap, char*));
break;
case TIFFTAG_ORIENTATION:
v = va_arg(ap, int);
if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) {
TIFFWarning(tif->tif_name,
"Bad value %ld for \"%s\" tag ignored",
v, _TIFFFieldWithTag(tif, tag)->field_name);
} else
td->td_orientation = (uint16) v;
break;
case TIFFTAG_SAMPLESPERPIXEL:
/* XXX should cross check -- e.g. if pallette, then 1 */
v = va_arg(ap, int);
if (v == 0)
goto badvalue;
td->td_samplesperpixel = (uint16) v;
break;
case TIFFTAG_ROWSPERSTRIP:
v32 = va_arg(ap, uint32);
if (v32 == 0)
goto badvalue32;
td->td_rowsperstrip = v32;
if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) {
td->td_tilelength = v32;
td->td_tilewidth = td->td_imagewidth;
}
break;
case TIFFTAG_MINSAMPLEVALUE:
td->td_minsamplevalue = (uint16) va_arg(ap, int);
break;
case TIFFTAG_MAXSAMPLEVALUE:
td->td_maxsamplevalue = (uint16) va_arg(ap, int);
break;
case TIFFTAG_SMINSAMPLEVALUE:
td->td_sminsamplevalue = (double) va_arg(ap, dblparam_t);
break;
case TIFFTAG_SMAXSAMPLEVALUE:
示例12: LZWPreDecode
/*
* Setup state for decoding a strip.
*/
static int
LZWPreDecode(TIFF* tif, tsample_t s)
{
LZWCodecState *sp = DecoderState(tif);
(void) s;
assert(sp != NULL);
/*
* Check for old bit-reversed codes.
*/
if (tif->tif_rawdata[0] == 0 && (tif->tif_rawdata[1] & 0x1)) {
#ifdef LZW_COMPAT
if (!sp->dec_decode) {
TIFFWarning(tif->tif_name,
"Old-style LZW codes, convert file");
/*
* Override default decoding methods with
* ones that deal with the old coding.
* Otherwise the predictor versions set
* above will call the compatibility routines
* through the dec_decode method.
*/
tif->tif_decoderow = LZWDecodeCompat;
tif->tif_decodestrip = LZWDecodeCompat;
tif->tif_decodetile = LZWDecodeCompat;
/*
* If doing horizontal differencing, must
* re-setup the predictor logic since we
* switched the basic decoder methods...
*/
(*tif->tif_setupdecode)(tif);
sp->dec_decode = LZWDecodeCompat;
}
sp->lzw_maxcode = MAXCODE(BITS_MIN);
#else /* !LZW_COMPAT */
if (!sp->dec_decode) {
TIFFError(tif->tif_name,
"Old-style LZW codes not supported");
sp->dec_decode = LZWDecode;
}
return (0);
#endif/* !LZW_COMPAT */
} else {
sp->lzw_maxcode = MAXCODE(BITS_MIN)-1;
sp->dec_decode = LZWDecode;
}
sp->lzw_nbits = BITS_MIN;
sp->lzw_nextbits = 0;
sp->lzw_nextdata = 0;
sp->dec_restart = 0;
sp->dec_nbitsmask = MAXCODE(BITS_MIN);
#ifdef LZW_CHECKEOS
sp->dec_bitsleft = tif->tif_rawcc << 3;
#endif
sp->dec_free_entp = sp->dec_codetab + CODE_FIRST;
/*
* Zero entries that are not yet filled in. We do
* this to guard against bogus input data that causes
* us to index into undefined entries. If you can
* come up with a way to safely bounds-check input codes
* while decoding then you can remove this operation.
*/
_TIFFmemset(sp->dec_free_entp, 0, (CSIZE-CODE_FIRST)*sizeof (code_t));
sp->dec_oldcodep = &sp->dec_codetab[-1];
sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask-1];
return (1);
}
示例13: TIFFImageIterBegin
//.........这里部分代码省略.........
return (0);
}
}
switch (img->photometric) {
case PHOTOMETRIC_PALETTE:
if (!TIFFGetField(tif, TIFFTAG_COLORMAP,
&img->redcmap, &img->greencmap, &img->bluecmap)) {
TIFFError(TIFFFileName(tif), "Missing required \"Colormap\" tag");
return (0);
}
/* fall thru... */
case PHOTOMETRIC_MINISWHITE:
case PHOTOMETRIC_MINISBLACK:
/* This should work now so skip the check - BSR
if (planarconfig == PLANARCONFIG_CONTIG && img->samplesperpixel != 1) {
sprintf(emsg,
"Sorry, can not handle contiguous data with %s=%d, and %s=%d",
photoTag, img->photometric,
"Samples/pixel", img->samplesperpixel);
return (0);
}
*/
break;
case PHOTOMETRIC_YCBCR:
if (planarconfig != PLANARCONFIG_CONTIG) {
sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d",
"Planarconfiguration", planarconfig);
return (0);
}
/* It would probably be nice to have a reality check here. */
{ uint16 compress;
TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
if (compress == COMPRESSION_JPEG && planarconfig == PLANARCONFIG_CONTIG) {
/* can rely on libjpeg to convert to RGB */
/* XXX should restore current state on exit */
TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
img->photometric = PHOTOMETRIC_RGB;
}
}
break;
case PHOTOMETRIC_RGB:
if (colorchannels < 3) {
sprintf(emsg, "Sorry, can not handle RGB image with %s=%d",
"Color channels", colorchannels);
return (0);
}
break;
case PHOTOMETRIC_SEPARATED: {
uint16 inkset;
TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
if (inkset != INKSET_CMYK) {
sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
"InkSet", inkset);
return (0);
}
if (img->samplesperpixel != 4) {
sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
"Samples/pixel", img->samplesperpixel);
return (0);
}
break;
}
default:
sprintf(emsg, "Sorry, can not handle image with %s=%d",
photoTag, img->photometric);
return (0);
}
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height);
TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation);
switch (img->orientation) {
case ORIENTATION_BOTRIGHT:
case ORIENTATION_RIGHTBOT: /* XXX */
case ORIENTATION_LEFTBOT: /* XXX */
TIFFWarning(TIFFFileName(tif), "using bottom-left orientation");
img->orientation = ORIENTATION_BOTLEFT;
/* fall thru... */
case ORIENTATION_BOTLEFT:
break;
case ORIENTATION_TOPRIGHT:
case ORIENTATION_RIGHTTOP: /* XXX */
case ORIENTATION_LEFTTOP: /* XXX */
default:
TIFFWarning(TIFFFileName(tif), "using top-left orientation");
img->orientation = ORIENTATION_TOPLEFT;
/* fall thru... */
case ORIENTATION_TOPLEFT:
break;
}
img->isContig =
!(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1);
if (img->isContig) {
img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig;
} else {
img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate;
}
return (1);
}
示例14: printTIF
void
printTIF(TIFF* tif, uint16 pageNumber)
{
uint32 w, h;
uint16 unit, compression;
float xres, yres, scale = 1.0;
tstrip_t s, ns;
time_t creation_time;
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
if (!TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression)
|| compression < COMPRESSION_CCITTRLE
|| compression > COMPRESSION_CCITT_T6)
return;
if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) || !xres) {
TIFFWarning(TIFFFileName(tif),
"No x-resolution, assuming %g dpi", defxres);
xres = defxres;
}
if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) || !yres) {
TIFFWarning(TIFFFileName(tif),
"No y-resolution, assuming %g lpi", defyres);
yres = defyres; /* XXX */
}
if (TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &unit) &&
unit == RESUNIT_CENTIMETER) {
xres *= 2.54F;
yres *= 2.54F;
}
if (pageWidth == 0)
pageWidth = w / xres;
if (pageHeight == 0)
pageHeight = h / yres;
printf("%%!PS-Adobe-3.0\n");
printf("%%%%Creator: fax2ps\n");
#ifdef notdef
printf("%%%%Title: %s\n", file);
#endif
creation_time = time(0);
printf("%%%%CreationDate: %s", ctime(&creation_time));
printf("%%%%Origin: 0 0\n");
printf("%%%%BoundingBox: 0 0 %u %u\n",
(int)(pageWidth * points), (int)(pageHeight * points)); /* XXX */
printf("%%%%Pages: (atend)\n");
printf("%%%%EndComments\n");
printf("%%%%BeginProlog\n");
emitFont(stdout);
printf("/d{bind def}def\n"); /* bind and def proc */
printf("/m{0 exch moveto}d\n");
printf("/s{show}d\n");
printf("/p{showpage}d \n"); /* end page */
printf("%%%%EndProlog\n");
printf("%%%%Page: \"%u\" %u\n", pageNumber, pageNumber);
printf("/$pageTop save def gsave\n");
if (scaleToPage)
scale = pageHeight / (h/yres) < pageWidth / (w/xres) ?
pageHeight / (h/yres) : pageWidth / (w/xres);
printf("%g %g translate\n",
points * (pageWidth - scale*w/xres) * half,
points * (scale*h/yres + (pageHeight - scale*h/yres) * half));
printf("%g %g scale\n", points/xres*scale, -points/yres*scale);
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++;
}
示例15: cpTiff
static int cpTiff(TIFF* in, TIFF* out,
const uint16_t iLayer, const uint16_t nLayer)
{
uint16_t samplesperpixel;
uint16_t orientation;
uint32_t width, length, rowsperstrip;
// Image size and memory layout.
CopyField(TIFFTAG_IMAGEWIDTH, width);
CopyField(TIFFTAG_IMAGELENGTH, length);
{
/*
* RowsPerStrip is left unspecified: use either the
* value from the input image or, if nothing is defined,
* use the library default.
*/
if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) {
rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip);
}
if (rowsperstrip > length && rowsperstrip != (uint32_t)-1) {
rowsperstrip = length;
}
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
}
CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
if (samplesperpixel <= 4)
CopyTag(TIFFTAG_TRANSFERFUNCTION, 4, TIFF_SHORT);
// Image orientation (per page).
TIFFGetFieldDefaulted(in, TIFFTAG_ORIENTATION, &orientation);
switch (orientation) {
case ORIENTATION_BOTRIGHT:
case ORIENTATION_RIGHTBOT: /* XXX */
TIFFWarning(TIFFFileName(in), "using bottom-left orientation");
orientation = ORIENTATION_BOTLEFT;
/* fall thru... */
case ORIENTATION_LEFTBOT: /* XXX */
case ORIENTATION_BOTLEFT:
break;
case ORIENTATION_TOPRIGHT:
case ORIENTATION_RIGHTTOP: /* XXX */
default:
TIFFWarning(TIFFFileName(in), "using top-left orientation");
orientation = ORIENTATION_TOPLEFT;
/* fall thru... */
case ORIENTATION_LEFTTOP: /* XXX */
case ORIENTATION_TOPLEFT:
break;
}
TIFFSetField(out, TIFFTAG_ORIENTATION, orientation);
// Colormap profile.
{
uint32_t len32;
void** data;
if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data))
TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data);
}
{
uint16_t ninks;
const char* inknames;
if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) {
TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks);
if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) {
int inknameslen = strlen(inknames) + 1;
const char* cp = inknames;
while (ninks > 1) {
cp = strchr(cp, '\0');
cp++;
inknameslen += (strlen(cp) + 1);
ninks--;
}
TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames);
}
}
}
// Page number.
TIFFSetField(out, TIFFTAG_PAGENUMBER, iLayer, nLayer);
// Rest of the tags, directly copy them.
for (struct defTagList *t = tags; t < &tags[NTAGS]; t++)
CopyTag(t->tag, t->count,t->type);
return cpData(in, out, length);
}