QImage real bytes count
-
wrote on 23 Sept 2013, 06:51 last edited by
Hello,
how to retrieve the amount of bytes for an object of type QImage so if it would be saved onto disk the file size will have the same amount of bytes?
-
how should this be possible since it depends in which format you save the file on the disk?
-
wrote on 23 Sept 2013, 06:56 last edited by
PNG
-
it's still not possible directly from QImage ;)
You would first save it to this format and check it's resulting data size. This may block your application depending on the size of the image. If so you may want to do this in another thread.
@
QImage image;
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
image.save(&buffer, "PNG");
buffer.close();int fileSize = ba.size();
@ -
wrote on 23 Sept 2013, 07:16 last edited by
It is still a synchronous job.
[quote author="raven-worx" date="1379919631"]it's still not possible directly from QImage ;)You would first save it to this format and check it's resulting data size. This may block your application depending on the size of the image. If so you may want to do this in another thread.
@
QImage image;
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
image.save(&buffer, "PNG");
buffer.close();int fileSize = ba.size();
@[/quote] -
[quote author="silex92" date="1379920609"]It is still a synchronous job.
[/quote]
Yes as i said!
If you do want it to do asynchronously use another thread using signals and slots with a queued connection.
1/6