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

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


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

The following commit has been merged in the master branch:
commit fab4603d700b1b8e19e137c5bd0dbcc68a1453f7
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Sun Jan 3 15:20:46 2010 +0000

    #665: Added write-support for ORF files.
---
 src/image.cpp        |   2 +-
 src/orfimage.cpp     | 105 +++++++++++++++++++++++++++++++++++----------------
 src/orfimage.hpp     |  18 +--------
 src/orfimage_int.hpp |   5 ++-
 4 files changed, 80 insertions(+), 50 deletions(-)

diff --git a/src/image.cpp b/src/image.cpp
index 29f62cef..13c9187 100644
--- a/src/image.cpp
+++ b/src/image.cpp
@@ -106,7 +106,7 @@ namespace {
         { ImageType::crw,  newCrwInstance,  isCrwType,  amReadWrite, amNone,      amNone,      amReadWrite },
         { ImageType::mrw,  newMrwInstance,  isMrwType,  amRead,      amRead,      amRead,      amNone      },
         { ImageType::tiff, newTiffInstance, isTiffType, amReadWrite, amReadWrite, amReadWrite, amNone      },
-        { ImageType::orf,  newOrfInstance,  isOrfType,  amRead,      amRead,      amRead,      amNone      },
+        { ImageType::orf,  newOrfInstance,  isOrfType,  amReadWrite, amReadWrite, amReadWrite, amNone      },
 #ifdef EXV_HAVE_LIBZ
         { ImageType::png,  newPngInstance,  isPngType,  amReadWrite, amReadWrite, amReadWrite, amReadWrite },
 #endif // EXV_HAVE_LIBZ
diff --git a/src/orfimage.cpp b/src/orfimage.cpp
index 9ae011b..132221d 100644
--- a/src/orfimage.cpp
+++ b/src/orfimage.cpp
@@ -86,18 +86,6 @@ namespace Exiv2 {
         return 0;
     }
 
-    void OrfImage::setExifData(const ExifData& /*exifData*/)
-    {
-        // Todo: implement me!
-        throw(Error(32, "Exif metadata", "ORF"));
-    }
-
-    void OrfImage::setIptcData(const IptcData& /*iptcData*/)
-    {
-        // Todo: implement me!
-        throw(Error(32, "IPTC metadata", "ORF"));
-    }
-
     void OrfImage::setComment(const std::string& /*comment*/)
     {
         // not supported
@@ -129,8 +117,29 @@ namespace Exiv2 {
 
     void OrfImage::writeMetadata()
     {
-        // Todo: implement me!
-        throw(Error(31, "ORF"));
+#ifdef DEBUG
+        std::cerr << "Writing ORF file " << io_->path() << "
";
+#endif
+        ByteOrder bo = byteOrder();
+        byte* pData = 0;
+        long size = 0;
+        IoCloser closer(*io_);
+        if (io_->open() == 0) {
+            // Ensure that this is the correct image type
+            if (isOrfType(*io_, false)) {
+                pData = io_->mmap(true);
+                size = io_->size();
+                OrfHeader orfHeader;
+                if (0 == orfHeader.read(pData, 8)) {
+                    bo = orfHeader.byteOrder();
+                }
+            }
+        }
+        if (bo == invalidByteOrder) {
+            bo = littleEndian;
+        }
+        setByteOrder(bo);
+        OrfParser::encode(*io_, pData, size, bo, exifData_, iptcData_, xmpData_); // may throw
     } // OrfImage::writeMetadata
 
     ByteOrder OrfParser::decode(
@@ -153,27 +162,42 @@ namespace Exiv2 {
     }
 
     WriteMethod OrfParser::encode(
-              Blob&     blob,
+              BasicIo&  io,
         const byte*     pData,
               uint32_t  size,
+              ByteOrder byteOrder,
         const ExifData& exifData,
         const IptcData& iptcData,
         const XmpData&  xmpData
     )
     {
-        /* Todo: Implement me!
-
-        return TiffParserWorker::encode(blob,
-                                 pData,
-                                 size,
-                                 exifData,
-                                 iptcData,
-                                 xmpData,
-                                 TiffCreator::create,
-                                 TiffMapping::findEncoder);
-        */
-        blob.clear();
-        return wmIntrusive;
+        // Copy to be able to modify the Exif data
+        ExifData ed = exifData;
+
+        // Delete IFDs which do not occur in TIFF images
+        static const IfdId filteredIfds[] = {
+            panaRawIfdId
+        };
+        for (unsigned int i = 0; i < EXV_COUNTOF(filteredIfds); ++i) {
+#ifdef DEBUG
+            std::cerr << "Warning: Exif IFD " << filteredIfds[i] << " not encoded
";
+#endif
+            ed.erase(std::remove_if(ed.begin(),
+                                    ed.end(),
+                                    FindExifdatum(filteredIfds[i])),
+                     ed.end());
+        }
+
+        std::auto_ptr<TiffHeaderBase> header(new OrfHeader(byteOrder));
+        return TiffParserWorker::encode(io,
+                                        pData,
+                                        size,
+                                        ed,
+                                        iptcData,
+                                        xmpData,
+                                        Tag::root,
+                                        TiffMapping::findEncoder,
+                                        header.get());
     }
 
     // *************************************************************************
@@ -208,8 +232,9 @@ namespace Exiv2 {
 namespace Exiv2 {
     namespace Internal {
 
-    OrfHeader::OrfHeader()
-        : TiffHeaderBase(0x4f52, 8, littleEndian, 0x00000008)
+    OrfHeader::OrfHeader(ByteOrder byteOrder)
+        : TiffHeaderBase(0x4f52, 8, byteOrder, 0x00000008),
+          sig_(0x4f52)
     {
     }
 
@@ -232,6 +257,7 @@ namespace Exiv2 {
         }
         uint16_t sig = getUShort(pData + 2, byteOrder());
         if (tag() != sig && 0x5352 != sig) return false; // #658: Added 0x5352 for SP-560UZ
+        sig_ = sig;
         setOffset(getULong(pData + 4, byteOrder()));
         if (offset() != 0x00000008) return false;
 
@@ -240,8 +266,23 @@ namespace Exiv2 {
 
     DataBuf OrfHeader::write() const
     {
-        // Todo: Implement me!
-        return DataBuf();
+        DataBuf buf(8);
+        switch (byteOrder()) {
+        case littleEndian:
+            buf.pData_[0] = 0x49;
+            buf.pData_[1] = 0x49;
+            break;
+        case bigEndian:
+            buf.pData_[0] = 0x4d;
+            buf.pData_[1] = 0x4d;
+            break;
+        case invalidByteOrder:
+            assert(false);
+            break;
+        }
+        us2Data(buf.pData_ + 2, sig_, byteOrder());
+        ul2Data(buf.pData_ + 4, 0x00000008, byteOrder());
+        return buf;
     }
 
 }}                                      // namespace Internal, Exiv2
diff --git a/src/orfimage.hpp b/src/orfimage.hpp
index 4fac825..5538948 100644
--- a/src/orfimage.hpp
+++ b/src/orfimage.hpp
@@ -79,22 +79,8 @@ namespace Exiv2 {
         //! @name Manipulators
         //@{
         void readMetadata();
-        /*!
-          @brief Todo: Write metadata back to the image. This method is not
-              yet implemented. Calling it will throw an Error(31).
-         */
         void writeMetadata();
         /*!
-          @brief Todo: Not supported yet, requires writeMetadata(). Calling
-              this function will throw an Error(32).
-         */
-        void setExifData(const ExifData& exifData);
-        /*!
-          @brief Todo: Not supported yet, requires writeMetadata(). Calling
-              this function will throw an Error(32).
-         */
-        void setIptcData(const IptcData& iptcData);
-        /*!
           @brief Not supported. ORF format does not contain a comment.
               Calling this function will throw an Error(32).
          */
@@ -143,14 +129,14 @@ namespace Exiv2 {
                  See TiffParser::encode().
         */
         static WriteMethod encode(
-                  Blob&     blob,
+                  BasicIo&  io,
             const byte*     pData,
                   uint32_t  size,
+                  ByteOrder byteOrder,
             const ExifData& exifData,
             const IptcData& iptcData,
             const XmpData&  xmpData
         );
-
     }; // class OrfParser
 
 // *****************************************************************************
diff --git a/src/orfimage_int.hpp b/src/orfimage_int.hpp
index 31c779f..5a52a0a 100644
--- a/src/orfimage_int.hpp
+++ b/src/orfimage_int.hpp
@@ -51,7 +51,7 @@ namespace Exiv2 {
         //! @name Creators
         //@{
         //! Default constructor
-        OrfHeader();
+        OrfHeader(ByteOrder byteOrder =littleEndian);
         //! Destructor.
         ~OrfHeader();
         //@}
@@ -65,6 +65,9 @@ namespace Exiv2 {
         //@{
         DataBuf write() const;
         //@}
+    private:
+        // DATA
+        uint16_t sig_;       //<! The actual magic number
     }; // class OrfHeader
 
 }}                                      // namespace Internal, Exiv2

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list