本文整理汇总了C++中TIFFFileName函数的典型用法代码示例。如果您正苦于以下问题:C++ TIFFFileName函数的具体用法?C++ TIFFFileName怎么用?C++ TIFFFileName使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIFFFileName函数的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: cpData
static int cpData(TIFF *in, TIFF *out, const uint32_t nrow) {
tsize_t scSize = TIFFScanlineSize(in);
tdata_t buf = _TIFFmalloc(scSize);
if (!buf)
return 0;
_TIFFmemset(buf, 0, scSize);
for (uint32_t irow = 0; irow < nrow; irow++) {
try {
if (TIFFReadScanline(in, buf, irow, 0) < 0) {
throw -1;
}
if (TIFFWriteScanline(out, buf, irow, 0) < 0) {
throw -2;
}
} catch (int err) {
if (err == -1) {
std::cerr << "Cannot read scanline " << irow;
std::cerr << " from " << TIFFFileName(in) << std::endl;
} else if (err == -2) {
std::cerr << "Cannot write scanline " << irow;
std::cerr << " to " << TIFFFileName(out) << std::endl;
} else {
std::cerr << "Unknown error during row copy" << std::endl;
}
_TIFFfree(buf);
return 0;
}
}
_TIFFfree(buf);
return 1;
}
示例4: tiffcvt
static int
tiffcvt(TIFF* in, TIFF* out)
{
uint32 width, height; /* image width & height */
uint32* raster; /* retrieve RGBA image */
uint16 shortv;
float floatv;
char *stringv;
uint32 longv;
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height);
raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32));
if (raster == 0) {
TIFFError(TIFFFileName(in), "No space for raster buffer");
return (0);
}
if (!TIFFReadRGBAImage(in, width, height, raster, 0)) {
_TIFFfree(raster);
return (0);
}
CopyField(TIFFTAG_SUBFILETYPE, longv);
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(out, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR);
if (compression == COMPRESSION_JPEG)
TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RAW);
CopyField(TIFFTAG_FILLORDER, shortv);
TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3);
CopyField(TIFFTAG_XRESOLUTION, floatv);
CopyField(TIFFTAG_YRESOLUTION, floatv);
CopyField(TIFFTAG_RESOLUTIONUNIT, shortv);
TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
{ char buf[2048];
char *cp = strrchr(TIFFFileName(in), '/');
sprintf(buf, "YCbCr conversion of %s", cp ? cp+1 : TIFFFileName(in));
TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, buf);
}
TIFFSetField(out, TIFFTAG_SOFTWARE, TIFFGetVersion());
CopyField(TIFFTAG_DOCUMENTNAME, stringv);
TIFFSetField(out, TIFFTAG_REFERENCEBLACKWHITE, refBlackWhite);
TIFFSetField(out, TIFFTAG_YCBCRSUBSAMPLING,
horizSubSampling, vertSubSampling);
TIFFSetField(out, TIFFTAG_YCBCRPOSITIONING, YCBCRPOSITION_CENTERED);
TIFFSetField(out, TIFFTAG_YCBCRCOEFFICIENTS, ycbcrCoeffs);
rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip);
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
return (cvtRaster(out, raster, width, height));
}
示例5: 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++;
}
示例6: TIFFImageIterGet
int
TIFFImageIterGet(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
{
if (img->get == NULL) {
TIFFError(TIFFFileName(img->tif), "No \"get\" routine setup");
return (0);
}
if (img->callback.any == NULL) {
TIFFError(TIFFFileName(img->tif),
"No \"put\" routine setupl; probably can not handle image format");
return (0);
}
return (*img->get)(img, udata, w, h);
}
示例7: TIFFRGBAImageGet
int
TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
{
if (img->get == NULL) {
TIFFError(TIFFFileName(img->tif), "No \"get\" routine setup");
return (0);
}
if (img->put.any == NULL) {
TIFFError(TIFFFileName(img->tif),
"No \"put\" routine setupl; probably can not handle image format");
return (0);
}
return (*img->get)(img, raster, w, h);
}
示例8: TIFFError
/*
* 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;
}
示例9: setupMap
/*
* Construct a mapping table to convert from the range
* of the data samples to [0,255] --for display. This
* process also handles inverting B&W images when needed.
*/
static int
setupMap(TIFFRGBAImage* img)
{
int32 x, range;
range = (int32)((1L<<img->bitspersample)-1);
img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue));
if (img->Map == NULL) {
TIFFError(TIFFFileName(img->tif),
"No space for photometric conversion table");
return (0);
}
if (img->photometric == PHOTOMETRIC_MINISWHITE) {
for (x = 0; x <= range; x++)
img->Map[x] = ((range - x) * 255) / range;
} else {
for (x = 0; x <= range; x++)
img->Map[x] = (x * 255) / range;
}
if (img->bitspersample <= 8 &&
(img->photometric == PHOTOMETRIC_MINISBLACK ||
img->photometric == PHOTOMETRIC_MINISWHITE)) {
/*
* Use photometric mapping table to construct
* unpacking tables for samples <= 8 bits.
*/
if (!makebwmap(img))
return (0);
/* no longer need Map, free it */
_TIFFfree(img->Map), img->Map = NULL;
}
return (1);
}
示例10: 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);
}
示例11: 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);
}
示例12: 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);
}
示例13: 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;
}
示例14: 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);
}
示例15: main
int
main(int argc, char* argv[])
{
TIFF *tif1, *tif2;
int c, dirnum;
extern int optind;
while ((c = getopt(argc, argv, "ltz")) != -1)
switch (c) {
case 'l':
stopondiff = 0;
break;
case 'z':
stopondiff += 100;
break;
case 't':
stoponfirsttag = 0;
break;
case '?':
usage();
/*NOTREACHED*/
}
if (argc - optind < 2)
usage();
tif1 = TIFFOpen(argv[optind], "r");
if (tif1 == NULL)
return (-1);
tif2 = TIFFOpen(argv[optind+1], "r");
if (tif2 == NULL)
return (-2);
dirnum = 0;
while (tiffcmp(tif1, tif2)) {
if (!TIFFReadDirectory(tif1)) {
if (!TIFFReadDirectory(tif2))
break;
printf("No more directories for %s\n",
TIFFFileName(tif1));
return (1);
} else if (!TIFFReadDirectory(tif2)) {
printf("No more directories for %s\n",
TIFFFileName(tif2));
return (1);
}
printf("Directory %d:\n", ++dirnum);
}
return (0);
}