@@ -385,6 +385,59 @@ AlbumArtList MetaIOID3::readAlbumArt(TagLib::ID3v2::Tag *tag)
385
385
return artlist;
386
386
}
387
387
388
+ /* !
389
+ * \brief Find an APIC tag by type and optionally description
390
+ *
391
+ * \param tag Pointer to TagLib::ID3v2::Tag object
392
+ * \param type Type of picture to search for
393
+ * \param description Description of picture to search for (optional)
394
+ * \returns Pointer to frame
395
+ */
396
+ AttachedPictureFrame* MetaIOID3::findAPIC (TagLib::ID3v2::Tag *tag,
397
+ const AttachedPictureFrame::Type &type,
398
+ const String &description)
399
+ {
400
+ TagLib::ID3v2::FrameList l = tag->frameList (" APIC" );
401
+ for (TagLib::ID3v2::FrameList::Iterator it = l.begin (); it != l.end (); ++it)
402
+ {
403
+ AttachedPictureFrame *f = static_cast <AttachedPictureFrame *>(*it);
404
+ if (f && f->type () == type &&
405
+ (description.isNull () || f->description () == description))
406
+ return f;
407
+ }
408
+ return NULL ;
409
+ }
410
+
411
+ /* !
412
+ * \brief Write the albumart image to the file
413
+ *
414
+ * \param tag The ID3v2 tag object in which to look for Album Art
415
+ * \returns True if successful
416
+ */
417
+ bool MetaIOID3::writeAlbumArt (TagLib::ID3v2::Tag *tag, QByteArray *image,
418
+ const AttachedPictureFrame::Type &type)
419
+ {
420
+ if (!tag || !image)
421
+ return false ;
422
+
423
+ AttachedPictureFrame *apic = findAPIC (tag, type);
424
+
425
+ if (!apic)
426
+ {
427
+ apic = new AttachedPictureFrame ();
428
+ tag->addFrame (apic);
429
+ apic->setType (type);
430
+ }
431
+
432
+ TagLib::ByteVector bytevector;
433
+ bytevector.setData (image->data ());
434
+ delete image;
435
+
436
+ apic->setPicture (bytevector);
437
+
438
+ return true ;
439
+ }
440
+
388
441
/* !
389
442
* \brief Find the a custom comment tag by description.
390
443
* This is a copy of the same function in the
@@ -411,9 +464,6 @@ UserTextIdentificationFrame* MetaIOID3::find(TagLib::ID3v2::Tag *tag,
411
464
412
465
/* !
413
466
* \brief Find the POPM tag associated with MythTV
414
- * This is a copy of the same function in the
415
- * TagLib::ID3v2::UserTextIdentificationFrame Class with a static
416
- * instead of dynamic cast.
417
467
*
418
468
* \param tag Pointer to TagLib::ID3v2::Tag object
419
469
* \param email Email address associated with this POPM frame
0 commit comments