本文整理汇总了C++中image::AutoPtr::setIptcData方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr::setIptcData方法的具体用法?C++ AutoPtr::setIptcData怎么用?C++ AutoPtr::setIptcData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image::AutoPtr
的用法示例。
在下文中一共展示了AutoPtr::setIptcData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
int IptcData::write(const std::string& path)
{
// Remove the Iptc section from the file if there is no metadata
if (count() == 0) return erase(path);
if (!fileExists(path, true)) return -1;
Image::AutoPtr image = ImageFactory::instance().open(path);
if (image.get() == 0) return -2;
DataBuf buf(copy());
// Read all metadata to preserve non-Iptc data
int rc = image->readMetadata();
if (rc == 0) {
image->setIptcData(buf.pData_, buf.size_);
rc = image->writeMetadata();
}
return rc;
} // IptcData::write
示例2: doWriteMetadata
void PgfImage::doWriteMetadata(BasicIo& outIo)
{
if (!io_->isopen()) throw Error(20);
if (!outIo.isopen()) throw Error(21);
#ifdef DEBUG
std::cout << "Exiv2::PgfImage::doWriteMetadata: Writing PGF file " << io_->path() << "\n";
std::cout << "Exiv2::PgfImage::doWriteMetadata: tmp file created " << outIo.path() << "\n";
#endif
// Ensure that this is the correct image type
if (!isPgfType(*io_, true))
{
if (io_->error() || io_->eof()) throw Error(20);
throw Error(22);
}
// Ensure PGF version.
byte mnb = readPgfMagicNumber(*io_);
readPgfHeaderSize(*io_);
int w, h;
DataBuf header = readPgfHeaderStructure(*io_, w, h);
Image::AutoPtr img = ImageFactory::create(ImageType::png);
img->setExifData(exifData_);
img->setIptcData(iptcData_);
img->setXmpData(xmpData_);
img->writeMetadata();
int imgSize = img->io().size();
DataBuf imgBuf = img->io().read(imgSize);
#ifdef DEBUG
std::cout << "Exiv2::PgfImage::doWriteMetadata: Creating image to host metadata (" << imgSize << " bytes)\n";
#endif
//---------------------------------------------------------------
// Write PGF Signature.
if (outIo.write(pgfSignature, 3) != 3) throw Error(21);
// Write Magic number.
if (outIo.putb(mnb) == EOF) throw Error(21);
// Write new Header size.
uint32_t newHeaderSize = header.size_ + imgSize;
DataBuf buffer(4);
memcpy (buffer.pData_, &newHeaderSize, 4);
byteSwap_(buffer,0,bSwap_);
if (outIo.write(buffer.pData_, 4) != 4) throw Error(21);
#ifdef DEBUG
std::cout << "Exiv2::PgfImage: new PGF header size : " << newHeaderSize << " bytes\n";
printf("%x\n", buffer.pData_[0]);
printf("%x\n", buffer.pData_[1]);
printf("%x\n", buffer.pData_[2]);
printf("%x\n", buffer.pData_[3]);
#endif
// Write Header data.
if (outIo.write(header.pData_, header.size_) != header.size_) throw Error(21);
// Write new metadata byte array.
if (outIo.write(imgBuf.pData_, imgBuf.size_) != imgBuf.size_) throw Error(21);
// Copy the rest of PGF image data.
DataBuf buf(4096);
long readSize = 0;
while ((readSize=io_->read(buf.pData_, buf.size_)))
{
if (outIo.write(buf.pData_, readSize) != readSize) throw Error(21);
}
if (outIo.error()) throw Error(21);
} // PgfImage::doWriteMetadata