Image from char data



I’ve been playing around with the TagLib library trying to extract album artwork from a file. I’m trying to build a music file browser.

I’ve managed to extract the char data from the file, and if I save it to a .txt (and then rename it .JPG) I am able to get the artwork I’m after.

My question is: how can I use this to display the artwork image within JUCE?

Here’s some code if its useful to anyone else:

// Adapted from:

using namespace TagLib::ID3v2;

TagLib::MPEG::File mp3File(file.getFullPathName().toRawUTF8());
Tag * mp3Tag;
FrameList listOfMp3Frames;
AttachedPictureFrame * pictureFrame;

mp3Tag = mp3File.ID3v2Tag();

    listOfMp3Frames = mp3Tag->frameListMap()["APIC"];
        FrameList::ConstIterator it= listOfMp3Frames.begin();
        for(; it != listOfMp3Frames.end() ; it++)
            pictureFrame = static_cast<AttachedPictureFrame *> (*it);
            File artwork;
            artwork.replaceWithData(pictureFrame->picture().data(), pictureFrame->picture().size());
        printf("No Artwork in File\n");


You can read the data into an juce Image via ImageCache and draw in the paint routine using the given Graphics context:

Image myImage = ImageCache::getFromMemory (pictureFrame->picture().data(), 
g.drawImageAt (myImage, 0, 0);