本文整理汇总了C++中exiv2::iptcdata::iterator::tagName方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::tagName方法的具体用法?C++ iterator::tagName怎么用?C++ iterator::tagName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exiv2::iptcdata::iterator
的用法示例。
在下文中一共展示了iterator::tagName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateExifInfo
void ThumbView::updateExifInfo(QString imageFullPath)
{
Exiv2::Image::AutoPtr exifImage;
QString key;
QString val;
try {
exifImage = Exiv2::ImageFactory::open(imageFullPath.toStdString());
exifImage->readMetadata();
}
catch (Exiv2::Error &error) {
return;
}
Exiv2::ExifData &exifData = exifImage->exifData();
if (!exifData.empty()) {
Exiv2::ExifData::const_iterator end = exifData.end();
infoView->addTitleEntry("Exif");
for (Exiv2::ExifData::const_iterator md = exifData.begin(); md != end; ++md) {
key = QString::fromUtf8(md->tagName().c_str());
val = QString::fromUtf8(md->print().c_str());
infoView->addEntry(key, val);
}
}
Exiv2::IptcData &iptcData = exifImage->iptcData();
if (!iptcData.empty()) {
Exiv2::IptcData::iterator end = iptcData.end();
infoView->addTitleEntry("IPTC");
for (Exiv2::IptcData::iterator md = iptcData.begin(); md != end; ++md) {
key = QString::fromUtf8(md->tagName().c_str());
val = QString::fromUtf8(md->print().c_str());
infoView->addEntry(key, val);
}
}
Exiv2::XmpData &xmpData = exifImage->xmpData();
if (!xmpData.empty()) {
Exiv2::XmpData::iterator end = xmpData.end();
infoView->addTitleEntry("XMP");
for (Exiv2::XmpData::iterator md = xmpData.begin(); md != end; ++md) {
key = QString::fromUtf8(md->tagName().c_str());
val = QString::fromUtf8(md->print().c_str());
infoView->addEntry(key, val);
}
}
}
示例2: writeTagsToImage
bool ImageTags::writeTagsToImage(QString &imageFileName, QSet<QString> &newTags)
{
QSet<QString> imageTags;
Exiv2::Image::AutoPtr exifImage;
try {
exifImage = Exiv2::ImageFactory::open(imageFileName.toStdString());
exifImage->readMetadata();
Exiv2::IptcData newIptcData;
/* copy existing data */
Exiv2::IptcData &iptcData = exifImage->iptcData();
if (!iptcData.empty()) {
QString key;
Exiv2::IptcData::iterator end = iptcData.end();
for (Exiv2::IptcData::iterator iptcIt = iptcData.begin(); iptcIt != end; ++iptcIt) {
if (iptcIt->tagName() != "Keywords") {
newIptcData.add(*iptcIt);
}
}
}
/* add new tags */
QSetIterator<QString> newTagsIt(newTags);
while (newTagsIt.hasNext()) {
QString tag = newTagsIt.next();
Exiv2::Value::AutoPtr value = Exiv2::Value::create(Exiv2::string);
value->read(tag.toStdString());
Exiv2::IptcKey key("Iptc.Application2.Keywords");
newIptcData.add(key, value.get());
}
exifImage->setIptcData(newIptcData);
exifImage->writeMetadata();
}
catch (Exiv2::Error &error) {
QMessageBox msgBox;
msgBox.critical(this, tr("Error"), tr("Failed to save tags to ") + imageFileName);
return false;
}
return true;
}