<div dir="ltr">Patrick,<div><br></div><div>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</div>

<div><a href="http://diwakergupta.github.io/thrift-missing-guide/#_c">http://diwakergupta.github.io/thrift-missing-guide/#_c</a><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">

2014-04-28 15:00 GMT+02:00 patrick machielse <span dir="ltr"><<a href="mailto:patrick@hieper.nl" target="_blank">patrick@hieper.nl</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Audric,<br>
<br>
Although this solution may work (I don't know why exactly…) it doesn't seem like a good design.<br>
<br>
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).<br>
<br>
It would seem better to use a generic data container for your musicData.artwork property, perhaps std::vector?<br>
<br>
p.<br>
<br>
<br>
Op 28 apr. 2014, om 14:15 heeft Audric Ackermann <<a href="mailto:audric.bilb@gmail.com">audric.bilb@gmail.com</a>> het volgende geschreven:<br>
<br>
> It worked, thank you !<br>
><br>
><br>
> 2014-04-28 12:06 GMT+02:00 Lukáš Lalinský <<a href="mailto:lalinsky@gmail.com">lalinsky@gmail.com</a>>:<br>
> std::string artwork_s(Pic->picture().data());<br>
><br>
> 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);<br>


><br>
> Lukas<br>
><br>
><br>
> On Mon, Apr 28, 2014 at 10:47 AM, Audric Ackermann <<a href="mailto:audric.bilb@gmail.com">audric.bilb@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> 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:<br>
><br>
> Music* gettags(QString mediafile){<br>
>    Music * music = new Music();<br>
>    TagLib::FileRef file(mediafile.toUtf8());<br>
><br>
>     //get covert art<br>
>     TagLib::ID3v2::Tag Tag(file.file(),0);<br>
>     TagLib::ID3v2::FrameList list = Tag.frameListMap()["APIC"];<br>
><br>
>     if(!list.isEmpty()) {<br>
>         TagLib::ID3v2::AttachedPictureFrame *Pic = static_cast<TagLib::ID3v2::AttachedPictureFrame *>(list.front());<br>
><br>
>         if(Pic != NULL) {<br>
>             std::string artwork_s(Pic->picture().data());<br>
>             qDebug() << "size: " << Pic->picture().size();<br>
><br>
>             music->musicData.artwork = artwork_s;<br>
><br>
>         }<br>
>     }<br>
>     return music;<br>
> }<br>
<br>
</blockquote></div><br></div>