本文整理汇总了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;
}
示例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;
}
示例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();
}
}
}