More improvements in custom tag handling code.
This commit is contained in:
parent
9f65685aa9
commit
b6db5920e5
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_dir.c,v 1.44 2005-03-17 14:43:14 dron Exp $ */
|
||||
/* $Id: tif_dir.c,v 1.45 2005-03-18 13:29:39 dron Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -592,7 +592,8 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
if (fip->field_passcount
|
||||
|| fip->field_writecount == TIFF_VARIABLE
|
||||
|| fip->field_writecount == TIFF_VARIABLE2
|
||||
|| fip->field_writecount == TIFF_SPP) {
|
||||
|| fip->field_writecount == TIFF_SPP
|
||||
|| tv->count > 1) {
|
||||
_TIFFmemcpy(tv->value, va_arg(ap, void *),
|
||||
tv->count * tv_size);
|
||||
} else {
|
||||
@ -989,8 +990,8 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
}
|
||||
|
||||
/*
|
||||
** Do we have a custom value?
|
||||
*/
|
||||
* Do we have a custom value?
|
||||
*/
|
||||
ret_val = 0;
|
||||
for (i = 0; i < td->td_customValueCount; i++) {
|
||||
TIFFTagValue *tv = td->td_customValues + i;
|
||||
@ -1007,44 +1008,49 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
ret_val = 1;
|
||||
break;
|
||||
} else {
|
||||
switch (fip->field_type) {
|
||||
case TIFF_BYTE:
|
||||
*va_arg(ap, uint8*) =
|
||||
*(uint8 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SBYTE:
|
||||
*va_arg(ap, int8*) =
|
||||
*(int8 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SHORT:
|
||||
*va_arg(ap, uint16*) =
|
||||
*(uint16 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SSHORT:
|
||||
*va_arg(ap, int16*) =
|
||||
*(int16 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
*va_arg(ap, uint32*) =
|
||||
*(uint32 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SLONG:
|
||||
*va_arg(ap, int32*) =
|
||||
*(int32 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_ASCII:
|
||||
*va_arg(ap, void **) = tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
default:
|
||||
ret_val = 0;
|
||||
break;
|
||||
if (fip->field_type == TIFF_ASCII
|
||||
|| fip->field_readcount == TIFF_VARIABLE
|
||||
|| fip->field_readcount == TIFF_VARIABLE2
|
||||
|| fip->field_readcount == TIFF_SPP
|
||||
|| tv->count > 1) {
|
||||
*va_arg(ap, void **) = tv->value;
|
||||
ret_val = 1;
|
||||
} else {
|
||||
switch (fip->field_type) {
|
||||
case TIFF_BYTE:
|
||||
*va_arg(ap, uint8*) =
|
||||
*(uint8 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SBYTE:
|
||||
*va_arg(ap, int8*) =
|
||||
*(int8 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SHORT:
|
||||
*va_arg(ap, uint16*) =
|
||||
*(uint16 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SSHORT:
|
||||
*va_arg(ap, int16*) =
|
||||
*(int16 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
*va_arg(ap, uint32*) =
|
||||
*(uint32 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SLONG:
|
||||
*va_arg(ap, int32*) =
|
||||
*(int32 *)tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
default:
|
||||
ret_val = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_print.c,v 1.20 2005-03-17 14:29:41 dron Exp $ */
|
||||
/* $Id: tif_print.c,v 1.21 2005-03-18 13:29:39 dron Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -518,12 +518,14 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
if (fip->field_type == TIFF_ASCII
|
||||
|| fip->field_readcount == TIFF_VARIABLE
|
||||
|| fip->field_readcount == TIFF_VARIABLE2
|
||||
|| fip->field_readcount == TIFF_SPP) {
|
||||
|| fip->field_readcount == TIFF_SPP
|
||||
|| value_count > 1) {
|
||||
if(TIFFGetField(tif, tag, &raw_data) != 1)
|
||||
continue;
|
||||
} else {
|
||||
raw_data = _TIFFmalloc(
|
||||
_TIFFDataSize(fip->field_type) * value_count);
|
||||
_TIFFDataSize(fip->field_type)
|
||||
* value_count);
|
||||
mem_alloc = 1;
|
||||
if(TIFFGetField(tif, tag, raw_data) != 1)
|
||||
continue;
|
||||
@ -534,17 +536,20 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
|
||||
for(j = 0; j < value_count; j++) {
|
||||
if(fip->field_type == TIFF_BYTE)
|
||||
fprintf(fd, "%u",
|
||||
(unsigned int) ((unsigned char *) raw_data)[j]);
|
||||
else if(fip->field_type == TIFF_SBYTE)
|
||||
fprintf(fd, "%d", (int) ((char *) raw_data)[j]);
|
||||
else if(fip->field_type == TIFF_SHORT)
|
||||
fprintf(fd, "%u",
|
||||
(int)((unsigned short *) raw_data)[j]);
|
||||
(unsigned int)((unsigned short *) raw_data)[j]);
|
||||
else if(fip->field_type == TIFF_SSHORT)
|
||||
fprintf(fd, "%d", (int)((short *) raw_data)[j]);
|
||||
else if(fip->field_type == TIFF_LONG)
|
||||
fprintf(fd, "%u",
|
||||
fprintf(fd, "%lu",
|
||||
(int)((unsigned long *) raw_data)[j]);
|
||||
else if(fip->field_type == TIFF_SLONG)
|
||||
fprintf(fd, "%d", (int)((long *) raw_data)[j]);
|
||||
fprintf(fd, "%ld", (long)((long *) raw_data)[j]);
|
||||
else if(fip->field_type == TIFF_RATIONAL)
|
||||
fprintf(fd, "%f", ((float *) raw_data)[j]);
|
||||
else if(fip->field_type == TIFF_SRATIONAL)
|
||||
|
Loading…
Reference in New Issue
Block a user