diff options
author | Ray Chen <raychen@google.com> | 2010-01-15 13:58:10 -0800 |
---|---|---|
committer | Ray Chen <raychen@google.com> | 2010-01-19 15:05:20 -0800 |
commit | a39920ca4b96a456511fa32ba90c77f119a274c3 (patch) | |
tree | 18ba1bfc915d0ba47c5c2f92315d0119570c5e56 | |
parent | f7e7344c2ef1625d35a35601d1fbf8a4824ea6c7 (diff) | |
download | jhead-a39920ca4b96a456511fa32ba90c77f119a274c3.tar.gz |
Add gps-timestamp and gps-datestamp support to jhead library.
-rw-r--r-- | gpsinfo.c | 18 | ||||
-rw-r--r-- | jhead.h | 15 | ||||
-rw-r--r-- | main.c | 8 |
3 files changed, 34 insertions, 7 deletions
@@ -15,7 +15,8 @@ #define TAG_GPS_LONG 4 #define TAG_GPS_ALT_REF 5 #define TAG_GPS_ALT 6 - +#define TAG_GPS_TIMESTAMP 7 +#define TAG_GPS_DATESTAMP 29 static TagTable_t GpsTags[]= { { 0x00, "GPSVersionID", FMT_BYTE, 4}, @@ -135,6 +136,8 @@ void ProcessGpsInfo(unsigned char * DirStart, int ByteCountUnused, unsigned char strcpy(ImageInfo.GpsLat, "? ?"); strcpy(ImageInfo.GpsLong, "? ?"); ImageInfo.GpsAlt[0] = 0; + bzero(ImageInfo.GpsTimeStamp, sizeof(ImageInfo.GpsTimeStamp)); + bzero(ImageInfo.GpsDateStamp, sizeof(ImageInfo.GpsDateStamp)); for (de=0;de<NumDirEntries;de++){ unsigned Tag, Format, Components; @@ -248,6 +251,19 @@ void ProcessGpsInfo(unsigned char * DirStart, int ByteCountUnused, unsigned char sprintf(ImageInfo.GpsAlt + 1, "%.2fm", ConvertAnyFormat(ValuePtr, Format)); break; + + case TAG_GPS_TIMESTAMP: + snprintf(ImageInfo.GpsTimeStamp, + sizeof(ImageInfo.GpsTimeStamp), "%d:%d:%d", + (int) ConvertAnyFormat(ValuePtr, Format), + (int) ConvertAnyFormat(ValuePtr + 8, Format), + (int) ConvertAnyFormat(ValuePtr + 16, Format) + ); + break; + + case TAG_GPS_DATESTAMP: + strncpy(ImageInfo.GpsDateStamp, (char*)ValuePtr, sizeof(ImageInfo.GpsDateStamp)); + break; } if (ShowTags){ @@ -1,9 +1,9 @@ //-------------------------------------------------------------------------- // Include file for jhead program. // -// This include file only defines stuff that goes across modules. -// I like to keep the definitions for macros and structures as close to -// where they get used as possible, so include files only get stuff that +// This include file only defines stuff that goes across modules. +// I like to keep the definitions for macros and structures as close to +// where they get used as possible, so include files only get stuff that // gets used in more than one file. //-------------------------------------------------------------------------- #define _CRT_SECURE_NO_DEPRECATE 1 @@ -113,6 +113,9 @@ typedef struct { char GpsLongRaw[31]; char GpsLongRef[2]; char GpsAlt[20]; + // gps-datestamp is 11 bytes ascii in EXIF 2.2 + char GpsDateStamp[11]; + char GpsTimeStamp[11]; }ImageInfo_t; @@ -171,7 +174,7 @@ int TagNameToValue(const char* tagName); extern const int BytesPerFormat[]; #define NUM_FORMATS 12 -#define FMT_BYTE 1 +#define FMT_BYTE 1 #define FMT_STRING 2 #define FMT_USHORT 3 #define FMT_ULONG 4 @@ -190,7 +193,7 @@ extern void ProcessMakerNote(unsigned char * DirStart, int ByteCount, unsigned char * OffsetBase, unsigned ExifLength); // gpsinfo.c prototypes -void ProcessGpsInfo(unsigned char * ValuePtr, int ByteCount, +void ProcessGpsInfo(unsigned char * ValuePtr, int ByteCount, unsigned char * OffsetBase, unsigned ExifLength); int IsGpsTag(const char* tag); int GpsTagToFormatType(unsigned short tag); @@ -255,7 +258,7 @@ extern char* formatStr(int format); #define M_JFIF 0xE0 // Jfif marker #define M_EXIF 0xE1 // Exif marker. Also used for XMP data! #define M_XMP 0x10E1 // Not a real tag (same value in file as Exif!) -#define M_COM 0xFE // COMment +#define M_COM 0xFE // COMment #define M_DQT 0xDB #define M_DHT 0xC4 #define M_DRI 0xDD @@ -651,6 +651,14 @@ static jstring getAttributes(JNIEnv *env, jobject jobj, jstring jfilename) bufLen = addKeyValueString(&buf, bufLen, "GPSAltitude", ImageInfo.GpsAlt); if (bufLen == 0) return NULL; } + if (ImageInfo.GpsDateStamp[0]) { + bufLen = addKeyValueString(&buf, bufLen, "GPSDateStamp", ImageInfo.GpsDateStamp); + if (bufLen == 0) return NULL; + } + if (ImageInfo.GpsTimeStamp[0]) { + bufLen = addKeyValueString(&buf, bufLen, "GPSTimeStamp", ImageInfo.GpsTimeStamp); + if (bufLen == 0) return NULL; + } } if (ImageInfo.Comments[0]) { |