From bd90094d709a579d8d74c326269e492627be9daa Mon Sep 17 00:00:00 2001 From: Tyler Luu Date: Wed, 12 Oct 2011 17:46:32 -0500 Subject: Fix insertion of GPSProcessingMethod tag GPSProcessingMethod was not being inserted properly because it was being treated as STRING format which results in "ASCII" being taken as the processing method. GPSProcessingMethod is defined as UNDEFINED format with the value containing a character string in Exif2.2 standard. 1. Set GPSProcessingMethod to UNDEFINED format as defined in Exif2.2 2. Add handling of ASCII value with UNDEFINED format in writeExifTagAndData. Handling is similar to STRING format, except we have to account for the 'ASCII\0\0\0' header before the string. b/5448171 Change-Id: I411a67d7d97e35bee66aa582b25f0f6333c0679a Signed-off-by: Tyler Luu --- exif.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'exif.c') diff --git a/exif.c b/exif.c index a70b310..a0056e0 100644 --- a/exif.c +++ b/exif.c @@ -1091,6 +1091,15 @@ static void writeExifTagAndData(int tag, components = strlen((char*)value) + 1; // account for null terminator if (components & 1) ++components; // no odd lengths } + if (format == FMT_UNDEFINED && components == -1) { + // check if this UNDEFINED format is actually ASCII (as it usually is) + // if so, we can calculate the size + if(memcmp((char*)value, ExifAsciiPrefix, sizeof(ExifAsciiPrefix)) == 0) { + components = sizeof(ExifAsciiPrefix) + + strlen((char*)value + sizeof(ExifAsciiPrefix)) + 1; + if (components & 1) ++components; // no odd lengths + } + } Put32u(Buffer+(*DirIndex) + 4, components); // Components printf("# components: %ld", components); if (format == FMT_STRING) { @@ -1104,6 +1113,18 @@ static void writeExifTagAndData(int tag, strncpy(Buffer+(*DataWriteIndex), (char*)value, components); (*DataWriteIndex) += components; } + } else if ((format == FMT_UNDEFINED) && + (memcmp((char*)value, ExifAsciiPrefix, sizeof(ExifAsciiPrefix)) == 0)) { + // short strings can fit right in the long, otherwise have to + // go in the data area + if (components <= 4) { + memcpy(Buffer+(*DirIndex) + 8, (char*)value, components); + } else { + Put32u(Buffer+(*DirIndex) + 8, (*DataWriteIndex)-8); // Pointer + printf("copying %s to %d", (char*)value + sizeof(ExifAsciiPrefix), (*DataWriteIndex)); + memcpy(Buffer+(*DataWriteIndex), (char*)value, components); + (*DataWriteIndex) += components; + } } else if (!valueInString) { Put32u(Buffer+(*DirIndex) + 8, value); // Value } else { -- cgit v1.2.3