[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:36:13 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=7d7322d

The following commit has been merged in the master branch:
commit 7d7322dff76a6e644e0997496042701f3be6ad45
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Wed Mar 31 02:53:21 2004 +0000

    Implemented ImageFactory::create() and its use in ExifData
---
 src/exif.cpp       | 34 ++++++++++++++------
 src/exif.hpp       |  8 +++--
 src/exifprint.cpp  |  5 ++-
 src/image.cpp      | 66 +++++++++++++++++++++------------------
 src/image.hpp      | 92 ++++++++++++++++++++++++++++--------------------------
 src/write-test.cpp | 10 ++++--
 6 files changed, 125 insertions(+), 90 deletions(-)

diff --git a/src/exif.cpp b/src/exif.cpp
index 33135dd..1af64ec 100644
--- a/src/exif.cpp
+++ b/src/exif.cpp
@@ -20,14 +20,14 @@
  */
 /*
   File:      exif.cpp
-  Version:   $Name:  $ $Revision: 1.33 $
+  Version:   $Name:  $ $Revision: 1.34 $
   Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
   History:   26-Jan-04, ahu: created
              11-Feb-04, ahu: isolated as a component
  */
 // *****************************************************************************
 #include "rcsid.hpp"
-EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.33 $ $RCSfile: exif.cpp,v $")
+EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.34 $ $RCSfile: exif.cpp,v $")
 
 // *****************************************************************************
 // included header files
@@ -480,10 +480,17 @@ namespace Exif {
 
     int ExifData::read(const std::string& path)
     {
-        JpegImage image;
-        int rc = image.readExifData(path);
-        if (rc) return rc;
-        return read(image.exifData(), image.sizeExifData());
+        std::ifstream file(path.c_str(), std::ios::binary);
+        if (!file) return -1;
+        Image* pImage = ImageFactory::instance().create(file);
+        file.close();
+        if (pImage == 0) return -2;
+        // Todo: should we use file to read from? (and write isThisType so 
+        //       that it doesn't advance the stream)
+        int rc = pImage->readExifData(path);
+        if (rc == 0) rc = read(pImage->exifData(), pImage->sizeExifData());
+        delete pImage;
+        return rc;
     }
 
     int ExifData::read(const char* buf, long len)
@@ -579,10 +586,19 @@ namespace Exif {
         char* buf = new char[size];
         long actualSize = copy(buf);
         assert(actualSize <= size);
-        JpegImage image;
-        image.setExifData(buf, actualSize);
+
+        std::ifstream file(path.c_str(), std::ios::binary);
+        if (!file) return -1;
+        Image* pImage = ImageFactory::instance().create(file);
+        file.close();
+        if (pImage == 0) return -2;
+        pImage->setExifData(buf, actualSize);
         delete[] buf;
-        return image.writeExifData(path);
+        // Todo: Should this method take a path and stream arg?
+        //       Then we could reuse the file stream from above.
+        int rc = pImage->writeExifData(path);
+        delete pImage;
+        return rc;
     } // ExifData::write
 
     long ExifData::copy(char* buf)
diff --git a/src/exif.hpp b/src/exif.hpp
index 7b1c8cc..c3d539e 100644
--- a/src/exif.hpp
+++ b/src/exif.hpp
@@ -21,7 +21,7 @@
 /*!
   @file    exif.hpp
   @brief   Encoding and decoding of %Exif data
-  @version $Name:  $ $Revision: 1.33 $
+  @version $Name:  $ $Revision: 1.34 $
   @author  Andreas Huggel (ahu)
            <a href="mailto:ahuggel at gmx.net">ahuggel at gmx.net</a>
   @date    09-Jan-04, ahu: created
@@ -504,8 +504,10 @@ namespace Exif {
         /*!
           @brief Read the %Exif data from file path.
           @param path Path to the file
-          @return 0 if successful<br>
-                  the return code of readExifData(std::istream& is)
+          @return  0 if successful;<BR>
+                  -1 if the file couldn't be opened;<BR>
+                  -2 if the file type is unknown;<BR>
+                  the return code of Image::readExifData(std::istream& is)
                     if the call to this function fails<br>
                   the return code of read(const char* buf, long len)
                     if the call to this function fails<br>
diff --git a/src/exifprint.cpp b/src/exifprint.cpp
index ec0a370..8d84b66 100644
--- a/src/exifprint.cpp
+++ b/src/exifprint.cpp
@@ -3,7 +3,7 @@
   Abstract : Sample program to print the Exif metadata of an image
 
   File:      exifprint.cpp
-  Version  : $Name:  $ $Revision: 1.11 $
+  Version  : $Name:  $ $Revision: 1.12 $
   Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
   History  : 26-Jan-04, ahu: created
  */
@@ -63,6 +63,9 @@ std::string readError(int rc, const char* file)
     case -1:
         error = "Couldn't open file `" + std::string(file) + "'";
         break;
+    case -2:
+        error = "The file contains data of an unknown image type";
+        break;
     case 1:
         error = "Couldn't read from the input stream";
         break;
diff --git a/src/image.cpp b/src/image.cpp
index 063cdf7..3bc927a 100644
--- a/src/image.cpp
+++ b/src/image.cpp
@@ -20,14 +20,14 @@
  */
 /*
   File:      image.cpp
-  Version:   $Name:  $ $Revision: 1.4 $
+  Version:   $Name:  $ $Revision: 1.5 $
   Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
   History:   26-Jan-04, ahu: created
              11-Feb-04, ahu: isolated as a component
  */
 // *****************************************************************************
 #include "rcsid.hpp"
-EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.4 $ $RCSfile: image.cpp,v $")
+EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.5 $ $RCSfile: image.cpp,v $")
 
 // *****************************************************************************
 // included header files
@@ -72,7 +72,21 @@ namespace Exif {
         registerImage(Image::jpeg, new JpegImage);
     } // ImageFactory c'tor
 
-    Image* ImageFactory::create(Image::Type type)
+    Image* ImageFactory::create(std::istream& is) const
+    {
+        Registry::const_iterator b = registry_.begin();
+        Registry::const_iterator e = registry_.end();
+        for (Registry::const_iterator i = b; i != e; ++i)
+        {
+            if (i->second != 0 && i->second->isThisType(is)) {
+                Image* pImage = i->second;
+                return pImage->clone();
+            }
+        }
+        return 0;
+    } // ImageFactory::create
+
+    Image* ImageFactory::create(Image::Type type) const
     {
         Registry::const_iterator i = registry_.find(type);
         if (i != registry_.end() && i->second != 0) {
@@ -124,24 +138,6 @@ namespace Exif {
     const char JpegImage::exifId_[] = "Exif

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list