picture result
Scott Wheeler
wheeler at kde.org
Fri Jul 30 20:42:21 CEST 2004
On Friday 30 July 2004 19:58, Cyril Bosselut wrote:
> QString format = "JPEG";
> if(result->mimeType() == "image/png"){
> format= "PNG";
> }
> p->setMimeType(QStringToTString(result->mimeType()));
> p->setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover);
> QPixmap file( ncover ); // load pic in QPixmap
> QByteArray data;
> QBuffer buffer( data );
> buffer.open( IO_WriteOnly );
> file.save( &buffer, format ); // save QPixmap in a QByteArray
> p->setPicture(TagLib::ByteVector(data, data.size())); // load data in the
This is doing a lot more work than you have to. The following (untested)
should work just as well:
QFile file(ncover);
file.open(IO_ReadOnly);
QByteArray data = file.readAll();
p->setPicture(TagLib::ByteVector(data.data(), data.size()));
-Scott
More information about the taglib-devel
mailing list