本文整理汇总了C++中exiv2::image::AutoPtr::mimeType方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr::mimeType方法的具体用法?C++ AutoPtr::mimeType怎么用?C++ AutoPtr::mimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exiv2::image::AutoPtr
的用法示例。
在下文中一共展示了AutoPtr::mimeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: if
bool KExiv2::Private::saveOperations(const QFileInfo& finfo, Exiv2::Image::AutoPtr image) const
{
try
{
Exiv2::AccessMode mode;
bool wroteComment = false, wroteEXIF = false, wroteIPTC = false, wroteXMP = false;
// We need to load target file metadata to merge with new one. It's mandatory with TIFF format:
// like all tiff file structure is based on Exif.
image->readMetadata();
// Image Comments ---------------------------------
mode = image->checkMode(Exiv2::mdComment);
if ((mode == Exiv2::amWrite) || (mode == Exiv2::amReadWrite))
{
image->setComment(imageComments());
wroteComment = true;
}
// Exif metadata ----------------------------------
mode = image->checkMode(Exiv2::mdExif);
if ((mode == Exiv2::amWrite) || (mode == Exiv2::amReadWrite))
{
if (image->mimeType() == "image/tiff")
{
Exiv2::ExifData orgExif = image->exifData();
Exiv2::ExifData newExif;
QStringList untouchedTags;
// With tiff image we cannot overwrite whole Exif data as well, because
// image data are stored in Exif container. We need to take a care about
// to not lost image data.
untouchedTags << "Exif.Image.ImageWidth";
untouchedTags << "Exif.Image.ImageLength";
untouchedTags << "Exif.Image.BitsPerSample";
untouchedTags << "Exif.Image.Compression";
untouchedTags << "Exif.Image.PhotometricInterpretation";
untouchedTags << "Exif.Image.FillOrder";
untouchedTags << "Exif.Image.SamplesPerPixel";
untouchedTags << "Exif.Image.StripOffsets";
untouchedTags << "Exif.Image.RowsPerStrip";
untouchedTags << "Exif.Image.StripByteCounts";
untouchedTags << "Exif.Image.XResolution";
untouchedTags << "Exif.Image.YResolution";
untouchedTags << "Exif.Image.PlanarConfiguration";
untouchedTags << "Exif.Image.ResolutionUnit";
for (Exiv2::ExifData::iterator it = orgExif.begin(); it != orgExif.end(); ++it)
{
if (untouchedTags.contains(it->key().c_str()))
{
newExif[it->key().c_str()] = orgExif[it->key().c_str()];
}
}
Exiv2::ExifData readedExif = exifMetadata();
for (Exiv2::ExifData::iterator it = readedExif.begin(); it != readedExif.end(); ++it)
{
if (!untouchedTags.contains(it->key().c_str()))
{
newExif[it->key().c_str()] = readedExif[it->key().c_str()];
}
}
image->setExifData(newExif);
}
else
{
image->setExifData(exifMetadata());
}
wroteEXIF = true;
}
// Iptc metadata ----------------------------------
mode = image->checkMode(Exiv2::mdIptc);
if ((mode == Exiv2::amWrite) || (mode == Exiv2::amReadWrite))
{
image->setIptcData(iptcMetadata());
wroteIPTC = true;
}
// Xmp metadata -----------------------------------
mode = image->checkMode(Exiv2::mdXmp);
if ((mode == Exiv2::amWrite) || (mode == Exiv2::amReadWrite))
{
#ifdef _XMP_SUPPORT_
image->setXmpData(xmpMetadata());
wroteXMP = true;
#endif
}
//.........这里部分代码省略.........