PDA

View Full Version : QImage bytesize



panicq
26th January 2021, 11:40
Hi,

I'm just wondering why QImage are consuming that much memory.

I'm loading an image that is 1.2 Mb (I checked that using QFileInfo) and when querying the size using sizeInBytes on the QImage I get something like 24 Mb. Any idea ?
What class can I use in order to load the image with the lowest size in memory (uncompressed), and to display it of course (I need to put it in a PixMap at the end in order to add it to a GraphicsScene) ?
Do you think I'm misinterpreting the value from QFileInfo ?

I can clearly see in the task manager, that my program consumes more memory than I think it should be.



QFileInfo info(imagePath);
qDebug() << "INFO:" << info.size() << " IMG BYTES: " << new QImage(imagePath)->sizeInBytes(); //INFO: 1277952 IMG BYTES: 24064000



Thanks in advance !

Ginsengelf
26th January 2021, 14:47
Hi, just a guess: maybe your original file is compressed (jpg or something like that), while QImage stores a raw representation of the pixels? What size does your image have (width x height)?

Ginsengelf

panicq
29th January 2021, 13:21
You're probably right, so QFileInfo::size() gave me the compressed byte size.