What is the fastest way to display an image in QT

2019-03-20 01:51发布

I need to display a raw image in a QT widget. I'm running X11 on a framebuffer, so OpenGL is not available.

Both the image and the framebuffer are in the same format - RGB565, but I can change it to any other format if needed. I don't need blending or scaling. I just need to display pixels as is.

I'm using QPainter::drawImage, but it converts QImage to QPixmap and this conversion seems to be very slow. Also it is backed by Xrender and I think there is unnecessary overhead required to support blending in Xrender which I don't really need

Is there any better way? If it is not available in QT, I can use Xlib or any other library or protocol. I can modify the driver, X server or anything else.

标签: linux qt qt4 x11 xlib
2条回答
地球回转人心会变
2楼-- · 2019-03-20 02:22

It may be worth setting the QT_GRAPHICSSYSTEM environment variable. I was having issues with the X11 renderer becoming very, very slow. On setting QT_GRAPHICSSYSTEM = 'raster', the QT rendering bypasses the X11 rendering engine, which can (as in my experience) be significantly more efficient. Other valid values for QT_GRAPHICSSYSTEM are 'native' and 'opengl', but 'raster' worked for me. I'll be interested to see how you got on.

查看更多
淡お忘
3楼-- · 2019-03-20 02:30

did you try to use XPutImage? (or XShmPutImage if you going to transfer image more then once from client and have MIT-SHM extension available) Also look at video4linux webcam sample viewer.c, but they convert 565 to 16 or 24 bit depth before sending. For your setup it should be possible to send image without conversion

查看更多
登录 后发表回答