summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngus Kong <shkong@google.com>2012-01-18 07:00:33 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-01-18 07:00:33 -0800
commitf485c62af532ad43c72268d7a5b3a399b1ef51cb (patch)
treec3f9a847b75151ab8d646b6ce64c3b575ac9a3a0
parentf4fd06d84d0d4ffe00b448f5c3320d63256b5035 (diff)
downloadjhead-f485c62af532ad43c72268d7a5b3a399b1ef51cb.tar.gz
Revert "Use values from attributes for DateTime tag."
This reverts commit f4fd06d84d0d4ffe00b448f5c3320d63256b5035
-rw-r--r--exif.c19
-rw-r--r--jhead.h4
-rw-r--r--main.c7
3 files changed, 11 insertions, 19 deletions
diff --git a/exif.c b/exif.c
index 5b437d4..8d8c0c0 100644
--- a/exif.c
+++ b/exif.c
@@ -1200,7 +1200,7 @@ char* formatStr(int format) {
// Create minimal exif header - just date and thumbnail pointers,
// so that date and thumbnail may be filled later.
//--------------------------------------------------------------------------
-static void create_EXIF_internal(ExifElement_t* elements, int exifTagCount, int gpsTagCount, int hasDateTimeTag, char* Buffer)
+static void create_EXIF_internal(ExifElement_t* elements, int exifTagCount, int gpsTagCount, char* Buffer)
{
unsigned short NumEntries;
int DataWriteIndex;
@@ -1221,26 +1221,21 @@ static void create_EXIF_internal(ExifElement_t* elements, int exifTagCount, int
{
DirIndex = DataWriteIndex;
- NumEntries = 1 + exifTagCount; // the extra is the thumbnail
+ NumEntries = 2 + exifTagCount; // the two extra are the datetime and the thumbnail
if (gpsTagCount) {
++NumEntries; // allow for the GPS info tag
}
- if (!hasDateTimeTag) {
- // We have to write extra date time tag. The entry number should be
- // adjusted.
- ++NumEntries;
- }
DataWriteIndex += 2 + NumEntries*12 + 4;
Put16u(Buffer+DirIndex, NumEntries); // Number of entries
DirIndex += 2;
// Entries go here...
- if (!hasDateTimeTag) {
+ {
// Date/time entry
char* dateTime = NULL;
char dateBuf[20];
- if (ImageInfo.numDateTimeTags) {
+ if (ImageInfo.numDateTimeTags){
// If we had a pre-existing exif header, use time from that.
dateTime = ImageInfo.DateTime;
} else {
@@ -1280,7 +1275,7 @@ static void create_EXIF_internal(ExifElement_t* elements, int exifTagCount, int
&DirIndex,
&DataWriteIndex);
}
-
+
if (gpsTagCount) {
// Link to gps dir entry
writeExifTagAndData(TAG_GPSINFO,
@@ -1417,7 +1412,7 @@ static void create_EXIF_internal(ExifElement_t* elements, int exifTagCount, int
}
}
-void create_EXIF(ExifElement_t* elements, int exifTagCount, int gpsTagCount, int hasDateTimeTag)
+void create_EXIF(ExifElement_t* elements, int exifTagCount, int gpsTagCount)
{
// It is hard to calculate exact necessary size for editing the exif
// header dynamically, so we are using the maximum size of EXIF, 64K
@@ -1425,7 +1420,7 @@ void create_EXIF(ExifElement_t* elements, int exifTagCount, int gpsTagCount, int
char* Buffer = malloc(EXIF_MAX_SIZE);
if (Buffer != NULL) {
- create_EXIF_internal(elements, exifTagCount, gpsTagCount, hasDateTimeTag, Buffer);
+ create_EXIF_internal(elements, exifTagCount, gpsTagCount, Buffer);
free(Buffer);
} else {
ErrFatal("Could not allocate memory");
diff --git a/jhead.h b/jhead.h
index 5173c1d..4347fe8 100644
--- a/jhead.h
+++ b/jhead.h
@@ -176,7 +176,7 @@ int Get16u(void * Short);
unsigned Get32u(void * Long);
int Get32s(void * Long);
void Put32u(void * Value, unsigned PutValue);
-void create_EXIF(ExifElement_t* elements, int exifTagCount, int gpsTagCount, int hasDateTimeTag);
+void create_EXIF(ExifElement_t* elements, int exifTagCount, int gpsTagCount);
int TagNameToValue(const char* tagName);
//--------------------------------------------------------------------------
@@ -277,3 +277,5 @@ extern char* formatStr(int format);
#define M_DHT 0xC4
#define M_DRI 0xDD
#define M_IPTC 0xED // IPTC marker
+
+
diff --git a/main.c b/main.c
index 2cbc4a5..b67724f 100644
--- a/main.c
+++ b/main.c
@@ -230,7 +230,6 @@ static void saveAttributes(JNIEnv *env, jobject jobj, jstring jfilename, jstring
int i;
char tag[100];
- int hasDateTimeTag = FALSE;
int gpsTagCount = 0;
int exifTagCount = 0;
@@ -264,10 +263,6 @@ static void saveAttributes(JNIEnv *env, jobject jobj, jstring jfilename, jstring
}
attrPtr = tagEnd + 1;
- if (exifElementTable[i].Tag == 0x0132) { // 0x0132 is the DateTime tag number.
- hasDateTimeTag = TRUE;
- }
-
// next get the length of the attribute value
int valueLen = atoi(attrPtr);
attrPtr = strchr(attrPtr, ' ') + 1;
@@ -320,7 +315,7 @@ static void saveAttributes(JNIEnv *env, jobject jobj, jstring jfilename, jstring
}
}
- create_EXIF(exifElementTable, exifTagCount, gpsTagCount, hasDateTimeTag);
+ create_EXIF(exifElementTable, exifTagCount, gpsTagCount);
if (thumbnailData) {
copyThumbnailData(thumbnailData, thumbnailLength);