Results 1 to 2 of 2

Thread: Loading Images from Directory Faster

  1. #1
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Loading Images from Directory Faster

    Hey guys!

    I've looked through nearly all image related posts and not found an answer yet.

    I'm trying to write an application, and in it, I want to load images from a selected directory and make them into objects that I will later display on screen in different layouts. The layout will range from displaying at least 1 and possibly up to, let's say, 10 images at once -- allowing the user to scroll through and see all the images loaded.

    So far, I've tried making the loaded images into QPixmap objects, QImage objects, and QGraphicsPixmapItem objects. However, my problem lies in the fact that the loading is too slow! The test folder I'm using contains 110 images (52 mb of formats .bmp, .gif, .jpg/.jpeg, .png) and it takes 17 seconds to load them all into QPixmap objects, and 12 seconds to load them into QImage objects. That is just not practical for the purpose of my application since I want to be able to load ~1000 images in a few seconds. I've tried loading a folder with 1100 images and it took a bit over 2 minutes.

    My question is, is Qt unable to load 1000 images any faster? Do I need to use any other objects, other libs? It's not impossible obviously. 'FastStone Image Viewer' is able to load my entire 1100 image folder in ~5 seconds, granted they are in thumbnail view to begin with, but that's exactly what I'm looking for.

    Someone mentioned using QImageReader and load them scaled down, would that be faster?

    Any info would help: explanations, sample code or links, I don't mind reading - not looking to be spoon-fed, just haven't found anything.

    Thanks in advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Loading Images from Directory Faster

    Quote Originally Posted by jalm View Post
    That is just not practical for the purpose of my application since I want to be able to load ~1000 images in a few seconds.
    Forget it, just look how long it takes Windows to generate thumbnails for your images.

    My question is, is Qt unable to load 1000 images any faster?
    It's the problem of your code, not Qt.

    Do I need to use any other objects, other libs? It's not impossible obviously. 'FastStone Image Viewer' is able to load my entire 1100 image folder in ~5 seconds, granted they are in thumbnail view to begin with, but that's exactly what I'm looking for.
    I guess your code is loading full size images and then scales them down, right? So you can immediately see a difference between your code and theirs.

    Someone mentioned using QImageReader and load them scaled down, would that be faster?
    It depends on the file format but likely yes.

    Any info would help: explanations, sample code or links, I don't mind reading - not looking to be spoon-fed, just haven't found anything.
    Two things:
    1. QtConcurrent::mapped() (taking the path and returning the image)
    2. load the images prescaled
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    jalm (24th August 2011)

Similar Threads

  1. Loading images from url in qt 4
    By shalini in forum Newbie
    Replies: 4
    Last Post: 15th September 2011, 16:21
  2. Slow loading images
    By abbapatris in forum Qt Programming
    Replies: 10
    Last Post: 5th March 2008, 15:52
  3. Loading images in html in a QTextBrowser
    By BasicPoke in forum Newbie
    Replies: 1
    Last Post: 6th June 2007, 21:51
  4. Stop the thread during recursivly loading directory
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th May 2007, 19:02
  5. Loading images in QTextBrowser
    By nisha0609 in forum Qt Programming
    Replies: 1
    Last Post: 3rd January 2007, 09:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.