Filip Hazubski
Filip Hazubski

Reputation: 1728

How to repaint QQuickItem quickly?

I have a stream of images, in YUY2 format. I would like to paint these images on QQuickItem - so I can use it with Qt Quick 2.

I have an issue with the performance so my question is what is the quickest way to redraw QML object written in C++? Is there some kind object dedicated to rendering videos?


What I have tried is creating a class that inherits QQuickPaintedItem. I have converted YUY2 images to RGBA8888 format, then loaded it using QImage and then painted it using QPainter. It proved not efficient if QQuickPaintedItem was big - for example bigger than 1000x1000. Much quicker method was to convert QImage to QPixmap and then paint using QPainter. It works somewhat good now but maybe there is quicker way? For example conversion of images seems too slow the process down.

Upvotes: 1

Views: 2220

Answers (1)

Filip Hazubski
Filip Hazubski

Reputation: 1728

I have got this to work by using QQuickItem with defined updatePaintNode function (the first idea from Kuba Ober's comment).

This example helped me a lot. In it NoisyNode class renders background (static image) and Graph is using it. I have taken those two class to my project and adapted them to my needs. I had no problem displaying 1080x1920 pixels, 30fps. As I understand to display a video you eventually need to convert YUV to RGB so I did this right away and worked with an array of RGBA pixels.

Upvotes: 1

Related Questions