Unsolved Show Images with Pixmap: Memory
-
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.
-
@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.
-
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? -
@TauCeti
for example this creates a QVector filled with scaled (100 x 100) QPixmaps of a given folderint 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(); }