From 8a3e708fd6c740e6e442fd28f99aae997ac1a8bb Mon Sep 17 00:00:00 2001 From: HumanDynamo Date: Thu, 18 Jun 2009 08:53:15 +0000 Subject: [PATCH] add PGF creation from scratch in memory --- src/pgfimage.cpp | 29 +++++++++++++++++++++++++++-- src/pgfimage.hpp | 1 - 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/pgfimage.cpp b/src/pgfimage.cpp index 9d32b3f7..79e47098 100644 --- a/src/pgfimage.cpp +++ b/src/pgfimage.cpp @@ -57,13 +57,38 @@ EXIV2_RCSID("@(#) $Id: pgfimage.cpp 1750 2009-02-16 14:30:51Z ahuggel $") // Signature from front of PGF file const unsigned char pgfSignature[3] = { 0x50, 0x47, 0x46 }; +const unsigned char pgfBlank[] = { 0x50,0x47,0x46,0x36,0x10,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x18,0x03,0x03,0x00,0x00,0x00,0x14,0x00,0x67,0x08,0x20,0x00,0xc0,0x01, + 0x00,0x00,0x37,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x37,0x00, + 0x00,0x78,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x37,0x00,0x00,0x78,0x00,0x00, + 0x00,0x00,0x01,0x00,0x00,0x00,0x37,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x01,0x00, + 0x00,0x00,0x37,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x37,0x00, + 0x00,0x78,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00 + }; + // ***************************************************************************** // class member definitions namespace Exiv2 { - PgfImage::PgfImage(BasicIo::AutoPtr io, bool /*create*/) - : Image(ImageType::pgf, mdExif | mdIptc | mdComment, io) + PgfImage::PgfImage(BasicIo::AutoPtr io, bool create) + : Image(ImageType::pgf, mdExif | mdIptc| mdXmp | mdComment, io) { + if (create) + { + if (io_->open() == 0) + { +#ifdef DEBUG + std::cerr << "Exiv2::PgfImage:: Creating PGF image to memory\n"; +#endif + IoCloser closer(*io_); + if (io_->write(pgfBlank, sizeof(pgfBlank)) != sizeof(pgfBlank)) + { +#ifdef DEBUG + std::cerr << "Exiv2::PgfImage:: Failed to create PGF image on memory\n"; +#endif + } + } + } } // PgfImage::PgfImage void PgfImage::readMetadata() diff --git a/src/pgfimage.hpp b/src/pgfimage.hpp index 35a71c5c..5c73a109 100644 --- a/src/pgfimage.hpp +++ b/src/pgfimage.hpp @@ -77,7 +77,6 @@ namespace Exiv2 method to get a temporary reference. @param create Specifies if an existing image should be read (false) or if a new file should be created (true). - This option is not yet implemented. */ PgfImage(BasicIo::AutoPtr io, bool create); //@}