Added
Link Here
|
1 |
--- ImageLounge/src/DkCore/DkMetaData.cpp.orig 2020-07-17 07:05:29 UTC |
2 |
+++ ImageLounge/src/DkCore/DkMetaData.cpp |
3 |
@@ -73,8 +73,8 @@ void DkMetaDataT::readMetaData(const QString& filePath |
4 |
mExifImg = Exiv2::ImageFactory::open(strFilePath); |
5 |
} |
6 |
else { |
7 |
- Exiv2::BasicIo::AutoPtr exifBuffer(new Exiv2::MemIo((const byte*)ba->constData(), ba->size())); |
8 |
- mExifImg = Exiv2::ImageFactory::open(exifBuffer); |
9 |
+ Exiv2::BasicIo::UniquePtr exifBuffer(new Exiv2::MemIo((const byte*)ba->constData(), ba->size())); |
10 |
+ mExifImg = Exiv2::ImageFactory::open(std::move(exifBuffer)); |
11 |
} |
12 |
} |
13 |
catch (...) { |
14 |
@@ -156,13 +156,13 @@ bool DkMetaDataT::saveMetaData(QSharedPointer<QByteArr |
15 |
Exiv2::XmpData &xmpData = mExifImg->xmpData(); |
16 |
Exiv2::IptcData &iptcData = mExifImg->iptcData(); |
17 |
|
18 |
- Exiv2::Image::AutoPtr exifImgN; |
19 |
- Exiv2::MemIo::AutoPtr exifMem; |
20 |
+ Exiv2::Image::UniquePtr exifImgN; |
21 |
+ Exiv2::MemIo::UniquePtr exifMem; |
22 |
|
23 |
try { |
24 |
|
25 |
- exifMem = Exiv2::MemIo::AutoPtr(new Exiv2::MemIo((byte*)ba->data(), ba->size())); |
26 |
- exifImgN = Exiv2::ImageFactory::open(exifMem); |
27 |
+ exifMem = Exiv2::MemIo::UniquePtr(new Exiv2::MemIo((byte*)ba->data(), ba->size())); |
28 |
+ exifImgN = Exiv2::ImageFactory::open(std::move(exifMem)); |
29 |
} |
30 |
catch (...) { |
31 |
|
32 |
@@ -186,8 +186,8 @@ bool DkMetaDataT::saveMetaData(QSharedPointer<QByteArr |
33 |
|
34 |
// now get the data again |
35 |
Exiv2::DataBuf exifBuf = exifImgN->io().read((long)exifImgN->io().size()); |
36 |
- if (exifBuf.pData_) { |
37 |
- QSharedPointer<QByteArray> tmp = QSharedPointer<QByteArray>(new QByteArray((const char*)exifBuf.pData_, exifBuf.size_)); |
38 |
+ if (exifBuf.c_data()) { |
39 |
+ QSharedPointer<QByteArray> tmp = QSharedPointer<QByteArray>(new QByteArray((const char*)exifBuf.c_data(), exifBuf.size())); |
40 |
|
41 |
if (tmp->size() > qRound(ba->size()*0.5f)) |
42 |
ba = tmp; |
43 |
@@ -197,7 +197,7 @@ bool DkMetaDataT::saveMetaData(QSharedPointer<QByteArr |
44 |
else |
45 |
return false; |
46 |
|
47 |
- mExifImg = exifImgN; |
48 |
+ mExifImg = std::move(exifImgN); |
49 |
mExifState = loaded; |
50 |
|
51 |
return true; |
52 |
@@ -250,7 +250,7 @@ int DkMetaDataT::getOrientationDegree() const { |
53 |
|
54 |
if (pos != exifData.end() && pos->count() != 0) { |
55 |
|
56 |
- Exiv2::Value::AutoPtr v = pos->getValue(); |
57 |
+ Exiv2::Value::UniquePtr v = pos->getValue(); |
58 |
orientation = (int)pos->toFloat(); |
59 |
|
60 |
switch (orientation) { |
61 |
@@ -315,7 +315,7 @@ int DkMetaDataT::getRating() const { |
62 |
Exiv2::ExifData::iterator pos = exifData.findKey(key); |
63 |
|
64 |
if (pos != exifData.end() && pos->count() != 0) { |
65 |
- Exiv2::Value::AutoPtr v = pos->getValue(); |
66 |
+ Exiv2::Value::UniquePtr v = pos->getValue(); |
67 |
exifRating = v->toFloat(); |
68 |
} |
69 |
} |
70 |
@@ -327,7 +327,7 @@ int DkMetaDataT::getRating() const { |
71 |
|
72 |
//xmp Rating tag |
73 |
if (pos != xmpData.end() && pos->count() != 0) { |
74 |
- Exiv2::Value::AutoPtr v = pos->getValue(); |
75 |
+ Exiv2::Value::UniquePtr v = pos->getValue(); |
76 |
xmpRating = v->toFloat(); |
77 |
} |
78 |
|
79 |
@@ -336,7 +336,7 @@ int DkMetaDataT::getRating() const { |
80 |
key = Exiv2::XmpKey("Xmp.MicrosoftPhoto.Rating"); |
81 |
pos = xmpData.findKey(key); |
82 |
if (pos != xmpData.end() && pos->count() != 0) { |
83 |
- Exiv2::Value::AutoPtr v = pos->getValue(); |
84 |
+ Exiv2::Value::UniquePtr v = pos->getValue(); |
85 |
xmpRating = v->toFloat(); |
86 |
} |
87 |
} |
88 |
@@ -399,7 +399,7 @@ QString DkMetaDataT::getNativeExifValue(const QString& |
89 |
if (pos->count () < 2000) { // diem: this is about performance - adobe obviously embeds whole images into tiff exiv data |
90 |
|
91 |
//qDebug() << "pos count: " << pos->count(); |
92 |
- //Exiv2::Value::AutoPtr v = pos->getValue(); |
93 |
+ //Exiv2::Value::UniquePtr v = pos->getValue(); |
94 |
info = exiv2ToQString(pos->toString()); |
95 |
|
96 |
} |
97 |
@@ -436,7 +436,7 @@ QString DkMetaDataT::getXmpValue(const QString& key) c |
98 |
} |
99 |
|
100 |
if (pos != xmpData.end() && pos->count() != 0) { |
101 |
- Exiv2::Value::AutoPtr v = pos->getValue(); |
102 |
+ Exiv2::Value::UniquePtr v = pos->getValue(); |
103 |
info = exiv2ToQString(pos->toString()); |
104 |
} |
105 |
} |
106 |
@@ -478,7 +478,7 @@ QString DkMetaDataT::getExifValue(const QString& key) |
107 |
} |
108 |
|
109 |
if (pos != exifData.end() && pos->count() != 0) { |
110 |
- //Exiv2::Value::AutoPtr v = pos->getValue(); |
111 |
+ //Exiv2::Value::UniquePtr v = pos->getValue(); |
112 |
info = exiv2ToQString(pos->toString()); |
113 |
} |
114 |
} |
115 |
@@ -508,7 +508,7 @@ QString DkMetaDataT::getIptcValue(const QString& key) |
116 |
} |
117 |
|
118 |
if (pos != iptcData.end() && pos->count() != 0) { |
119 |
- Exiv2::Value::AutoPtr v = pos->getValue(); |
120 |
+ Exiv2::Value::UniquePtr v = pos->getValue(); |
121 |
info = exiv2ToQString(pos->toString()); |
122 |
} |
123 |
} |
124 |
@@ -654,7 +654,7 @@ QImage DkMetaDataT::getThumbnail() const { |
125 |
Exiv2::ExifThumb thumb(exifData); |
126 |
Exiv2::DataBuf buffer = thumb.copy(); |
127 |
|
128 |
- QByteArray ba = QByteArray((char*)buffer.pData_, buffer.size_); |
129 |
+ QByteArray ba = QByteArray((char*)buffer.c_data(), buffer.size()); |
130 |
qThumb.loadFromData(ba); |
131 |
} |
132 |
catch (...) { |
133 |
@@ -931,8 +931,8 @@ void DkMetaDataT::setThumbnail(QImage thumb) { |
134 |
|
135 |
try { |
136 |
// whipe all exif data of the thumbnail |
137 |
- Exiv2::MemIo::AutoPtr exifBufferThumb(new Exiv2::MemIo((const byte*)ba.constData(), ba.size())); |
138 |
- Exiv2::Image::AutoPtr exifImgThumb = Exiv2::ImageFactory::open(exifBufferThumb); |
139 |
+ Exiv2::MemIo::UniquePtr exifBufferThumb(new Exiv2::MemIo((const byte*)ba.constData(), ba.size())); |
140 |
+ Exiv2::Image::UniquePtr exifImgThumb = Exiv2::ImageFactory::open(std::move(exifBufferThumb)); |
141 |
|
142 |
if (exifImgThumb.get() != 0 && exifImgThumb->good()) |
143 |
exifImgThumb->clearExifData(); |
144 |
@@ -1045,11 +1045,11 @@ void DkMetaDataT::setOrientation(int o) { |
145 |
pos = exifData.findKey(key); |
146 |
} |
147 |
|
148 |
- Exiv2::Value::AutoPtr v = pos->getValue(); |
149 |
+ Exiv2::Value::UniquePtr v = pos->getValue(); |
150 |
Exiv2::UShortValue* prv = dynamic_cast<Exiv2::UShortValue*>(v.release()); |
151 |
if (!prv) return; |
152 |
|
153 |
- Exiv2::UShortValue::AutoPtr rv = Exiv2::UShortValue::AutoPtr(prv); |
154 |
+ Exiv2::UShortValue::UniquePtr rv = Exiv2::UShortValue::UniquePtr(prv); |
155 |
if (rv->value_.empty()) return; |
156 |
|
157 |
orientation = (int) rv->value_[0]; |
158 |
@@ -1110,7 +1110,7 @@ void DkMetaDataT::setRating(int r) { |
159 |
exifData["Exif.Image.Rating"] = uint16_t(r); |
160 |
exifData["Exif.Image.RatingPercent"] = uint16_t(r); |
161 |
|
162 |
- Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::xmpText); |
163 |
+ Exiv2::Value::UniquePtr v = Exiv2::Value::create(Exiv2::xmpText); |
164 |
v->read(sRating); |
165 |
xmpData.add(Exiv2::XmpKey("Xmp.xmp.Rating"), v.get()); |
166 |
v->read(sRatingPercent); |
167 |
@@ -1354,9 +1354,9 @@ DkRotatingRect DkMetaDataT::getXMPRect(const QSize& si |
168 |
return DkRotatingRect(rr); |
169 |
} |
170 |
|
171 |
-Exiv2::Image::AutoPtr DkMetaDataT::loadSidecar(const QString& filePath) const { |
172 |
+Exiv2::Image::UniquePtr DkMetaDataT::loadSidecar(const QString& filePath) const { |
173 |
|
174 |
- Exiv2::Image::AutoPtr xmpImg; |
175 |
+ Exiv2::Image::UniquePtr xmpImg; |
176 |
|
177 |
//TODO: check if the file type supports xmp |
178 |
|
179 |
@@ -1409,7 +1409,7 @@ bool DkMetaDataT::setXMPValue(Exiv2::XmpData& xmpData, |
180 |
setXMPValueSuccessful = true; |
181 |
} |
182 |
else { |
183 |
- Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::xmpText); |
184 |
+ Exiv2::Value::UniquePtr v = Exiv2::Value::create(Exiv2::xmpText); |
185 |
if (!v->read(xmpValue.toStdString())) { |
186 |
if (!xmpData.add(Exiv2::XmpKey(key), v.get())) |
187 |
setXMPValueSuccessful = true; |