当前位置: 首页>>代码示例>>C++>>正文


C++ ByteVector::setData方法代码示例

本文整理汇总了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;
}
开发者ID:pekingduck,项目名称:metadsf,代码行数:24,代码来源:utils.cpp

示例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;
}
开发者ID:tomhughes,项目名称:mythtv,代码行数:77,代码来源:metaioid3.cpp


注:本文中的taglib::ByteVector::setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。