Handle all data types in custom tags.
This commit is contained in:
parent
5cdbfc3664
commit
78cf75a417
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_dir.c,v 1.45 2005-03-18 13:29:39 dron Exp $ */
|
/* $Id: tif_dir.c,v 1.46 2005-03-21 10:17:37 dron Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@ -553,8 +553,7 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
|||||||
if (tv_size == 0) {
|
if (tv_size == 0) {
|
||||||
status = 0;
|
status = 0;
|
||||||
TIFFError(module, "%s: Bad field type %d for \"%s\"",
|
TIFFError(module, "%s: Bad field type %d for \"%s\"",
|
||||||
tif->tif_name, fip->field_type,
|
tif->tif_name, fip->field_type, fip->field_name);
|
||||||
fip->field_name);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,9 +562,8 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
|||||||
tv->count = (uint32) va_arg(ap, uint32);
|
tv->count = (uint32) va_arg(ap, uint32);
|
||||||
else
|
else
|
||||||
tv->count = (int) va_arg(ap, int);
|
tv->count = (int) va_arg(ap, int);
|
||||||
}
|
} else if (fip->field_writecount == TIFF_VARIABLE
|
||||||
else if (fip->field_writecount == TIFF_VARIABLE
|
|| fip->field_writecount == TIFF_VARIABLE2)
|
||||||
|| fip->field_writecount == TIFF_VARIABLE2)
|
|
||||||
tv->count = 1;
|
tv->count = 1;
|
||||||
else if (fip->field_writecount == TIFF_SPP)
|
else if (fip->field_writecount == TIFF_SPP)
|
||||||
tv->count = td->td_samplesperpixel;
|
tv->count = td->td_samplesperpixel;
|
||||||
@ -602,21 +600,32 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
|||||||
case TIFF_SBYTE:
|
case TIFF_SBYTE:
|
||||||
case TIFF_SHORT:
|
case TIFF_SHORT:
|
||||||
case TIFF_SSHORT:
|
case TIFF_SSHORT:
|
||||||
|
case TIFF_UNDEFINED:
|
||||||
{
|
{
|
||||||
int v = va_arg(ap, int);
|
int v = va_arg(ap, int);
|
||||||
_TIFFmemcpy(tv->value, &v, tv_size*tv->count);
|
_TIFFmemcpy(tv->value, &v, tv_size*tv->count);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_LONG:
|
case TIFF_LONG:
|
||||||
|
case TIFF_IFD:
|
||||||
{
|
{
|
||||||
uint32 v32 = va_arg(ap, uint32);
|
uint32 v = va_arg(ap, uint32);
|
||||||
_TIFFmemcpy(tv->value, &v32, tv_size*tv->count);
|
_TIFFmemcpy(tv->value, &v, tv_size*tv->count);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_SLONG:
|
case TIFF_SLONG:
|
||||||
{
|
{
|
||||||
int32 v32 = va_arg(ap, int32);
|
int32 v = va_arg(ap, int32);
|
||||||
_TIFFmemcpy(tv->value, &v32, tv_size*tv->count);
|
_TIFFmemcpy(tv->value, &v, tv_size*tv->count);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TIFF_RATIONAL:
|
||||||
|
case TIFF_SRATIONAL:
|
||||||
|
case TIFF_FLOAT:
|
||||||
|
case TIFF_DOUBLE:
|
||||||
|
{
|
||||||
|
double v = va_arg(ap, double);
|
||||||
|
_TIFFmemcpy(tv->value, &v, tv_size*tv->count);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -629,8 +638,8 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
|
TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
|
||||||
tif->tif_flags |= TIFF_DIRTYDIRECT;
|
tif->tif_flags |= TIFF_DIRTYDIRECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
@ -1018,6 +1027,7 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
|||||||
} else {
|
} else {
|
||||||
switch (fip->field_type) {
|
switch (fip->field_type) {
|
||||||
case TIFF_BYTE:
|
case TIFF_BYTE:
|
||||||
|
case TIFF_UNDEFINED:
|
||||||
*va_arg(ap, uint8*) =
|
*va_arg(ap, uint8*) =
|
||||||
*(uint8 *)tv->value;
|
*(uint8 *)tv->value;
|
||||||
ret_val = 1;
|
ret_val = 1;
|
||||||
@ -1038,6 +1048,7 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
|||||||
ret_val = 1;
|
ret_val = 1;
|
||||||
break;
|
break;
|
||||||
case TIFF_LONG:
|
case TIFF_LONG:
|
||||||
|
case TIFF_IFD:
|
||||||
*va_arg(ap, uint32*) =
|
*va_arg(ap, uint32*) =
|
||||||
*(uint32 *)tv->value;
|
*(uint32 *)tv->value;
|
||||||
ret_val = 1;
|
ret_val = 1;
|
||||||
@ -1047,6 +1058,18 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
|||||||
*(int32 *)tv->value;
|
*(int32 *)tv->value;
|
||||||
ret_val = 1;
|
ret_val = 1;
|
||||||
break;
|
break;
|
||||||
|
case TIFF_RATIONAL:
|
||||||
|
case TIFF_SRATIONAL:
|
||||||
|
case TIFF_FLOAT:
|
||||||
|
*va_arg(ap, float*) =
|
||||||
|
*(float *)tv->value;
|
||||||
|
ret_val = 1;
|
||||||
|
break;
|
||||||
|
case TIFF_DOUBLE:
|
||||||
|
*va_arg(ap, double*) =
|
||||||
|
*(double *)tv->value;
|
||||||
|
ret_val = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret_val = 0;
|
ret_val = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_print.c,v 1.21 2005-03-18 13:29:39 dron Exp $ */
|
/* $Id: tif_print.c,v 1.22 2005-03-21 10:17:37 dron Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@ -538,7 +538,9 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
|||||||
if(fip->field_type == TIFF_BYTE)
|
if(fip->field_type == TIFF_BYTE)
|
||||||
fprintf(fd, "%u",
|
fprintf(fd, "%u",
|
||||||
(unsigned int) ((unsigned char *) raw_data)[j]);
|
(unsigned int) ((unsigned char *) raw_data)[j]);
|
||||||
else if(fip->field_type == TIFF_SBYTE)
|
else if(fip->field_type == TIFF_UNDEFINED)
|
||||||
|
fprintf(fd, "0x%x",
|
||||||
|
(unsigned int) ((unsigned char *) raw_data)[j]); else if(fip->field_type == TIFF_SBYTE)
|
||||||
fprintf(fd, "%d", (int) ((char *) raw_data)[j]);
|
fprintf(fd, "%d", (int) ((char *) raw_data)[j]);
|
||||||
else if(fip->field_type == TIFF_SHORT)
|
else if(fip->field_type == TIFF_SHORT)
|
||||||
fprintf(fd, "%u",
|
fprintf(fd, "%u",
|
||||||
@ -550,10 +552,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
|||||||
(int)((unsigned long *) raw_data)[j]);
|
(int)((unsigned long *) raw_data)[j]);
|
||||||
else if(fip->field_type == TIFF_SLONG)
|
else if(fip->field_type == TIFF_SLONG)
|
||||||
fprintf(fd, "%ld", (long)((long *) raw_data)[j]);
|
fprintf(fd, "%ld", (long)((long *) raw_data)[j]);
|
||||||
else if(fip->field_type == TIFF_RATIONAL)
|
else if(fip->field_type == TIFF_RATIONAL
|
||||||
fprintf(fd, "%f", ((float *) raw_data)[j]);
|
|| fip->field_type == TIFF_SRATIONAL
|
||||||
else if(fip->field_type == TIFF_SRATIONAL)
|
|| fip->field_type == TIFF_FLOAT)
|
||||||
fprintf(fd, "%f", ((float *) raw_data)[j]);
|
fprintf(fd, "%f", ((float *) raw_data)[j]);
|
||||||
|
else if(fip->field_type == TIFF_IFD)
|
||||||
|
fprintf(fd, "0x%x",
|
||||||
|
(int)((unsigned long *) raw_data)[j]);
|
||||||
else if(fip->field_type == TIFF_ASCII) {
|
else if(fip->field_type == TIFF_ASCII) {
|
||||||
fprintf(fd, "%s", (char *) raw_data);
|
fprintf(fd, "%s", (char *) raw_data);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user