From 680104fec37155533c1e86b60ffb41e80eda1f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 11 Aug 2019 09:26:54 +0200 Subject: [PATCH] Fixed lat/lon reference parsing in big endian EXIF entries Closes #218 --- src/common/tifffile.h | 1 + src/data/exifparser.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/tifffile.h b/src/common/tifffile.h index 05dd816d..9ec461b0 100644 --- a/src/common/tifffile.h +++ b/src/common/tifffile.h @@ -17,6 +17,7 @@ public: TIFFFile(QIODevice *device); bool isValid() const {return _ifd != 0;} + bool isBE() const {return _be;} quint32 ifd() const {return _ifd;} bool seek(qint64 pos) {return _device->seek(_offset + pos);} diff --git a/src/data/exifparser.cpp b/src/data/exifparser.cpp index 0314517c..80200efc 100644 --- a/src/data/exifparser.cpp +++ b/src/data/exifparser.cpp @@ -113,9 +113,12 @@ Coordinates EXIFParser::coordinates(TIFFFile &file, const IFDEntry &lon, if (!c.isValid()) return Coordinates(); - if (lonRef.offset == 'W') + char ew = file.isBE() ? lonRef.offset >> 24 : lonRef.offset; + char ns = file.isBE() ? latRef.offset >> 24 : latRef.offset; + + if (ew == 'W') c.rlon() = -c.lon(); - if (latRef.offset == 'S') + if (ns == 'S') c.rlat() = -c.lat(); return c;