QImage too slow to load ...
-
Hi guys ;
I would like to show a small thumbnail image in my app, when user selects an image file. Here is my code :QPixmap MyPixmap; MyPixmap = QPixmap (":/Images/Holder.png"); if (!MyPixmap.isNull()) { ui->imageLabel->setPixmap ( MyPixmap.scaled ( 98, 55, Qt::KeepAspectRatio));}
Everything works fine for small images (700 KByte size), but it take long time to show when I load an image with 3MegaByte file size...!
Is there a way to improve the performance ?Thanks.
MSD. -
Hi
Have you tried the 3 MB file from a
normal file and not from a resource ?
Just to see time difference. -
-
You could try out QImageReader which, for some formats, can speed up reading by reading in a scaled image.
On top of that you could read in the image in a separate thread (in case the loading is blocking some UI you might have).
And on top of that you could use a quicker method of scaling the image. Should you want to reuse the image, don't forget to cache the scaled image.
PS: Also, there is no need to guess: Make use of QElapsedTimer if you want to know how long certain actions take.