PDA

View Full Version : ImageViewer: Pixmap or OpenGL - performance when creating pixmap



olrom
30th January 2020, 16:16
Hello,

I started to code my own image viewer in PyQt5 since no other image viewer I know of does work like I want it to. From the beginnings of using a Lable to now using QGraphicsView with QImage/QPixmap I wonder if it might make sense to go to openGL to display images.

The reason I ask is, that I measure how long it takes for Qt to create a pixmap out of an image, and it seems that this really is an enourmous bottleneck as it will take like 600 ms for some 6000x8000 px image thus slowing the program down a lot compared to for example IrfanView.
The time it takes is not because of HDD speed, as it's roughly the same when feeding it directly from a QBuffer (I read images from archives to a QBuffer and then feed it to QImage).

So before I dive into openGL I'd like to know if openGL would speed up getting an image shown compared to QPixmaps?

Thank you

d_stranz
30th January 2020, 16:57
I measure how long it takes for Qt to create a pixmap out of an image

This is the crucial piece of missing information: How exactly -are- you creating the image? Setting it pixel-by-pixel? If so, of course that will be slow. It will be no faster in OpenGL if you use the same approach.

olrom
30th January 2020, 18:11
This is the crucial piece of missing information: How exactly -are- you creating the image? Setting it pixel-by-pixel? If so, of course that will be slow. It will be no faster in OpenGL if you use the same approach.

QPixmap(filepath) or QPixmap.fromImageReader() if I use a buffer.

I found some code pieces that use "QImage tex = QGLWidget::convertToGLFormat(image);" which definitely would not help as creating a QImage is as slow as creating the QPixmap.