Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Media to byte array
I'd like to create an image and sound cache for an application. The image and sound files are retrieved remotely via url. (http://myDomain.com/someCoolImage.png) I want to save the images locally and retrieve them from there, rather than re-download them every session. There are a few suggestions out there about how to convert a byteArray to an image, but not much about converting an Image to any sort of savable format. Anyone know of a good way to do this? Extra appreciation if it can be done in pure qml.
not much about converting an Image to any sort of savable format
Well just save it to the image's format, like PNG or JPEG.
On the non QML side, QCache might be of interest.
@sierdzio But there is no Image.bitmap, Image.byteArray, Image.data, Image.content or similar. No access to the image's data in order to save it.
Oh, you're talking about QML's Image element? I thought you're downloading the files in C++.
OK, so here I have 2 hints:
- use the Image's URL to download the actual file using QNetworkAccessManager in C++ - then saving is easy
- use an image provider to download / store / retrieve the images in any way you want or need. It will take some time to code it in, but it's potentially a very robust solution
@sierdzio thank you.