?? tif_open.c
字號:
*/ TIFFInitOrder(tif, tif->tif_header.tiff_magic); /* * Setup default directory. */ if (!TIFFDefaultDirectory(tif)) goto bad; tif->tif_diroff = 0; tif->tif_dirlist = NULL; tif->tif_dirlistsize = 0; tif->tif_dirnumber = 0; return (tif); } /* * Setup the byte order handling. */ if (tif->tif_header.tiff_magic != TIFF_BIGENDIAN && tif->tif_header.tiff_magic != TIFF_LITTLEENDIAN#if MDI_SUPPORT &&#if HOST_BIGENDIAN tif->tif_header.tiff_magic != MDI_BIGENDIAN#else tif->tif_header.tiff_magic != MDI_LITTLEENDIAN#endif ) { TIFFErrorExt(tif->tif_clientdata, name, "Not a TIFF or MDI file, bad magic number %d (0x%x)",#else ) { TIFFErrorExt(tif->tif_clientdata, name, "Not a TIFF file, bad magic number %d (0x%x)",#endif tif->tif_header.tiff_magic, tif->tif_header.tiff_magic); goto bad; } TIFFInitOrder(tif, tif->tif_header.tiff_magic); /* * Swap header if required. */ if (tif->tif_flags & TIFF_SWAB) { TIFFSwabShort(&tif->tif_header.tiff_version); TIFFSwabLong(&tif->tif_header.tiff_diroff); } /* * Now check version (if needed, it's been byte-swapped). * Note that this isn't actually a version number, it's a * magic number that doesn't change (stupid). */ if (tif->tif_header.tiff_version == TIFF_BIGTIFF_VERSION) { TIFFErrorExt(tif->tif_clientdata, name, "This is a BigTIFF file. This format not supported\n" "by this version of libtiff." ); goto bad; } if (tif->tif_header.tiff_version != TIFF_VERSION) { TIFFErrorExt(tif->tif_clientdata, name, "Not a TIFF file, bad version number %d (0x%x)", tif->tif_header.tiff_version, tif->tif_header.tiff_version); goto bad; } tif->tif_flags |= TIFF_MYBUFFER; tif->tif_rawcp = tif->tif_rawdata = 0; tif->tif_rawdatasize = 0; /* * Sometimes we do not want to read the first directory (for example, * it may be broken) and want to proceed to other directories. I this * case we use the TIFF_HEADERONLY flag to open file and return * immediately after reading TIFF header. */ if (tif->tif_flags & TIFF_HEADERONLY) return (tif); /* * Setup initial directory. */ switch (mode[0]) { case 'r': tif->tif_nextdiroff = tif->tif_header.tiff_diroff; /* * Try to use a memory-mapped file if the client * has not explicitly suppressed usage with the * 'm' flag in the open mode (see above). */ if ((tif->tif_flags & TIFF_MAPPED) && !TIFFMapFileContents(tif, (tdata_t*) &tif->tif_base, &tif->tif_size)) tif->tif_flags &= ~TIFF_MAPPED; if (TIFFReadDirectory(tif)) { tif->tif_rawcc = -1; tif->tif_flags |= TIFF_BUFFERSETUP; return (tif); } break; case 'a': /* * New directories are automatically append * to the end of the directory chain when they * are written out (see TIFFWriteDirectory). */ if (!TIFFDefaultDirectory(tif)) goto bad; return (tif); }bad: tif->tif_mode = O_RDONLY; /* XXX avoid flush */ TIFFCleanup(tif);bad2: return ((TIFF*)0);}/* * Query functions to access private data. *//* * Return open file's name. */const char *TIFFFileName(TIFF* tif){ return (tif->tif_name);}/* * Set the file name. */const char *TIFFSetFileName(TIFF* tif, const char *name){ const char* old_name = tif->tif_name; tif->tif_name = (char *)name; return (old_name);}/* * Return open file's I/O descriptor. */intTIFFFileno(TIFF* tif){ return (tif->tif_fd);}/* * Set open file's I/O descriptor, and return previous value. */intTIFFSetFileno(TIFF* tif, int fd){ int old_fd = tif->tif_fd; tif->tif_fd = fd; return old_fd;}/* * Return open file's clientdata. */thandle_tTIFFClientdata(TIFF* tif){ return (tif->tif_clientdata);}/* * Set open file's clientdata, and return previous value. */thandle_tTIFFSetClientdata(TIFF* tif, thandle_t newvalue){ thandle_t m = tif->tif_clientdata; tif->tif_clientdata = newvalue; return m;}/* * Return read/write mode. */intTIFFGetMode(TIFF* tif){ return (tif->tif_mode);}/* * Return read/write mode. */intTIFFSetMode(TIFF* tif, int mode){ int old_mode = tif->tif_mode; tif->tif_mode = mode; return (old_mode);}/* * Return nonzero if file is organized in * tiles; zero if organized as strips. */intTIFFIsTiled(TIFF* tif){ return (isTiled(tif));}/* * Return current row being read/written. */uint32TIFFCurrentRow(TIFF* tif){ return (tif->tif_row);}/* * Return index of the current directory. */tdir_tTIFFCurrentDirectory(TIFF* tif){ return (tif->tif_curdir);}/* * Return current strip. */tstrip_tTIFFCurrentStrip(TIFF* tif){ return (tif->tif_curstrip);}/* * Return current tile. */ttile_tTIFFCurrentTile(TIFF* tif){ return (tif->tif_curtile);}/* * Return nonzero if the file has byte-swapped data. */intTIFFIsByteSwapped(TIFF* tif){ return ((tif->tif_flags & TIFF_SWAB) != 0);}/* * Return nonzero if the data is returned up-sampled. */intTIFFIsUpSampled(TIFF* tif){ return (isUpSampled(tif));}/* * Return nonzero if the data is returned in MSB-to-LSB bit order. */intTIFFIsMSB2LSB(TIFF* tif){ return (isFillOrder(tif, FILLORDER_MSB2LSB));}/* * Return nonzero if given file was written in big-endian order. */intTIFFIsBigEndian(TIFF* tif){ return (tif->tif_header.tiff_magic == TIFF_BIGENDIAN);}/* * Return pointer to file read method. */TIFFReadWriteProcTIFFGetReadProc(TIFF* tif){ return (tif->tif_readproc);}/* * Return pointer to file write method. */TIFFReadWriteProcTIFFGetWriteProc(TIFF* tif){ return (tif->tif_writeproc);}/* * Return pointer to file seek method. */TIFFSeekProcTIFFGetSeekProc(TIFF* tif){ return (tif->tif_seekproc);}/* * Return pointer to file close method. */TIFFCloseProcTIFFGetCloseProc(TIFF* tif){ return (tif->tif_closeproc);}/* * Return pointer to file size requesting method. */TIFFSizeProcTIFFGetSizeProc(TIFF* tif){ return (tif->tif_sizeproc);}/* * Return pointer to memory mapping method. */TIFFMapFileProcTIFFGetMapFileProc(TIFF* tif){ return (tif->tif_mapproc);}/* * Return pointer to memory unmapping method. */TIFFUnmapFileProcTIFFGetUnmapFileProc(TIFF* tif){ return (tif->tif_unmapproc);}/* vim: set ts=8 sts=8 sw=8 noet: */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -