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


C++ AttachedPictureFrame::mimeType方法代码示例

本文整理汇总了C++中taglib::id3v2::AttachedPictureFrame::mimeType方法的典型用法代码示例。如果您正苦于以下问题:C++ AttachedPictureFrame::mimeType方法的具体用法?C++ AttachedPictureFrame::mimeType怎么用?C++ AttachedPictureFrame::mimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在taglib::id3v2::AttachedPictureFrame的用法示例。


在下文中一共展示了AttachedPictureFrame::mimeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exportImage

bool CTagBase::exportImage(const wchar_t* s)
{
	if (!s)	return false;
	if (_tagFile)
	{
		//get picture
		TagLib::MPEG::File *f = (TagLib::MPEG::File *)_tagFile.get();
		if (!f->hasID3v2Tag() || f->ID3v2Tag()->isEmpty())
			return false;
		/*
		TagLib::ID3v2::FrameList::ConstIterator it = f->ID3v2Tag()->frameList().begin();
		for (; it != f->ID3v2Tag()->frameList().end(); it++)
		{
			if ((*it)->frameID().operator == (TagLib::ByteVector("APIC")))
			{
				HANDLE hFile = CreateFile(s, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
				if (INVALID_HANDLE_VALUE == hFile)
					return false;
				int nWriteBytes = 0;
				size_t size = (*it)->size();
				::WriteFile(hFile, (*it)->render().data(), (*it)->size(), (LPDWORD)&nWriteBytes, NULL);
				::CloseHandle(hFile);
				if (nWriteBytes != size)
					return false;
				return true;
			}
		}*/
		if (f->ID3v2Tag()->frameListMap().size() == 0)
			return false;
		if (f->ID3v2Tag()->frameListMap().find("APIC") == f->ID3v2Tag()->frameListMap().end())
			return false;

		TagLib::ID3v2::FrameList Flist = f->ID3v2Tag()->frameListMap()["APIC"];
		if (Flist.isEmpty())
			return false;
		TagLib::ID3v2::AttachedPictureFrame *p = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(Flist.front());
		size_t size = p->picture().size();
		CString strPicType = p->mimeType().toCString(true);
		int nPos = strPicType.Find('/');
		CString strTemp = strPicType.Right(strPicType.GetLength() - nPos - 1);
		//CString strPicPath   = s;

		//if (strTemp == _T("png"))
		//	strPicPath.Append(_T(".png"));
		//else
		//	strPicPath.Append(_T(".jpg"));

		HANDLE hFile = CreateFile(s, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
		if (INVALID_HANDLE_VALUE == hFile)
			return false;
		int nWriteBytes = 0;
		::WriteFile(hFile, p->picture().data(), size, (LPDWORD)&nWriteBytes, NULL);
		::CloseHandle(hFile);
		if (nWriteBytes != size)
			return false;

		return true;
	}
	return false;
}
开发者ID:hjhong,项目名称:MyDuiLib,代码行数:60,代码来源:tagBase.cpp

示例2: exportPictures

bool MetaDSF::exportPictures(const char *prefix) const
{
  std::map<std::string, unsigned int> counter;
  TagLib::ID3v2::FrameList l = _i->_file.ID3v2Tag()->frameList("APIC");
  TagLib::ID3v2::FrameList::ConstIterator it;
  for (it = l.begin(); it != l.end(); ++it) {
    TagLib::ID3v2::AttachedPictureFrame *f =
      static_cast<TagLib::ID3v2::AttachedPictureFrame *>(*it);
    std::string fname = prefix;
    std::string tname = picTypeDesc[f->type()].toCString();
    std::string ext = MIMETypeToExtMap[f->mimeType()].toCString();
    if (counter.find(tname) == counter.end())
      counter[tname] = 1;
    else
      counter[tname] += 1;
    fname += "_";
    fname += tname;
    fname += "_";
    fname += std::to_string(counter[tname]);
    fname += ".";
    fname += ext;
    //std::cout << "fname = " << fname << std::endl;
    writeFileFromVector(fname.c_str(), f->picture());
  }
  return true;
}
开发者ID:pekingduck,项目名称:metadsf,代码行数:26,代码来源:metadsf.cpp

示例3: saveFile

void saveFile(string stdPath, DataEditors* editors) {

    const char* charPath = stdPath.c_str();
    ifstream fileCheck(charPath);
    if(!fileCheck.good()) {

        QWidget *w = new QWidget();
        QLabel *l = new QLabel("Invalid file!", w);
        QPushButton *b = new QPushButton("OK", w);
        QVBoxLayout *lay = new QVBoxLayout();
        lay->addWidget(l);
        lay->addWidget(b);
        w->setLayout(lay);
        QWidget::connect(b, SIGNAL(clicked()), w, SLOT(close()));
        w->show();
        return;
    }
    TagLib::FileName name = charPath;
    TagLib::FileRef file(name);
    if(editors->artist->isEnabled())
        file.tag()->setArtist(editors->artist->text().toStdString());
    if(editors->album->isEnabled())
        file.tag()->setAlbum(editors->album->text().toStdString());
    if(editors->track->isEnabled())
        file.tag()->setTrack(editors->track->text().toInt());
    if(editors->title->isEnabled())
        file.tag()->setTitle(editors->title->text().toStdString());
    if(editors->year->isEnabled())
        file.tag()->setYear(editors->year->text().toInt());
    if(editors->genre->isEnabled())
        file.tag()->setGenre(editors->genre->currentText().toStdString());
    if(editors->comment->isEnabled())
        file.tag()->setComment(editors->comment->toPlainText().toStdString());
    file.save();

    if(editors->picture->isEnabled()) {
        TagLib::MPEG::File mpegFile(name);
        TagLib::ID3v2::Tag *tag = mpegFile.ID3v2Tag(true);
        TagLib::ID3v2::AttachedPictureFrame *frame = new TagLib::ID3v2::AttachedPictureFrame;
        QString picture = editors->picture->text();
        if(picture == "<Attached picture>") {

            TagLib::ID3v2::AttachedPictureFrame *f =
                    static_cast<TagLib::ID3v2::AttachedPictureFrame *>(editors->mpegFile->ID3v2Tag(true)->frameList("APIC").front());
            frame->setMimeType(f->mimeType());
            frame->setPicture(f->picture());
            tag->removeFrames("APIC");
            tag->addFrame(frame);
            mpegFile.save();

        } else if(picture == "") {

            tag->removeFrames("APIC");
            mpegFile.save();

        } else {

            frame->setMimeType("image/jpeg");
            string stdPic = picture.toStdString();
            const char* charPicture = stdPic.c_str();
            ifstream fileCheck(charPicture);
            if(!fileCheck.good()) {

                QWidget *w = new QWidget();
                QLabel *l = new QLabel("Invalid picture!", w);
                QPushButton *b = new QPushButton("OK", w);
                QVBoxLayout *lay = new QVBoxLayout();
                lay->addWidget(l);
                lay->addWidget(b);
                w->setLayout(lay);
                QWidget::connect(b, SIGNAL(clicked()), w, SLOT(close()));
                w->show();
                delete w;
                return;
            }

            ImageFile imageTagLibFile(charPicture);
            frame->setPicture(imageTagLibFile.data());
            tag->removeFrames("APIC");
            tag->addFrame(frame);
            mpegFile.save();
            
        }

    }

}
开发者ID:UsernameMartin,项目名称:Metaudit,代码行数:87,代码来源:datasaver.cpp


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