本文整理汇总了C++中exiv2::image::AutoPtr::comment方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr::comment方法的具体用法?C++ AutoPtr::comment怎么用?C++ AutoPtr::comment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exiv2::image::AutoPtr
的用法示例。
在下文中一共展示了AutoPtr::comment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// *****************************************************************************
// Main
int main(int argc, char* const argv[])
{
try {
// Handle command line arguments
Params params;
if (params.getopt(argc, argv)) {
params.usage();
return 1;
}
if (params.help_) {
params.help();
return 2;
}
// Use MemIo to increase test coverage.
Exiv2::BasicIo::AutoPtr fileIo(new Exiv2::FileIo(params.read_));
Exiv2::BasicIo::AutoPtr memIo(new Exiv2::MemIo);
memIo->transfer(*fileIo);
Exiv2::Image::AutoPtr readImg = Exiv2::ImageFactory::open(memIo);
assert(readImg.get() != 0);
readImg->readMetadata();
Exiv2::Image::AutoPtr writeImg = Exiv2::ImageFactory::open(params.write_);
assert(writeImg.get() != 0);
if (params.preserve_) writeImg->readMetadata();
if (params.iptc_) {
writeImg->setIptcData(readImg->iptcData());
}
if (params.exif_) {
writeImg->setExifData(readImg->exifData());
}
if (params.comment_) {
writeImg->setComment(readImg->comment());
}
if (params.xmp_) {
writeImg->setXmpData(readImg->xmpData());
}
try {
writeImg->writeMetadata();
}
catch (const Exiv2::AnyError&) {
std::cerr << params.progname() <<
": Could not write metadata to (" << params.write_ << ")\n";
return 8;
}
return 0;
}
catch (Exiv2::AnyError& e) {
std::cerr << "Caught Exiv2 exception '" << e << "'\n";
return 10;
}
}
示例2: QSize
bool KExiv2::loadFromData(const QByteArray& imgData) const
{
if (imgData.isEmpty())
return false;
try
{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open((Exiv2::byte*)imgData.data(), imgData.size());
d->filePath.clear();
image->readMetadata();
// Size and mimetype ---------------------------------
d->pixelSize = QSize(image->pixelWidth(), image->pixelHeight());
d->mimeType = QString::fromLatin1(image->mimeType().c_str());
// Image comments ---------------------------------
d->imageComments() = image->comment();
// Exif metadata ----------------------------------
d->exifMetadata() = image->exifData();
// Iptc metadata ----------------------------------
d->iptcMetadata() = image->iptcData();
#ifdef _XMP_SUPPORT_
// Xmp metadata -----------------------------------
d->xmpMetadata() = image->xmpData();
#endif // _XMP_SUPPORT_
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError(QString::fromLatin1("Cannot load metadata using Exiv2 "), e);
}
catch(...)
{
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
return false;
}
示例3: xmpSidecarFileInfo
bool KExiv2::load(const QString& filePath) const
{
if (filePath.isEmpty())
{
return false;
}
d->filePath = filePath;
bool hasLoaded = false;
try
{
Exiv2::Image::AutoPtr image;
image = Exiv2::ImageFactory::open((const char*)(QFile::encodeName(filePath)).constData());
image->readMetadata();
// Size and mimetype ---------------------------------
d->pixelSize = QSize(image->pixelWidth(), image->pixelHeight());
d->mimeType = QString::fromLatin1(image->mimeType().c_str());
// Image comments ---------------------------------
d->imageComments() = image->comment();
// Exif metadata ----------------------------------
d->exifMetadata() = image->exifData();
// Iptc metadata ----------------------------------
d->iptcMetadata() = image->iptcData();
#ifdef _XMP_SUPPORT_
// Xmp metadata -----------------------------------
d->xmpMetadata() = image->xmpData();
#endif // _XMP_SUPPORT_
hasLoaded = true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError(QString::fromLatin1("Cannot load metadata from file "), e);
}
catch(...)
{
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
#ifdef _XMP_SUPPORT_
try
{
if (d->useXMPSidecar4Reading)
{
QString xmpSidecarPath = sidecarFilePathForFile(filePath);
QFileInfo xmpSidecarFileInfo(xmpSidecarPath);
Exiv2::Image::AutoPtr xmpsidecar;
if (xmpSidecarFileInfo.exists() && xmpSidecarFileInfo.isReadable())
{
// Read sidecar data
xmpsidecar = Exiv2::ImageFactory::open(QFile::encodeName(xmpSidecarPath).constData());
xmpsidecar->readMetadata();
// Merge
d->loadSidecarData(xmpsidecar);
hasLoaded = true;
}
}
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError(QString::fromLatin1("Cannot load XMP sidecar"), e);
}
catch(...)
{
qCCritical(LIBKEXIV2_LOG) << "Default exception from Exiv2";
}
#endif // _XMP_SUPPORT_
return hasLoaded;
}