[Interest] problem saving QPixMap : base64 conversion
sarvesh saran
aquarian.thunder at gmail.com
Fri Nov 4 03:01:20 CET 2011
Hi All,
I get some base64 data from a server , it is also Url encoded (not sure
about this). I want to convert it to a QPixMap and save the image to the
disk:
//input is QString content. I have no iformation about the content
except that it is base64 encoded and its a PNG
QByteArray orig = content.toAscii(); //convert to byte array
QString decoded = QUrl::fromPercentEncoding(orig); //Do URL
decoding..if we skip this then map->loadFromData() fails below.
QByteArray arr = QByteArray::fromBase64(decoded.toAscii()); //
convert it back to a byteArray and decode..?
QPixmap *map = new QPixmap;
bool res = map->loadFromData(arr,type.toAscii()); //it succeeds,
here type.toAscii returns "PNG"
if(res){
bool sv =
map->save(QDir::currentPath().append("/bannerImage.png"),type.toAscii());
//FAILS!!
} else{
qDebug()<<"Error creating pixmap";
}
The conversion map->loadFromData() succeeds (returns true) but
map->save always returns false!
Any pointers would help!
thanks,
Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20111104/4c930c6b/attachment.html>
More information about the Interest
mailing list