QImage to QPixmap is too slow
-
Hi,
I want to show images continuously in Qt. However, QImage to QPixmap is so slow that I
can't get frame rates I need. So is there any way to show images more effectively in Qt?
Thank you. -
@betterorbest
Hello,
There are options depending on your setup, however you should provide a little more information on what you're trying to do. For example is this is a multithreaded application, do you block the event loop for other things etc. A code sample could also be useful, and will probably attract better answers.Kind regards.
-
@kshegunov
Hi
I want to show my image streams in Qt's ui. Now I have to first convert my image from the hardware data streams to a qImage, then convert the qImage to QPixmap and finally use QLabel::setPixmap(qPixmap) to show it in a QLabel. I just mean that QPixmap::fromImage(qImage) is too slow and takes around 30ms for qimage with 1280 * 960 resolution. So I want to find a faster way to show my image streams.
Thank you for your help. -
@betterorbest
That's a big image. Have you tried drawing the image directly, instead of converting it to a pixmap first? If that doesn't work have you tried drawing the image on a GL surface?b) 1 thread converts qimage to qpixmap
That ain't happening.
QPixmap
is not reentrant. -
@betterorbest said:
Now I have to first convert my image from the hardware data streams
The fastest way possible is to move the raw pixel data directly into an OpenGL Pixel Buffer Object and do all the transformations / rendering in the GPU.
-
@kshegunov
Thank you for your answer. I thought there may be some faster way without using opengl. But if this is the fact, I will finally try the opengGl. In other hand, drawing the image directly seems to be as slow as QPixmap::from(qImage). -
@yoavmil
I tried your advice once. But the conversion from qImage to qPixmap is stiil the bottle neck. Thank you for your advice.@Moderators
Thank you. I will try the openGl advice. -
@betterorbest said:
Thank you for your answer. I thought there may be some faster way without using opengl.
Nope. OpenGL has facilities for such things, while the ordinary
QPainter
based approach doesn't. So I'd go with what @Wieland suggested. -
Hi,
Out of curiosity, what is the format of your images ?
-
Are you only showing that image ?