本文整理汇总了C++中TIFFFdOpen函数的典型用法代码示例。如果您正苦于以下问题:C++ TIFFFdOpen函数的具体用法?C++ TIFFFdOpen怎么用?C++ TIFFFdOpen使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIFFFdOpen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TIFFOpenW
/*
* Open a TIFF file with a Unicode filename, for read/writing.
*/
TIFF*
TIFFOpenW(const wchar_t* name, const char* mode)
{
static const char module[] = "TIFFOpenW";
thandle_t fd;
int m;
DWORD dwMode;
int mbsize;
char *mbname;
TIFF *tif;
m = _TIFFgetMode(mode, module);
switch(m) {
case O_RDONLY: dwMode = OPEN_EXISTING; break;
case O_RDWR: dwMode = OPEN_ALWAYS; break;
case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break;
case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break;
case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break;
default: return ((TIFF*)0);
}
fd = (thandle_t)CreateFileW(name,
(m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE),
FILE_SHARE_READ, NULL, dwMode,
(m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
NULL);
if (fd == INVALID_HANDLE_VALUE) {
TIFFError(module, "%S: Cannot open", name);
return ((TIFF *)0);
}
mbname = NULL;
mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
if (mbsize > 0) {
mbname = _TIFFmalloc(mbsize);
if (!mbname) {
TIFFError(module,
"Can't allocate space for filename conversion buffer");
return ((TIFF*)0);
}
WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize,
NULL, NULL);
}
tif = TIFFFdOpen((int)fd,
(mbname != NULL) ? mbname : "<unknown>", mode);
_TIFFfree(mbname);
return tif;
}
示例2: TIFFOpen
/*
* Open a TIFF file for read/writing.
*/
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
Str255 pname;
FInfo finfo;
short fref;
OSErr err;
FSSpec fSpec;
strcpy((char*) pname, name);
ourc2pstr((char*) pname);
err = FSMakeFSSpec( 0, 0, pname, &fSpec );
switch (_TIFFgetMode(mode, module)) {
default:
return ((TIFF*) 0);
case O_RDWR | O_CREAT | O_TRUNC:
if (FSpGetFInfo(&fSpec, &finfo) == noErr)
FSpDelete(&fSpec);
/* fall through */
case O_RDWR | O_CREAT:
if ((err = FSpGetFInfo(&fSpec, &finfo)) == fnfErr) {
if (FSpCreate(&fSpec, ' ', 'TIFF', smSystemScript) != noErr)
goto badCreate;
if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr)
goto badOpen;
} else if (err == noErr) {
if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr)
goto badOpen;
} else
goto badOpen;
break;
case O_RDONLY:
if (FSpOpenDF(&fSpec, fsRdPerm, &fref) != noErr)
goto badOpen;
break;
case O_RDWR:
if (FSpOpenDF(&fSpec, fsRdWrPerm, &fref) != noErr)
goto badOpen;
break;
}
return (TIFFFdOpen((int) fref, name, mode));
badCreate:
TIFFErrorExt(0, module, "%s: Cannot create", name);
return ((TIFF*) 0);
badOpen:
TIFFErrorExt(0, module, "%s: Cannot open", name);
return ((TIFF*) 0);
}
示例3: readQFile
static int
readQFile(int fd, char* qfile, int beingReceived, struct stat* sb)
{
int ok = 0;
TIFF* tif = TIFFFdOpen(fd, qfile, "r");
if (tif) {
ok = isFAXImage(tif);
if (ok) {
u_long pageWidth, pageLength;
char* cp;
char sender[80];
char date[30];
float resolution = 98;
int c, i, npages;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &pageWidth);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &pageLength);
if (TIFFGetField(tif, TIFFTAG_YRESOLUTION, &resolution)) {
u_short resunit = RESUNIT_NONE;
TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &resunit);
if (resunit == RESUNIT_CENTIMETER)
resolution *= 25.4;
} else
resolution = 98;
if (TIFFGetField(tif, TIFFTAG_IMAGEDESCRIPTION, &cp))
sanitize(sender, cp, sizeof (sender));
else
strcpy(sender, "<unknown>");
if (TIFFGetField(tif, TIFFTAG_DATETIME, &cp))
sanitize(date, cp, sizeof (date));
else
strftime(date, sizeof (date), "%Y:%m:%d %H:%M:%S",
localtime(&sb->st_mtime));
npages = 0;
do {
npages++;
} while (TIFFReadDirectory(tif));
if (version > 0)
sendClient("recvJob", "%d:%lu:%lu:%3.1f:%u:%s:%s",
beingReceived, pageWidth, pageLength, resolution,
npages, date, sender);
else
sendClient("recvJob", "%d:%lu:%lu:%3.1f:%u:%u:%s",
beingReceived, pageWidth, pageLength, resolution,
npages, sb->st_mtime, sender);
}
TIFFClose(tif);
}
return (ok);
}
示例4: TIFFOpen
/*
* Open a TIFF file for read/writing.
*/
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
int m, fd;
TIFF *ret;
m = _TIFFgetMode(mode, module);
if (m == -1)
return ((TIFF*)0);
fd = open(name, m|O_BINARY, 0666);
if (fd < 0) {
TIFFErrorExt(0, module, "%s: Cannot open", name);
return ((TIFF*)0);
}
return (TIFFFdOpen(fd, name, mode));
ret = TIFFFdOpen(fd, name, mode);
if (ret == NULL) close(fd);
return ret;
}
示例5: XTIFFFdOpen
TIFF*
XTIFFFdOpen(int fd, const char* name, const char* mode)
{
TIFF *tif;
/* Set up the callback */
XTIFFInitialize();
/* Open the file; the callback will set everything up
*/
tif = TIFFFdOpen(fd, name, mode);
if (!tif) return tif;
return tif;
}
示例6: tiff_from_filep
TIFF *
tiff_from_filep(const char *name, FILE *filep, int big_endian)
{
int fd;
#ifdef __WIN32__
fd = _get_osfhandle(fileno(filep));
#else
fd = fileno(filep);
#endif
if (fd < 0)
return NULL;
return TIFFFdOpen(fd, name, big_endian ? "wb" : "wl");
}
示例7: TIFFOpenW
/*
* Open a TIFF file with a Unicode filename, for read/writing.
*/
TIFF*
TIFFOpenW(const wchar_t* name, const char* mode)
{
static const char module[] = "TIFFOpenW";
int m, fd;
int mbsize;
char *mbname;
TIFF* tif;
m = _TIFFgetMode(mode, module);
if (m == -1)
return ((TIFF*)0);
/* for cygwin and mingw */
#ifdef O_BINARY
m |= O_BINARY;
#endif
fd = _wopen(name, m, 0666);
if (fd < 0) {
TIFFErrorExt(0, module, "%s: Cannot open", name);
return ((TIFF *)0);
}
mbname = NULL;
mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
if (mbsize > 0) {
mbname = _TIFFmalloc(mbsize);
if (!mbname) {
TIFFErrorExt(0, module,
"Can't allocate space for filename conversion buffer");
return ((TIFF*)0);
}
WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize,
NULL, NULL);
}
tif = TIFFFdOpen((int)fd, (mbname != NULL) ? mbname : "<unknown>",
mode);
_TIFFfree(mbname);
if(!tif)
close(fd);
return tif;
}
示例8: createTiffGeneratorDirect
static void
createTiffGeneratorDirect(const char * const outputFileName,
CreatePolicy const createPolicy,
TIFF ** const tifPP,
int * const ofdP) {
/*----------------------------------------------------------------------------
Create a TIFF generator that writes its output to the specified file.
If the file doesn't already exist and 'createPolicy' is MayCreate,
create the file; otherwise fail the program.
Fail the program if the specified file is not seekable and readable.
Return the handle of the TIFF generator as *tifPP. Also return the
file descriptor for the output file as *ofdP.
-----------------------------------------------------------------------------*/
int fd;
if (createPolicy == MUST_EXIST)
fd = open(outputFileName, O_RDWR);
else
fd = open(outputFileName, (O_RDWR | O_CREAT), 00644);
if (fd == -1) {
if (errno == ENOENT) /* Possible only if MustExist */
pm_error ("Cannot open file : '%s'. File does not exist.",
outputFileName);
else
pm_error ("Cannot open file : '%s'. open() failed with "
"errno %d (%s). ",
outputFileName, errno, strerror(errno));
}
if (!fileIsSeekable(fd, outputFileName))
pm_error("Output file (%s) is not seekable. "
"lseek() returned errno %d (%s). "
"The TIFF library can write only to "
"a seekable file.",
outputFileName, errno, strerror(errno));
*tifPP = TIFFFdOpen(fd, outputFileName, "a");
if (*tifPP == NULL)
pm_error("error opening file %s as TIFF file. "
"TIFFFdOpen() failed.", outputFileName);
*ofdP = fd;
}
示例9: TIFFOpen
/*
* Open a TIFF file for read/writing.
*/
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
thandle_t fd;
int m;
DWORD dwMode;
TIFF* tif;
m = _TIFFgetMode(mode, module);
switch(m)
{
case O_RDONLY:
dwMode = OPEN_EXISTING;
break;
case O_RDWR:
dwMode = OPEN_ALWAYS;
break;
case O_RDWR|O_CREAT:
dwMode = OPEN_ALWAYS;
break;
case O_RDWR|O_TRUNC:
dwMode = CREATE_ALWAYS;
break;
case O_RDWR|O_CREAT|O_TRUNC:
dwMode = CREATE_ALWAYS;
break;
default:
return ((TIFF*)0);
}
fd = (thandle_t)CreateFileA(name,
(m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE),
FILE_SHARE_READ, NULL, dwMode,
(m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
NULL);
if (fd == INVALID_HANDLE_VALUE) {
TIFFError(module, "%s: Cannot open", name);
return ((TIFF *)0);
}
tif = TIFFFdOpen((int)fd, name, mode);
if(!tif)
CloseHandle(fd);
return tif;
}
示例10: TIFFOpen
/*
* Open a TIFF file for read/writing.
*/
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
Str255 pname;
FInfo finfo;
short fref;
OSErr err;
strcpy((char*) pname, name);
CtoPstr((char*) pname);
switch (_TIFFgetMode(mode, module)) {
default:
return ((TIFF*) 0);
case O_RDWR | O_CREAT | O_TRUNC:
if (GetFInfo(pname, 0, &finfo) == noErr)
FSDelete(pname, 0);
/* fall through */
case O_RDWR | O_CREAT:
if ((err = GetFInfo(pname, 0, &finfo)) == fnfErr) {
if (Create(pname, 0, ' ', 'TIFF') != noErr)
goto badCreate;
if (FSOpen(pname, 0, &fref) != noErr)
goto badOpen;
} else if (err == noErr) {
if (FSOpen(pname, 0, &fref) != noErr)
goto badOpen;
} else
goto badOpen;
break;
case O_RDONLY:
case O_RDWR:
if (FSOpen(pname, 0, &fref) != noErr)
goto badOpen;
break;
}
return (TIFFFdOpen((int) fref, name, mode));
badCreate:
TIFFError(module, "%s: Cannot create", name);
return ((TIFF*) 0);
badOpen:
TIFFError(module, "%s: Cannot open", name);
return ((TIFF*) 0);
}
示例11: TIFFOpen
/*
* Open a TIFF file for read/writing.
*/
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
int fd;
TIFF* tif;
fd = fioOpen(name, O_RDONLY);
if (fd < 0) {
TIFFError(module, "%s: Cannot open", name);
return ((TIFF *)0);
}
tif = TIFFFdOpen((int)fd, name, mode);
if(!tif)
fioClose(fd);
return tif;
}
示例12: gdk_pixbuf__tiff_image_load
static GdkPixbuf *
gdk_pixbuf__tiff_image_load (FILE *f, GError **error)
{
TIFF *tiff;
int fd;
GdkPixbuf *pixbuf;
g_return_val_if_fail (f != NULL, NULL);
tiff_push_handlers ();
fd = fileno (f);
/* On OSF, apparently fseek() works in some on-demand way, so
* the fseek gdk_pixbuf_new_from_file() doesn't work here
* since we are using the raw file descriptor. So, we call lseek() on the fd
* before using it. (#60840)
*/
lseek (fd, 0, SEEK_SET);
tiff = TIFFFdOpen (fd, "libpixbuf-tiff", "r");
if (!tiff || global_error) {
tiff_set_error (error,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Failed to open TIFF image"));
tiff_pop_handlers ();
return NULL;
}
pixbuf = tiff_image_parse (tiff, NULL, error);
TIFFClose (tiff);
if (global_error) {
tiff_set_error (error,
GDK_PIXBUF_ERROR_FAILED,
_("TIFFClose operation failed"));
}
tiff_pop_handlers ();
return pixbuf;
}
示例13: TIFFOpen
/*
* Open a TIFF file for read/writing.
*/
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
int m, fd;
m = _TIFFgetMode(mode, module);
if (m == -1)
return ((TIFF*)0);
#ifdef _AM29K
fd = open(name, m);
#else
fd = open(name, m, 0666);
#endif
if (fd < 0) {
TIFFError(module, "%s: Cannot open", name);
return ((TIFF *)0);
}
return (TIFFFdOpen(fd, name, mode));
}
示例14: TIFFOpen
/*
* Open a TIFF file for read/writing.
*/
TIFF*
TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
int m, fd;
m = _TIFFgetMode(mode, module);
if (m == -1)
{
return ((TIFF*) 0);
}
fd = open(name, 0, m);
if (fd < 0)
{
TIFFError(module, "%s: Cannot open", name);
return ((TIFF *)0);
}
return (TIFFFdOpen(fd, name, mode));
}
示例15: tiff_write
static int
tiff_write(FILE *fp, struct ida_image *img)
{
TIFF *TiffHndl;
tdata_t buf;
unsigned int y;
TiffHndl = TIFFFdOpen(fileno(fp),"42.tiff","w");
if (TiffHndl == NULL)
return -1;
TIFFSetField(TiffHndl, TIFFTAG_IMAGEWIDTH, img->i.width);
TIFFSetField(TiffHndl, TIFFTAG_IMAGELENGTH, img->i.height);
TIFFSetField(TiffHndl, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(TiffHndl, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField(TiffHndl, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(TiffHndl, TIFFTAG_SAMPLESPERPIXEL, 3);
TIFFSetField(TiffHndl, TIFFTAG_ROWSPERSTRIP, 2);
TIFFSetField(TiffHndl, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
#if 0 /* fixme: make this configureable */
TIFFSetField(TiffHndl, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
TIFFSetField(TiffHndl, TIFFTAG_PREDICTOR, 2);
#endif
if (img->i.dpi) {
float dpi = img->i.dpi;
TIFFSetField(TiffHndl, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
TIFFSetField(TiffHndl, TIFFTAG_XRESOLUTION, dpi);
TIFFSetField(TiffHndl, TIFFTAG_YRESOLUTION, dpi);
}
for (y = 0; y < img->i.height; y++) {
buf = img->data + 3*img->i.width*y;
TIFFWriteScanline(TiffHndl, buf, y, 0);
}
TIFFClose(TiffHndl);
return 0;
}