In qml, i am using xml file to get some information from server. In this xml file there is a field as < image>iVBORw0KGgoAAAANSUhEUgAAA2AAAALKCAYAAABUYjK........< /image>. I am using XmlListModel and ListView for other field but how can i convert this code to png image.
Asked
Active
Viewed 6,036 times
2 Answers
17
I didn't try myself, but if QML supports the data URI scheme (http://en.wikipedia.org/wiki/Data_URI_scheme), try
Image {
source: "data:image/png;base64," + model.imageData
}

blakharaz
- 2,580
- 13
- 18
-
I tried, it works. This might be the best and shortest solution! – hiddenbit Jul 19 '11 at 20:03
0
I would implement a custom QDeclarativeImageProvider
, which creates an image from the encoded data.
Then you can do something like this in your delegate:
// ...
Image {
source: "image://encodedimage/" + model.imageData
}
// ...
Have a look at this example, it might be a starting point for your implementation.
If the image is base64 encoded, then you can create an image like that (not tested):
QByteArray ba = QByteArray::fromBase64(imageDataString.toAscii());
QImage image = QImage::fromData(ba, "PNG");

hiddenbit
- 2,233
- 14
- 25