本文整理汇总了C++中TIFFSwabArrayOfShort函数的典型用法代码示例。如果您正苦于以下问题:C++ TIFFSwabArrayOfShort函数的具体用法?C++ TIFFSwabArrayOfShort怎么用?C++ TIFFSwabArrayOfShort使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIFFSwabArrayOfShort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: swabHorAcc16
static int
swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc)
{
uint16* wp = (uint16*) cp0;
tmsize_t wc = cc / 2;
TIFFSwabArrayOfShort(wp, wc);
return horAcc16(tif, cp0, cc);
}
示例2: swabData
void swabData(int type, long size, void* data)
{
if (!swabflag) return;
if ( (type == TIFF_SHORT) || (type == TIFF_SSHORT) )
TIFFSwabArrayOfShort( (uint16*) data, size/2 );
if ( (type == TIFF_LONG) || (type == TIFF_SLONG) || (type == TIFF_FLOAT) )
TIFFSwabArrayOfLong( (uint32*) data, size/4 );
if (type == TIFF_RATIONAL)
TIFFSwabArrayOfLong( (uint32*) data, size/4 );
if (type == TIFF_DOUBLE)
TIFFSwabArrayOfDouble( (double*) data, size/8 );
}
示例3: swabHorAcc16
static void
swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc)
{
tmsize_t stride = PredictorState(tif)->stride;
uint16* wp = (uint16*) cp0;
tmsize_t wc = cc / 2;
assert((cc%(2*stride))==0);
if (wc > stride) {
TIFFSwabArrayOfShort(wp, wc);
wc -= stride;
do {
REPEAT4(stride, wp[stride] += wp[0]; wp++)
wc -= stride;
} while (wc > 0);
}
示例4: TIFFWriteData
/*
* Write a contiguous directory item.
*/
static int
TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp)
{
tsize_t cc;
if (tif->tif_flags & TIFF_SWAB) {
switch (dir->s.tdir_type) {
case TIFF_SHORT:
case TIFF_SSHORT:
TIFFSwabArrayOfShort((uint16*) cp, TDIRGetEntryCount(tif,dir));
break;
case TIFF_LONG:
case TIFF_SLONG:
case TIFF_IFD:
case TIFF_FLOAT:
TIFFSwabArrayOfLong((uint32*) cp, TDIRGetEntryCount(tif,dir));
break;
case TIFF_LONG8:
case TIFF_SLONG8:
case TIFF_IFD8:
TIFFSwabArrayOfLong8((uint64*) cp, TDIRGetEntryCount(tif,dir));
break;
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
TIFFSwabArrayOfLong((uint32*) cp, 2 * TDIRGetEntryCount(tif,dir));
break;
case TIFF_DOUBLE:
TIFFSwabArrayOfDouble((double*) cp, TDIRGetEntryCount(tif,dir));
break;
}
}
TDIRSetEntryOff(tif,dir,tif->tif_dataoff);
cc = TDIRGetEntryCount(tif,dir) * TIFFDataWidth((TIFFDataType) dir->s.tdir_type);
if (SeekOK(tif, tif->tif_dataoff) &&
WriteOK(tif, cp, cc)) {
tif->tif_dataoff += ((cc + 1) & ~1);
return (1);
}
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error writing data for field \"%s\" (%d)",
_TIFFFieldWithTag(tif, dir->s.tdir_tag)->field_name, TIFFGetErrno(tif));
return (0);
}
示例5: TIFFFetchData
/*
* Fetch a contiguous directory item.
*/
static tsize_t
TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp)
{
int w = tiffDataWidth[dir->tdir_type];
tsize_t cc = dir->tdir_count * w;
if (!isMapped(tif)) {
if (!SeekOK(tif, dir->tdir_offset))
goto bad;
if (!ReadOK(tif, cp, cc))
goto bad;
} else {
if (dir->tdir_offset + cc > tif->tif_size)
goto bad;
_TIFFmemcpy(cp, tif->tif_base + dir->tdir_offset, cc);
}
if (tif->tif_flags & TIFF_SWAB) {
switch (dir->tdir_type) {
case TIFF_SHORT:
case TIFF_SSHORT:
TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count);
break;
case TIFF_LONG:
case TIFF_SLONG:
case TIFF_FLOAT:
TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count);
break;
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count);
break;
case TIFF_DOUBLE:
TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count);
break;
}
}
return (cc);
bad:
TIFFError(tif->tif_name, "Error fetching data for field \"%s\"",
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
return ((tsize_t) 0);
}
示例6: swapBytesInScanline
static void
swapBytesInScanline(void *buf, uint32 width, TIFFDataType dtype)
{
switch (dtype) {
case TIFF_SHORT:
case TIFF_SSHORT:
TIFFSwabArrayOfShort((uint16*)buf,
(unsigned long)width);
break;
case TIFF_LONG:
case TIFF_SLONG:
TIFFSwabArrayOfLong((uint32*)buf,
(unsigned long)width);
break;
/* case TIFF_FLOAT: */ /* FIXME */
case TIFF_DOUBLE:
TIFFSwabArrayOfDouble((double*)buf,
(unsigned long)width);
break;
default:
break;
}
}
示例7: TIFFWriteData
/*
* Write a contiguous directory item.
*/
static int
TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp)
{
tsize_t cc;
if (tif->tif_flags & TIFF_SWAB) {
switch (dir->tdir_type) {
case TIFF_SHORT:
case TIFF_SSHORT:
TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count);
break;
case TIFF_LONG:
case TIFF_SLONG:
case TIFF_FLOAT:
TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count);
break;
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count);
break;
case TIFF_DOUBLE:
TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count);
break;
}
}
dir->tdir_offset = tif->tif_dataoff;
cc = dir->tdir_count * TIFFDataWidth((TIFFDataType) dir->tdir_type);
if (SeekOK(tif, dir->tdir_offset) &&
WriteOK(tif, cp, cc)) {
tif->tif_dataoff += (cc + 1) & ~1;
return (1);
}
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error writing data for field \"%s\"",
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
return (0);
}
示例8: _TIFFWriteCustomDirectory
static int
_TIFFWriteCustomDirectory(TIFF* tif, toff_t *pdiroff)
{
uint16 dircount;
uint32 nfields;
tsize_t dirsize;
char* data;
TIFFDirEntry* dir;
TIFFDirectory* td;
unsigned long b, fields[FIELD_SETLONGS];
int fi, nfi;
if (tif->tif_mode == O_RDONLY)
return (1);
td = &tif->tif_dir;
/*
* Size the directory so that we can calculate
* offsets for the data items that aren't kept
* in-place in each field.
*/
nfields = 0;
for (b = 0; b <= FIELD_LAST; b++)
if (TIFFFieldSet(tif, b) && b != FIELD_CUSTOM)
nfields += (b < FIELD_SUBFILETYPE ? 2 : 1);
nfields += td->td_customValueCount;
dirsize = nfields * sizeof (TIFFDirEntry);
data = (char*) _TIFFmalloc(dirsize);
if (data == NULL) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Cannot write directory, out of space");
return (0);
}
/*
* Put the directory at the end of the file.
*/
tif->tif_diroff = (TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1;
tif->tif_dataoff = (toff_t)(
tif->tif_diroff + sizeof (uint16) + dirsize + sizeof (toff_t));
if (tif->tif_dataoff & 1)
tif->tif_dataoff++;
(void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET);
dir = (TIFFDirEntry*) data;
/*
* Setup external form of directory
* entries and write data items.
*/
_TIFFmemcpy(fields, td->td_fieldsset, sizeof (fields));
for (fi = 0, nfi = tif->tif_nfields; nfi > 0; nfi--, fi++) {
const TIFFFieldInfo* fip = tif->tif_fieldinfo[fi];
/*
* For custom fields, we test to see if the custom field
* is set or not. For normal fields, we just use the
* FieldSet test.
*/
if( fip->field_bit == FIELD_CUSTOM )
{
int ci, is_set = FALSE;
for( ci = 0; ci < td->td_customValueCount; ci++ )
is_set |= (td->td_customValues[ci].info == fip);
if( !is_set )
continue;
}
else if (!FieldSet(fields, fip->field_bit))
continue;
if( fip->field_bit != FIELD_CUSTOM )
ResetFieldBit(fields, fip->field_bit);
}
/*
* Write directory.
*/
dircount = (uint16) nfields;
*pdiroff = (uint32) tif->tif_nextdiroff;
if (tif->tif_flags & TIFF_SWAB) {
/*
* The file's byte order is opposite to the
* native machine architecture. We overwrite
* the directory information with impunity
* because it'll be released below after we
* write it to the file. Note that all the
* other tag construction routines assume that
* we do this byte-swapping; i.e. they only
* byte-swap indirect data.
*/
for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) {
TIFFSwabArrayOfShort(&dir->tdir_tag, 2);
TIFFSwabArrayOfLong(&dir->tdir_count, 2);
}
dircount = (uint16) nfields;
TIFFSwabShort(&dircount);
TIFFSwabLong(pdiroff);
}
(void) TIFFSeekFile(tif, tif->tif_diroff, SEEK_SET);
if (!WriteOK(tif, &dircount, sizeof (dircount))) {
//.........这里部分代码省略.........
示例9: _TIFFWriteDirectory
//.........这里部分代码省略.........
if (!TIFFWriteInkNames(tif, dir))
goto bad;
break;
#endif
#ifdef COLORIMETRY_SUPPORT
case FIELD_TRANSFERFUNCTION:
if (!TIFFWriteTransferFunction(tif, dir))
goto bad;
break;
#endif
#if SUBIFD_SUPPORT
case FIELD_SUBIFD:
if (!TIFFWriteNormalTag(tif, dir, fip))
goto bad;
/*
* Total hack: if this directory includes a SubIFD
* tag then force the next <n> directories to be
* written as ``sub directories'' of this one. This
* is used to write things like thumbnails and
* image masks that one wants to keep out of the
* normal directory linkage access mechanism.
*/
if (dir->tdir_count > 0) {
tif->tif_flags |= TIFF_INSUBIFD;
tif->tif_nsubifd = (uint16) dir->tdir_count;
if (dir->tdir_count > 1)
tif->tif_subifdoff = dir->tdir_offset;
else
tif->tif_subifdoff = (uint32)(
tif->tif_diroff
+ sizeof (uint16)
+ ((char*)&dir->tdir_offset-data));
}
break;
#endif
default:
if (!TIFFWriteNormalTag(tif, dir, fip))
goto bad;
break;
}
dir++;
if( fip->field_bit != FIELD_CUSTOM )
ResetFieldBit(fields, fip->field_bit);
}
/*
* Write directory.
*/
dircount = (uint16) nfields;
diroff = (uint32) tif->tif_nextdiroff;
if (tif->tif_flags & TIFF_SWAB) {
/*
* The file's byte order is opposite to the
* native machine architecture. We overwrite
* the directory information with impunity
* because it'll be released below after we
* write it to the file. Note that all the
* other tag construction routines assume that
* we do this byte-swapping; i.e. they only
* byte-swap indirect data.
*/
for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) {
TIFFSwabArrayOfShort(&dir->tdir_tag, 2);
TIFFSwabArrayOfLong(&dir->tdir_count, 2);
}
dircount = (uint16) nfields;
TIFFSwabShort(&dircount);
TIFFSwabLong(&diroff);
}
(void) TIFFSeekFile(tif, tif->tif_diroff, SEEK_SET);
if (!WriteOK(tif, &dircount, sizeof (dircount))) {
TIFFError(tif->tif_name, "Error writing directory count");
goto bad;
}
if (!WriteOK(tif, data, dirsize)) {
TIFFError(tif->tif_name, "Error writing directory contents");
goto bad;
}
if (!WriteOK(tif, &diroff, sizeof (diroff))) {
TIFFError(tif->tif_name, "Error writing directory link");
goto bad;
}
if (done) {
TIFFFreeDirectory(tif);
tif->tif_flags &= ~TIFF_DIRTYDIRECT;
(*tif->tif_cleanup)(tif);
/*
* Reset directory-related state for subsequent
* directories.
*/
TIFFCreateDirectory(tif);
}
_TIFFfree(data);
return (1);
bad:
_TIFFfree(data);
return (0);
}
示例10: EXIFExtractMetadata
//.........这里部分代码省略.........
if (poTIFFDirEntry->tdir_count > MAXSTRINGLENGTH)
{
CPLError( CE_Warning, CPLE_AppDefined,
"Too many bytes in tag: %u, ignoring tag.",
poTIFFDirEntry->tdir_count );
}
else if (nDataWidth == 0 || poTIFFDirEntry->tdir_type >= TIFF_IFD )
{
CPLError( CE_Warning, CPLE_AppDefined,
"Invalid or unhandled EXIF data type: %d, ignoring tag.",
poTIFFDirEntry->tdir_type );
}
/* -------------------------------------------------------------------- */
/* This is at most 4 byte data so we can read it from tdir_offset */
/* -------------------------------------------------------------------- */
else if (space >= 0 && space <= 4) {
unsigned char data[4];
memcpy(data, &poTIFFDirEntry->tdir_offset, 4);
if (bSwabflag)
{
// Unswab 32bit value, and reswab per data type.
TIFFSwabLong((GUInt32*) data);
switch (poTIFFDirEntry->tdir_type) {
case TIFF_LONG:
case TIFF_SLONG:
case TIFF_FLOAT:
TIFFSwabLong((GUInt32*) data);
break;
case TIFF_SSHORT:
case TIFF_SHORT:
TIFFSwabArrayOfShort((GUInt16*) data,
poTIFFDirEntry->tdir_count);
break;
default:
break;
}
}
EXIFPrintData(pszTemp,
poTIFFDirEntry->tdir_type,
poTIFFDirEntry->tdir_count, data);
}
/* -------------------------------------------------------------------- */
/* The data is being read where tdir_offset point to in the file */
/* -------------------------------------------------------------------- */
else if (space > 0 && space < MAXSTRINGLENGTH)
{
unsigned char *data = (unsigned char *)VSIMalloc(space);
if (data) {
VSIFSeekL(fp,poTIFFDirEntry->tdir_offset+nTIFFHEADER,SEEK_SET);
VSIFReadL(data, 1, space, fp);
if (bSwabflag) {
switch (poTIFFDirEntry->tdir_type) {
case TIFF_SHORT:
case TIFF_SSHORT:
TIFFSwabArrayOfShort((GUInt16*) data,
poTIFFDirEntry->tdir_count);
break;
case TIFF_LONG:
case TIFF_SLONG:
示例11: TIFFSwab16BitData
void
TIFFSwab16BitData(TIFF* tif, tidata_t buf, tsize_t cc)
{
assert((cc & 1) == 0);
TIFFSwabArrayOfShort((uint16*) buf, cc/2);
}
示例12: TIFFMakeBigTIFF
//.........这里部分代码省略.........
TIFFSwabLong(&dir->s.tdir_offset);
}
dirB->b.tdir_tag = dir->s.tdir_tag;
dirB->b.tdir_type = dir->s.tdir_type;
dirB->b.tdir_count = dir->s.tdir_count;
dirB->b.tdir_offset = 0;
/*
* If data are in directory entry itself, copy data, else (data are pointed
* to by directory entry) copy pointer. This is complicated by the fact that
* the old entry had 32-bits of space, and the new has 64-bits, so may have
* to read data pointed at by the old entry directly into the new entry.
*/
switch (dir->s.tdir_type) {
case TIFF_UNDEFINED:
case TIFF_BYTE:
case TIFF_SBYTE:
case TIFF_ASCII:
if (dir->s.tdir_count <= sizeof(dir->s.tdir_offset))
_TIFFmemcpy(&dirB->b.tdir_offset, &dir->s.tdir_offset, dir->s.tdir_count);
else if (dir->s.tdir_count <= sizeof(dirB->b.tdir_count)) {
TIFFSeekFile(tif, dir->s.tdir_offset, SEEK_SET);
TIFFReadFile(tif, &dirB->b.tdir_offset, dir->s.tdir_count);
} else
dirB->b.tdir_offset = dir->s.tdir_offset;
break;
case TIFF_SHORT:
case TIFF_SSHORT:
if (dir->s.tdir_count <= sizeof(dir->s.tdir_offset) / sizeof(uint16))
_TIFFmemcpy(&dirB->b.tdir_offset, &dir->s.tdir_offset, dir->s.tdir_count * sizeof(uint16));
else if (dir->s.tdir_count <= sizeof(dirB->b.tdir_count) / sizeof(uint16)) {
TIFFSeekFile(tif, dir->s.tdir_offset, SEEK_SET);
TIFFReadFile(tif, &dirB->b.tdir_offset, dir->s.tdir_count * sizeof(uint16));
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabArrayOfShort((uint16*) &dirB->b.tdir_offset, dir->s.tdir_count);
} else
dirB->b.tdir_offset = dir->s.tdir_offset;
break;
case TIFF_LONG:
case TIFF_FLOAT:
case TIFF_IFD:
if (dir->s.tdir_count <= sizeof(dir->s.tdir_offset) / sizeof(uint32))
_TIFFmemcpy(&dirB->b.tdir_offset, &dir->s.tdir_offset, dir->s.tdir_count * sizeof(uint32));
else if (dir->s.tdir_count <= sizeof(dirB->b.tdir_count) / sizeof(uint32)) {
TIFFSeekFile(tif, dir->s.tdir_offset, SEEK_SET);
TIFFReadFile(tif, &dirB->b.tdir_offset, dir->s.tdir_count * sizeof(uint32));
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabArrayOfLong((uint32*) &dirB->b.tdir_offset, dir->s.tdir_count);
} else
dirB->b.tdir_offset = dir->s.tdir_offset;
break;
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
if (dir->s.tdir_count * 2 <= sizeof(dirB->b.tdir_offset) / sizeof(uint32)) {
TIFFSeekFile(tif, dir->s.tdir_offset, SEEK_SET);
TIFFReadFile(tif, &dirB->b.tdir_offset, dir->s.tdir_count * 2 * sizeof(uint32));
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabArrayOfLong((uint32*) &dirB->b.tdir_offset, dir->s.tdir_count * 2);
} else
dirB->b.tdir_offset = dir->s.tdir_offset;
break;
default:
dirB->b.tdir_offset = dir->s.tdir_offset;
break;
}
/*
* Process special case of SUBIFD; must change data from 32-bit to 64-bit in
示例13: tiff_print_page
int
tiff_print_page(gx_device_printer *dev, TIFF *tif, int min_feature_size)
{
int code = 0;
byte *data;
int size = gdev_mem_bytes_per_scan_line((gx_device *)dev);
int max_size = max(size, TIFFScanlineSize(tif));
int row;
int bpc = dev->color_info.depth / dev->color_info.num_components;
void *min_feature_data = NULL;
int line_lag = 0;
int filtered_count;
data = gs_alloc_bytes(dev->memory, max_size, "tiff_print_page(data)");
if (data == NULL)
return_error(gs_error_VMerror);
if (bpc != 1)
min_feature_size = 1;
if (min_feature_size > 1) {
code = min_feature_size_init(dev->memory, min_feature_size,
dev->width, dev->height,
&min_feature_data);
if (code < 0)
goto cleanup;
}
code = TIFFCheckpointDirectory(tif);
memset(data, 0, max_size);
for (row = 0; row < dev->height && code >= 0; row++) {
code = gdev_prn_copy_scan_lines(dev, row, data, size);
if (code < 0)
break;
if (min_feature_size > 1) {
filtered_count = min_feature_size_process(data, min_feature_data);
if (filtered_count == 0)
line_lag++;
}
if (row - line_lag >= 0) {
#if defined(ARCH_IS_BIG_ENDIAN) && (!ARCH_IS_BIG_ENDIAN)
if (bpc == 16)
TIFFSwabArrayOfShort((uint16 *)data,
dev->width * dev->color_info.num_components);
#endif
code = TIFFWriteScanline(tif, data, row - line_lag, 0);
}
}
for (row -= line_lag ; row < dev->height && code >= 0; row++)
{
filtered_count = min_feature_size_process(data, min_feature_data);
code = TIFFWriteScanline(tif, data, row, 0);
}
if (code >= 0)
code = TIFFWriteDirectory(tif);
cleanup:
if (min_feature_size > 1)
min_feature_size_dnit(min_feature_data);
gs_free_object(dev->memory, data, "tiff_print_page(data)");
return code;
}
示例14: TIFFReadDirectory
//.........这里部分代码省略.........
*/
td = &tif->tif_dir;
/* free any old stuff and reinit */
TIFFFreeDirectory(tif);
TIFFDefaultDirectory(tif);
/*
* Electronic Arts writes gray-scale TIFF files
* without a PlanarConfiguration directory entry.
* Thus we setup a default value here, even though
* the TIFF spec says there is no default value.
*/
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
/*
* Sigh, we must make a separate pass through the
* directory for the following reason:
*
* We must process the Compression tag in the first pass
* in order to merge in codec-private tag definitions (otherwise
* we may get complaints about unknown tags). However, the
* Compression tag may be dependent on the SamplesPerPixel
* tag value because older TIFF specs permited Compression
* to be written as a SamplesPerPixel-count tag entry.
* Thus if we don't first figure out the correct SamplesPerPixel
* tag value then we may end up ignoring the Compression tag
* value because it has an incorrect count value (if the
* true value of SamplesPerPixel is not 1).
*
* It sure would have been nice if Aldus had really thought
* this stuff through carefully.
*/
for (dp = dir, n = dircount; n > 0; n--, dp++) {
if (tif->tif_flags & TIFF_SWAB) {
TIFFSwabArrayOfShort(&dp->tdir_tag, 2);
TIFFSwabArrayOfLong(&dp->tdir_count, 2);
}
if (dp->tdir_tag == TIFFTAG_SAMPLESPERPIXEL) {
if (!TIFFFetchNormalTag(tif, dp))
goto bad;
dp->tdir_tag = IGNORE;
}
}
/*
* First real pass over the directory.
*/
fix = 0;
for (dp = dir, n = dircount; n > 0; n--, dp++) {
/*
* Find the field information entry for this tag.
* Added check for tags to ignore ... [BFC]
*/
if( TIFFReassignTagToIgnore(TIS_EXTRACT, dp->tdir_tag) )
dp->tdir_tag = IGNORE;
if (dp->tdir_tag == IGNORE)
continue;
/*
* Silicon Beach (at least) writes unordered
* directory tags (violating the spec). Handle
* it here, but be obnoxious (maybe they'll fix it?).
*/
if (dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) {
if (!diroutoforderwarning) {
TIFFWarning(tif->tif_name,
示例15: ReadDirectory
/*
* Read the next TIFF directory from a file
* and convert it to the internal format.
* We read directories sequentially.
*/
static uint32
ReadDirectory(int fd, unsigned ix, uint32 off)
{
register TIFFDirEntry *dp;
register int n;
TIFFDirEntry *dir = 0;
uint16 dircount;
int space;
uint32 nextdiroff = 0;
if (off == 0) /* no more directories */
goto done;
if (lseek(fd, (off_t) off, 0) != off) {
Fatal("Seek error accessing TIFF directory");
goto done;
}
if (read(fd, (char*) &dircount, sizeof (uint16)) != sizeof (uint16)) {
ReadError("directory count");
goto done;
}
if (swabflag)
TIFFSwabShort(&dircount);
dir = (TIFFDirEntry *)_TIFFmalloc(dircount * sizeof (TIFFDirEntry));
if (dir == NULL) {
Fatal("No space for TIFF directory");
goto done;
}
n = read(fd, (char*) dir, dircount*sizeof (*dp));
if (n != dircount*sizeof (*dp)) {
n /= sizeof (*dp);
Error(
"Could only read %u of %u entries in directory at offset %#lx",
n, dircount, (unsigned long) off);
dircount = n;
}
if (read(fd, (char*) &nextdiroff, sizeof (uint32)) != sizeof (uint32))
nextdiroff = 0;
if (swabflag)
TIFFSwabLong(&nextdiroff);
printf("Directory %u: offset %lu (%#lx) next %lu (%#lx)\n", ix,
(unsigned long) off, (unsigned long) off,
(unsigned long) nextdiroff, (unsigned long) nextdiroff);
for (dp = dir, n = dircount; n > 0; n--, dp++) {
if (swabflag) {
TIFFSwabArrayOfShort(&dp->tdir_tag, 2);
TIFFSwabArrayOfLong(&dp->tdir_count, 2);
}
PrintTag(stdout, dp->tdir_tag);
putchar(' ');
PrintType(stdout, dp->tdir_type);
putchar(' ');
printf("%lu<", (unsigned long) dp->tdir_count);
if (dp->tdir_type >= NWIDTHS) {
printf(">\n");
continue;
}
space = dp->tdir_count * datawidth[dp->tdir_type];
if (space <= 4) {
switch (dp->tdir_type) {
case TIFF_FLOAT:
case TIFF_UNDEFINED:
case TIFF_ASCII: {
unsigned char data[4];
_TIFFmemcpy(data, &dp->tdir_offset, 4);
if (swabflag)
TIFFSwabLong((uint32*) data);
PrintData(stdout,
dp->tdir_type, dp->tdir_count, data);
break;
}
case TIFF_BYTE:
PrintByte(stdout, bytefmt, dp);
break;
case TIFF_SBYTE:
PrintByte(stdout, sbytefmt, dp);
break;
case TIFF_SHORT:
PrintShort(stdout, shortfmt, dp);
break;
case TIFF_SSHORT:
PrintShort(stdout, sshortfmt, dp);
break;
case TIFF_LONG:
PrintLong(stdout, longfmt, dp);
break;
case TIFF_SLONG:
PrintLong(stdout, slongfmt, dp);
break;
}
} else {
unsigned char *data = (unsigned char *)_TIFFmalloc(space);
if (data) {
if (TIFFFetchData(fd, dp, data))
if (dp->tdir_count > maxitems) {
PrintData(stdout, dp->tdir_type,
//.........这里部分代码省略.........