本文整理汇总了C++中taglib::ByteVector::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ ByteVector::setData方法的具体用法?C++ ByteVector::setData怎么用?C++ ByteVector::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taglib::ByteVector
的用法示例。
在下文中一共展示了ByteVector::setData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFileIntoVector
size_t loadFileIntoVector(const char *path, TagLib::ByteVector &v)
{
std::ifstream is(path, std::ifstream::binary);
if (!is.good()) {
return 0;
}
// get the file size and create an appropriate buffer
is.seekg(0, is.end);
size_t len = is.tellg();
is.seekg(0, is.beg);
char *buf = new char[len];
// read into buffer
is.read(buf, len);
v.setData(buf, len);
is.close();
delete[] buf;
return len;
}
示例2: image
/*!
* \brief Write the albumart image to the file
*
* \param filename The music file to add the albumart
* \param albumart The Album Art image to write
* \returns True if successful
*
* \note We always save the image in JPEG format
*/
bool MetaIOID3::writeAlbumArt(const QString &filename,
const AlbumArtImage *albumart)
{
if (filename.isEmpty() || !albumart)
return false;
// load the image into a QByteArray
QImage image(albumart->m_filename);
QByteArray imageData;
QBuffer buffer(&imageData);
buffer.open(QIODevice::WriteOnly);
image.save(&buffer, "JPEG");
AttachedPictureFrame::Type type = AttachedPictureFrame::Other;
switch (albumart->m_imageType)
{
case IT_FRONTCOVER:
type = AttachedPictureFrame::FrontCover;
break;
case IT_BACKCOVER:
type = AttachedPictureFrame::BackCover;
break;
case IT_CD:
type = AttachedPictureFrame::Media;
break;
case IT_INLAY:
type = AttachedPictureFrame::LeafletPage;
break;
case IT_ARTIST:
type = AttachedPictureFrame::Artist;
break;
default:
type = AttachedPictureFrame::Other;
break;
}
if (!OpenFile(filename, true))
return false;
TagLib::ID3v2::Tag *tag = GetID3v2Tag();
if (!tag)
return false;
AttachedPictureFrame *apic = findAPIC(tag, type,
QStringToTString(albumart->m_description));
if (!apic)
{
apic = new AttachedPictureFrame();
tag->addFrame(apic);
apic->setType(type);
}
QString mimetype = "image/jpeg";
TagLib::ByteVector bytevector;
bytevector.setData(imageData.data(), imageData.size());
apic->setMimeType(QStringToTString(mimetype));
apic->setPicture(bytevector);
apic->setDescription(QStringToTString(albumart->m_description));
if (!SaveFile())
return false;
return true;
}