Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QImage too slow to load ...

QImage too slow to load ...

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 3.9k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MSDQuick
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Have you tried the 3 MB file from a
      normal file and not from a resource ?
      Just to see time difference.

      1 Reply Last reply
      1
      • miclandM Offline
        miclandM Offline
        micland
        wrote on last edited by
        #3

        I guess the time is not taken for loading the image but for scaling the image. If the image is loaded from resource (means: static and will not change after compilation) you should scale the image once and include the scaled version into your binary...

        1 Reply Last reply
        1
        • T Offline
          T Offline
          thEClaw
          wrote on last edited by thEClaw
          #4

          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.

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved