I am newbie in Qt & image storage & manipulation. Please bear with me if my question is silly.
Problem:
I am required to store some QImage
s on the RAM while my Qt application is running. My app runs only on android. Say that I am required to store 100 QImage
s of size 1000*1000
. But the RAM might not support such a huge memory requirement since there is a heap memory limit for apps on Android.
Attempted solution:
Now that I have to store 100 QImage
s which a huge requirement given the size, I am trying to do something like this to reduce the main memory footprint of these QImage
s.
SetQImageToList(QImage & img) {
QByteArray theByteArray;
QBuffer buffer(& theByteArray);
buffer.open(QIODevice::WriteOnly);
img.save(&buffer, "JPG");
}
I can get the same QImage back doing following as I learn:
QImage::fromData(theByteArray, "JPG")
I can store & read back the QImage
s. Code works fine for storing & retrieval of the QImage
s.
Question:
Does this technique guarantee that theByteArray
stored is a lower footprint than the actual QImage
?
What are the downsides of doing this? Will I incur a performance loss while I read & write into theByteArray
then QImage
& vice versa?