summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-04-21 14:10:10 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-04-21 21:55:48 +0200
commit922d87535b3413764928b70db159600c4ff2a8c2 (patch)
treefe699eec9dbf3ef07483802bdfa0922b0119544f
parentc0bb58329e16c9346039a12882b9c3be412e9f0b (diff)
Extract IFD processing in Exif.
Change-Id: Ia00803c748cd40b7e2e6142a2802ea6e4e13f8fd
-rw-r--r--vcl/source/filter/jpeg/Exif.cxx55
-rw-r--r--vcl/source/filter/jpeg/Exif.hxx1
2 files changed, 31 insertions, 25 deletions
diff --git a/vcl/source/filter/jpeg/Exif.cxx b/vcl/source/filter/jpeg/Exif.cxx
index be054dc6076a..318e2bdec5ae 100644
--- a/vcl/source/filter/jpeg/Exif.cxx
+++ b/vcl/source/filter/jpeg/Exif.cxx
@@ -155,6 +155,35 @@ bool Exif::processJpeg(SvStream& rStream, bool bSetValue)
return false;
}
+bool Exif::processIFD(sal_uInt8* pExifData, sal_uInt16 aLength, sal_uInt16 aOffset, sal_uInt16 aNumberOfTags, bool bSetValue)
+{
+ ExifIFD* ifd = NULL;
+
+ while (aOffset <= aLength - 12 && aNumberOfTags > 0)
+ {
+ ifd = (ExifIFD*) &pExifData[aOffset];
+
+ if (ifd->tag == Tag::ORIENTATION)
+ {
+ if(bSetValue)
+ {
+ ifd->tag = Tag::ORIENTATION;
+ ifd->type = 3;
+ ifd->count = 1;
+ ifd->offset = maOrientation;
+ }
+ else
+ {
+ maOrientation = convertToOrientation(ifd->offset);
+ }
+ }
+
+ aNumberOfTags--;
+ aOffset += 12;
+ }
+ return true;
+}
+
bool Exif::processExif(SvStream& rStream, sal_uInt16 aSectionLength, bool bSetValue)
{
sal_uInt32 aMagic32;
@@ -193,31 +222,7 @@ bool Exif::processExif(SvStream& rStream, sal_uInt16 aSectionLength, bool bSetVa
aNumberOfTags <<= 8;
aNumberOfTags += aExifData[aOffset];
- aOffset += 2;
-
- ExifIFD* ifd = NULL;
-
- while (aOffset <= aLength - 12 && aNumberOfTags > 0) {
- ifd = (ExifIFD*) &aExifData[aOffset];
-
- if (ifd->tag == Tag::ORIENTATION)
- {
- if(bSetValue)
- {
- ifd->tag = Tag::ORIENTATION;
- ifd->type = 3;
- ifd->count = 1;
- ifd->offset = maOrientation;
- }
- else
- {
- maOrientation = convertToOrientation(ifd->offset);
- }
- }
-
- aNumberOfTags--;
- aOffset += 12;
- }
+ processIFD(aExifData, aLength, aOffset+2, aNumberOfTags, bSetValue);
if (bSetValue)
{
diff --git a/vcl/source/filter/jpeg/Exif.hxx b/vcl/source/filter/jpeg/Exif.hxx
index eea8ada97534..def8ee3abf59 100644
--- a/vcl/source/filter/jpeg/Exif.hxx
+++ b/vcl/source/filter/jpeg/Exif.hxx
@@ -54,6 +54,7 @@ private:
bool processJpeg(SvStream& rStream, bool bSetValue);
bool processExif(SvStream& rStream, sal_uInt16 aLength, bool bSetValue);
+ bool processIFD(sal_uInt8* pExifData, sal_uInt16 aLength, sal_uInt16 aOffset, sal_uInt16 aNumberOfTags, bool bSetValue);
struct ExifIFD {
sal_uInt16 tag;