direct initialize some structs

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2023-03-31 12:36:32 -07:00
parent 0dd06894b3
commit 233f404ac7
3 changed files with 11 additions and 29 deletions

View File

@ -759,33 +759,16 @@ void readWriteEpsMetadata(BasicIo& io, std::string& xmpPacket, NativePreviewList
}
}
if (posEndPhotoshop != posEndEps) {
NativePreview nativePreview;
nativePreview.position_ = static_cast<long>(posBeginPhotoshop);
nativePreview.size_ = static_cast<uint32_t>(posEndPhotoshop - posBeginPhotoshop);
nativePreview.width_ = 0;
nativePreview.height_ = 0;
nativePreview.filter_ = "hex-irb";
nativePreview.mimeType_ = "image/jpeg";
auto sizePhotoshop = posEndPhotoshop - posBeginPhotoshop;
NativePreview nativePreview{posBeginPhotoshop, sizePhotoshop, 0, 0, "hex-irb", "image/jpeg"};
nativePreviews.push_back(std::move(nativePreview));
}
if (sizeWmf != 0) {
NativePreview nativePreview;
nativePreview.position_ = static_cast<long>(posWmf);
nativePreview.size_ = sizeWmf;
nativePreview.width_ = 0;
nativePreview.height_ = 0;
nativePreview.filter_ = "";
nativePreview.mimeType_ = "image/x-wmf";
NativePreview nativePreview{posWmf, sizeWmf, 0, 0, "", "image/x-wmf"};
nativePreviews.push_back(std::move(nativePreview));
}
if (sizeTiff != 0) {
NativePreview nativePreview;
nativePreview.position_ = static_cast<long>(posTiff);
nativePreview.size_ = sizeTiff;
nativePreview.width_ = 0;
nativePreview.height_ = 0;
nativePreview.filter_ = "";
nativePreview.mimeType_ = "image/tiff";
NativePreview nativePreview{posTiff, sizeTiff, 0, 0, "", "image/tiff"};
nativePreviews.push_back(std::move(nativePreview));
}
} else {

View File

@ -292,13 +292,12 @@ void PsdImage::readResourceBlock(uint16_t resourceId, uint32_t resourceSize) {
if (io_->error() || io_->eof())
throw Error(ErrorCode::kerFailedToReadImageData);
if (format == 1) {
nativePreview.filter_ = "";
nativePreview.mimeType_ = "image/jpeg";
nativePreviews_.push_back(std::move(nativePreview));
} else {
// unsupported format of native preview
}
// unsupported format of native preview
if (format != 1)
break;
nativePreview.filter_ = "";
nativePreview.mimeType_ = "image/jpeg";
nativePreviews_.push_back(std::move(nativePreview));
}
break;
}

View File

@ -422,7 +422,7 @@ Xmpdatum& XmpData::operator[](const std::string& key) {
XmpKey xmpKey(key);
auto pos = findKey(xmpKey);
if (pos == end()) {
xmpMetadata_.push_back(Xmpdatum(xmpKey));
xmpMetadata_.emplace_back(xmpKey);
return xmpMetadata_.back();
}
return *pos;