aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/exiv2wrapper.cpp22
-rw-r--r--src/exiv2wrapper.hpp6
2 files changed, 21 insertions, 7 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp
index c6a94de..ac2c46b 100644
--- a/src/exiv2wrapper.cpp
+++ b/src/exiv2wrapper.cpp
@@ -41,7 +41,7 @@
namespace exiv2wrapper
{
-void Image::_instantiate_image(Exiv2::byte* data, long size)
+void Image::_instantiate_image()
{
// If an exception is thrown, it has to be done outside of the
// Py_{BEGIN,END}_ALLOW_THREADS block.
@@ -53,9 +53,9 @@ void Image::_instantiate_image(Exiv2::byte* data, long size)
try
{
- if (data != 0)
+ if (_data != 0)
{
- _image = Exiv2::ImageFactory::open(data, size);
+ _image = Exiv2::ImageFactory::open(_data, _size);
}
else
{
@@ -85,6 +85,7 @@ void Image::_instantiate_image(Exiv2::byte* data, long size)
Image::Image(const std::string& filename)
{
_filename = filename;
+ _data = 0;
_instantiate_image();
}
@@ -92,13 +93,14 @@ Image::Image(const std::string& filename)
Image::Image(const std::string& buffer, long size)
{
// Deep copy of the data buffer
- Exiv2::byte* data = new Exiv2::byte[size];
+ _data = new Exiv2::byte[size];
for (unsigned long i = 0; i < size; ++i)
{
- data[i] = buffer[i];
+ _data[i] = buffer[i];
}
- _instantiate_image(data, size);
+ _size = size;
+ _instantiate_image();
}
// Copy constructor
@@ -108,6 +110,14 @@ Image::Image(const Image& image)
_instantiate_image();
}
+Image::~Image()
+{
+ if (_data != 0)
+ {
+ delete _data;
+ }
+}
+
void Image::readMetadata()
{
// If an exception is thrown, it has to be done outside of the
diff --git a/src/exiv2wrapper.hpp b/src/exiv2wrapper.hpp
index 5443f2b..2be1855 100644
--- a/src/exiv2wrapper.hpp
+++ b/src/exiv2wrapper.hpp
@@ -154,6 +154,8 @@ public:
Image(const std::string& buffer, long size);
Image(const Image& image);
+ ~Image();
+
void readMetadata();
void writeMetadata();
@@ -230,6 +232,8 @@ public:
private:
std::string _filename;
+ Exiv2::byte* _data;
+ long _size;
Exiv2::Image::AutoPtr _image;
Exiv2::ExifData _exifData;
Exiv2::IptcData _iptcData;
@@ -239,7 +243,7 @@ private:
// false otherwise
bool _dataRead;
- void _instantiate_image(Exiv2::byte* data=0, long size=0);
+ void _instantiate_image();
};