covert art data and size issue
Audric Ackermann
audric.bilb at gmail.com
Mon Apr 28 13:07:49 UTC 2014
Patrick,
Yes I think so, but the fact is I use thrift to send this information, and
I used a binary to represents the image, which is converted to std::string
by thrift, as said here
http://diwakergupta.github.io/thrift-missing-guide/#_c
2014-04-28 15:00 GMT+02:00 patrick machielse <patrick at hieper.nl>:
> Audric,
>
> Although this solution may work (I don't know why exactly…) it doesn't
> seem like a good design.
>
> The ByteVector you get from Pic->picture().data() is not string data, but
> jpeg data. Storing it in a String object is a bit misleading to say the
> least (even if it might work).
>
> It would seem better to use a generic data container for your
> musicData.artwork property, perhaps std::vector?
>
> p.
>
>
> Op 28 apr. 2014, om 14:15 heeft Audric Ackermann <audric.bilb at gmail.com>
> het volgende geschreven:
>
> > It worked, thank you !
> >
> >
> > 2014-04-28 12:06 GMT+02:00 Lukáš Lalinský <lalinsky at gmail.com>:
> > std::string artwork_s(Pic->picture().data());
> >
> > This code uses the NULL byte to determine the size, which JPEG is very
> likely to have somewhere in the middle. You need to explicitly set it. Use
> this string constructor instead: string (const char* s, size_t n);
> >
> > Lukas
> >
> >
> > On Mon, Apr 28, 2014 at 10:47 AM, Audric Ackermann <
> audric.bilb at gmail.com> wrote:
> > Hi,
> >
> > I need to get metadata from audio files and found taglib. It works fine
> with artist, album, title,... but I have some problems with covert art.
> Here is my code to extract it:
> >
> > Music* gettags(QString mediafile){
> > Music * music = new Music();
> > TagLib::FileRef file(mediafile.toUtf8());
> >
> > //get covert art
> > TagLib::ID3v2::Tag Tag(file.file(),0);
> > TagLib::ID3v2::FrameList list = Tag.frameListMap()["APIC"];
> >
> > if(!list.isEmpty()) {
> > TagLib::ID3v2::AttachedPictureFrame *Pic =
> static_cast<TagLib::ID3v2::AttachedPictureFrame *>(list.front());
> >
> > if(Pic != NULL) {
> > std::string artwork_s(Pic->picture().data());
> > qDebug() << "size: " << Pic->picture().size();
> >
> > music->musicData.artwork = artwork_s;
> >
> > }
> > }
> > return music;
> > }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20140428/06798522/attachment.html>
More information about the taglib-devel
mailing list