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. Show Images with Pixmap: Memory

Show Images with Pixmap: Memory

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 606 Views
  • 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.
  • T Offline
    T Offline
    TauCeti
    wrote on last edited by
    #1

    Hello,
    I want to display a large number of images with large size (each >100 MB).
    They should be displayed as a small preview picture with low resolution.
    Is it possible to avoid that they are all loaded into memory?

    What could be the proper way of doing it?

    Thanks for help.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @TauCeti said in Show Images with Pixmap: Memory:

      What could be the proper way of doing it?

      Load them, create thumbnails and only store them in memory.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • T Offline
        T Offline
        TauCeti
        wrote on last edited by
        #3

        Still not sure how to solve this.

        QIcon thumbnail = QIcon(Pixmap::fromImage(image));
        
        QLabel *img = new QLabel(tab);
        img->setPixmap(QPixmap("..."));
        img->scaledToWidth( .. );
        

        How do I create thumbnails? Just load them to a QIcon or QLabel with
        different size?

        J.HilkJ 1 Reply Last reply
        0
        • T TauCeti

          Still not sure how to solve this.

          QIcon thumbnail = QIcon(Pixmap::fromImage(image));
          
          QLabel *img = new QLabel(tab);
          img->setPixmap(QPixmap("..."));
          img->scaledToWidth( .. );
          

          How do I create thumbnails? Just load them to a QIcon or QLabel with
          different size?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @TauCeti
          for example this creates a QVector filled with scaled (100 x 100) QPixmaps of a given folder

          int main(int argc, char *argv[])
          {
              QApplication a(argc, argv);
          
              QVector<QPixmap> myThumbNails;
              
              
              QDir dir(pathToImages);
              const QStringList entries = dir.entryList(QDir::Files);
              const QString path = pathToImages + QString("/%1");
              for(const QString &image : entries){
                  QPixmap imgOrginal(path.arg(image) );
                  if(!imgOrginal.isNull())
                      myThumbNails.append(imgOrginal.scaled(100,100,Qt::KeepAspectRatio));
              }
          
              return a.exec();
          }
          

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          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