From 76a3a36e51b6b5e0fc95cda9ac578dc9c61d4421 Mon Sep 17 00:00:00 2001 From: HumanDynamo Date: Thu, 18 Jun 2009 08:29:22 +0000 Subject: [PATCH] creating JPEG2 blank file from scratch is now supported --- src/jp2image.cpp | 36 +++++++++++++++++++++++++++++++++++- src/jp2image.hpp | 1 - 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 625d1a0a..1b01934c 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -69,6 +69,24 @@ const unsigned char kJp2UuidXmp[] = "\xbe\x7a\xcf\xcb\x97\xa9\x42\xe8\x9c\x71\x // See section B.1.1 (JPEG 2000 Signature box) of JPEG-2000 specification const unsigned char Jp2Signature[12] = { 0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a }; +const unsigned char Jp2Blank[] = { 0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20,0x0d,0x0a,0x87,0x0a,0x00,0x00,0x00,0x14, + 0x66,0x74,0x79,0x70,0x6a,0x70,0x32,0x20,0x00,0x00,0x00,0x00,0x6a,0x70,0x32,0x20, + 0x00,0x00,0x00,0x2d,0x6a,0x70,0x32,0x68,0x00,0x00,0x00,0x16,0x69,0x68,0x64,0x72, + 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x07,0x07,0x00,0x00,0x00,0x00, + 0x00,0x0f,0x63,0x6f,0x6c,0x72,0x01,0x00,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x00, + 0x00,0x6a,0x70,0x32,0x63,0xff,0x4f,0xff,0x51,0x00,0x29,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07, + 0x01,0x01,0xff,0x64,0x00,0x23,0x00,0x01,0x43,0x72,0x65,0x61,0x74,0x6f,0x72,0x3a, + 0x20,0x4a,0x61,0x73,0x50,0x65,0x72,0x20,0x56,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20, + 0x31,0x2e,0x39,0x30,0x30,0x2e,0x31,0xff,0x52,0x00,0x0c,0x00,0x00,0x00,0x01,0x00, + 0x05,0x04,0x04,0x00,0x01,0xff,0x5c,0x00,0x13,0x40,0x40,0x48,0x48,0x50,0x48,0x48, + 0x50,0x48,0x48,0x50,0x48,0x48,0x50,0x48,0x48,0x50,0xff,0x90,0x00,0x0a,0x00,0x00, + 0x00,0x00,0x00,0x2d,0x00,0x01,0xff,0x5d,0x00,0x14,0x00,0x40,0x40,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x93,0xcf,0xb4, + 0x04,0x00,0x80,0x80,0x80,0x80,0x80,0xff,0xd9 + }; + //! @cond IGNORE struct Jp2BoxHeader { @@ -99,9 +117,25 @@ struct Jp2UuidBox namespace Exiv2 { - Jp2Image::Jp2Image(BasicIo::AutoPtr io, bool /*create*/) + Jp2Image::Jp2Image(BasicIo::AutoPtr io, bool create) : Image(ImageType::jp2, mdExif | mdIptc | mdXmp, io) { + if (create) + { + if (io_->open() == 0) + { +#ifdef DEBUG + std::cerr << "Exiv2::Jp2Image:: Creating PNG image to memory\n"; +#endif + IoCloser closer(*io_); + if (io_->write(Jp2Blank, sizeof(Jp2Blank)) != sizeof(Jp2Blank)) + { +#ifdef DEBUG + std::cerr << "Exiv2::Jp2Image:: Failed to create PNG image on memory\n"; +#endif + } + } + } } // Jp2Image::Jp2Image void Jp2Image::setComment(const std::string& /*comment*/) diff --git a/src/jp2image.hpp b/src/jp2image.hpp index 2610f54c..2e96098c 100644 --- a/src/jp2image.hpp +++ b/src/jp2image.hpp @@ -76,7 +76,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. */ Jp2Image(BasicIo::AutoPtr io, bool create); //@}