summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorscuri <scuri>2009-08-22 04:31:03 +0000
committerscuri <scuri>2009-08-22 04:31:03 +0000
commit36e80e6481f7518e8005527d8965148039ba8dc2 (patch)
tree04446e7c74b2b9468551a77b750000d6809fa227 /src
parent0ab3aef31d7820f40bb22e15bba930f923f8bf72 (diff)
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/im_attrib.cpp10
-rw-r--r--src/im_format_tiff.cpp55
-rw-r--r--src/libtiff/tif_config.h28
-rw-r--r--src/libtiff/tiffiop.h6
4 files changed, 56 insertions, 43 deletions
diff --git a/src/im_attrib.cpp b/src/im_attrib.cpp
index 90c007e..10d4599 100644
--- a/src/im_attrib.cpp
+++ b/src/im_attrib.cpp
@@ -2,7 +2,7 @@
* \brief Attributes Table
*
* See Copyright Notice in im_lib.h
- * $Id: im_attrib.cpp,v 1.2 2009/08/19 18:39:43 scuri Exp $
+ * $Id: im_attrib.cpp,v 1.3 2009/08/22 04:31:04 scuri Exp $
*/
#include <stdlib.h>
@@ -62,12 +62,15 @@ static char* utlStrDup(const char* str)
imAttribNode::imAttribNode(const char* name, int _data_type, int _count, const void* _data, imAttribNode* _next)
{
+ if (_data_type == 0 && _count == -1) /* BYTE meaning a string */
+ _count = strlen((char*)_data)+1;
+
this->name = utlStrDup(name);
this->data_type = _data_type;
this->count = _count;
this->next = _next;
- int size = count * imDataTypeSize(_data_type);
+ int size = _count * imDataTypeSize(_data_type);
this->data = malloc(size);
if (_data) memcpy(this->data, _data, size);
else memset(this->data, 0, size);
@@ -152,9 +155,6 @@ void imAttribTableSet(imAttribTablePrivate* ptable, const char* name, int data_t
int index = iHashIndex(name, ptable->hash_size);
imAttribNode* first_node = ptable->hash_table[index];
- if (data_type == 0 && count == -1) /* BYTE */
- count = strlen((char*)data)+1;
-
// The name already exists ?
imAttribNode* cur_node = first_node;
imAttribNode* prev_node = NULL;
diff --git a/src/im_format_tiff.cpp b/src/im_format_tiff.cpp
index 66fbe57..5b072fc 100644
--- a/src/im_format_tiff.cpp
+++ b/src/im_format_tiff.cpp
@@ -3,7 +3,7 @@
*
* See Copyright Notice in im_lib.h
* See libTIFF Copyright Notice in tiff.h
- * $Id: im_format_tiff.cpp,v 1.3 2009/08/19 18:39:43 scuri Exp $
+ * $Id: im_format_tiff.cpp,v 1.4 2009/08/22 04:31:04 scuri Exp $
*/
#include "im_format.h"
@@ -34,9 +34,6 @@
static const TIFFFieldInfo iTiffFieldInfo[] =
{
- /* missing in libTIFF (fixed in libtiff 4.0) */
- { EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, FIELD_CUSTOM, TRUE, FALSE, "ColorSpace" },
-
/* Patch from Dave Coffin (Used for DNG) */
{ TIFFTAG_WHITELEVEL, -2, -1, TIFF_LONG, FIELD_CUSTOM, 0, 1, "WhiteLevel" },
{ TIFFTAG_WHITELEVEL, -2, -1, TIFF_SHORT, FIELD_CUSTOM, 0, 1, "WhiteLevel" },
@@ -301,12 +298,16 @@ static void iTIFFReadCustomTags(TIFF* tiff, imAttribTable* attrib_table)
if (fld == NULL)
continue;
- if (fld->field_tag == TIFFTAG_EXIFIFD || /* offset */
+ /* offsets */
+ if (fld->field_tag == TIFFTAG_EXIFIFD ||
fld->field_tag == TIFFTAG_GPSIFD ||
fld->field_tag == TIFFTAG_INTEROPERABILITYIFD ||
fld->field_tag == TIFFTAG_SUBIFD ||
- fld->field_tag == TIFFTAG_COLORMAP || /* handled elsewhere */
- fld->field_tag == TIFFTAG_EXTRASAMPLES ||
+ fld->field_tag == TIFFTAG_COLORMAP)
+ continue;
+
+ /* handled elsewhere */
+ if (fld->field_tag == TIFFTAG_EXTRASAMPLES ||
fld->field_tag == TIFFTAG_TRANSFERFUNCTION ||
fld->field_tag == TIFFTAG_RESOLUTIONUNIT ||
fld->field_tag == TIFFTAG_XRESOLUTION ||
@@ -449,7 +450,47 @@ static void iTIFFReadCustomTags(TIFF* tiff, imAttribTable* attrib_table)
delete [] float_data;
}
else
+ {
+ char* newstr = NULL;
+
+ if (fld->field_type == TIFF_ASCII && ((char*)data)[data_count-1] != 0)
+ {
+ int i = data_count-1;
+ char* p = (char*)data;
+ while (i > 0 && p[i] != 0)
+ i--;
+ if (i == 0)
+ {
+ if (fld->field_tag == TIFFTAG_DATETIME ||
+ fld->field_tag == EXIFTAG_DATETIMEORIGINAL ||
+ fld->field_tag == EXIFTAG_DATETIMEDIGITIZED)
+ {
+ /* sometimes theses tags get non standard strings,
+ libTIIF does not returns the actual number os bytes read,
+ it returns the standard value of 20.
+ so we will try to find the actual string size, but we risk in a memory invalid access. */
+ i = data_count;
+ while (i < data_count+6 && p[i] != 0)
+ i++;
+ if (i < data_count+6)
+ data_count = i+1;
+ }
+ else
+ {
+ newstr = (char*)malloc(data_count+1);
+ memcpy(newstr, data, data_count);
+ newstr[data_count] = 0;
+ data_count++;
+ }
+ }
+ else
+ data_count = i;
+ }
+
attrib_table->Set(fld->field_name, data_type, data_count, data);
+
+ if (newstr) free(newstr);
+ }
}
}
}
diff --git a/src/libtiff/tif_config.h b/src/libtiff/tif_config.h
index 3558fe7..f9db461 100644
--- a/src/libtiff/tif_config.h
+++ b/src/libtiff/tif_config.h
@@ -253,34 +253,6 @@
#define inline
#endif
-#ifdef _MSC_VER
-#if _MSC_VER>1400
-/* Signed 64-bit type formatter */
-#define TIFF_INT64_FORMAT "%I64d"
-
-/* Signed 64-bit type */
-#define TIFF_INT64_T signed __int64
-
-/* Unsigned 64-bit type formatter */
-#define TIFF_UINT64_FORMAT "%I64u"
-
-/* Unsigned 64-bit type */
-#define TIFF_UINT64_T unsigned __int64
-//#else
-///* Signed 64-bit type formatter */
-//#define TIFF_INT64_FORMAT "%I64d"
-//
-///* Signed 64-bit type */
-//#define TIFF_INT64_T signed __int64
-//
-///* Unsigned 64-bit type formatter */
-//#define TIFF_UINT64_FORMAT "%I64u"
-//
-///* Unsigned 64-bit type */
-//#define TIFF_UINT64_T unsigned __int64
-#endif
-#endif
-
/* Define to `long' if <sys/types.h> does not define. */
/* #undef off_t */
diff --git a/src/libtiff/tiffiop.h b/src/libtiff/tiffiop.h
index dcf9a63..3360b7a 100644
--- a/src/libtiff/tiffiop.h
+++ b/src/libtiff/tiffiop.h
@@ -1,4 +1,4 @@
-/* $Id: tiffiop.h,v 1.2 2009/08/21 04:01:59 scuri Exp $ */
+/* $Id: tiffiop.h,v 1.3 2009/08/22 04:31:04 scuri Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -61,8 +61,8 @@ extern void *lfind(const void *, const void *, size_t *, size_t,
Libtiff itself does not require a 64-bit type, but bundled TIFF
utilities may use it.
*/
-typedef TIFF_INT64_T int64;
-typedef TIFF_UINT64_T uint64;
+/* typedef TIFF_INT64_T int64; IMLIB */
+/* typedef TIFF_UINT64_T uint64; IMLIB */
#include "tiffio.h"
#include "tif_dir.h"