I am beginning with Qt
I need to convert a Base64 string of a Jpeg image into a Qimage and display it in a QLabel
Can someone please direct me as to how to go about doing this?
I am beginning with Qt
I need to convert a Base64 string of a Jpeg image into a Qimage and display it in a QLabel
Can someone please direct me as to how to go about doing this?
Well there is QByteArray and QImage. QImage has loadFromData method which can be used with base64 encoded data.
QByteArray imageData = QByteArray::fromBase64("YourBase64EncodedString");
QImage img;
if (img.loadFromData(imageData)) {
// show this label somewhere.
QLabel label;
label->setPixmap(QPixmap::fromImage(img));
}
Here you can find more information on how to read and write images
A more complete example can be found in my github repository. I wrote this app some years ago to restore base64 encoded images from e-mails that were accidentally deleted.
You can do it with QByteArray and QImage::loadFromData(const QByteArray & data)
QByteArray barray = QByteArray::fromBase64("base64 string");
QImage image;
image.loadFromData(barray);