Qt: quick merge and display images


I am looking for the fastest way:

  • merging (this means creating one image from several images, placing one on the other with respect to their alpha values)
  • display images

in Qt. This is my decision:

// --------------------------------------------- --- ------------------------------------

QImage image1 (width, height, QImage::Format_ARGB32); QImage image2 (width, height, QImage::Format_ARGB32); QImage image3 (width, height, QImage::Format_ARGB32); 

/ * some image operations * /

  QPainter displayPainter (this); displayPainter.drawImage (topLeft, image1, area); displayPainter.drawImage (topLeft, image2, area); displayPainter.drawImage (topLeft, image3, area); 

// --------------------------------------------- --- ------------------------------------

If something is better, faster? I found information that QPixmap is better to display on the screen, but this: displayPainter.drawPixmap (.) slower than this: displayPainter.drawImage (.) .

------------------------------------------ EDIT ---- --- -----------------------------------

I want to add that I saw this question: What is the most efficient way to display decoded video frames in Qt?

but in my case, using QGLWidget is a bit more complicated. I use requireitas and it is not stable with paintEvent in QGLWidget. There are no problems with paintGL. Respectfully,

+4
source share
2 answers

I found a solution to make my code more optimal. In my case, I am involved in alpha blending multiple images. I found in the documentation that:

"Some operations (such as composing images using alpha blending) use pre-multiplied ARGB32 faster than regular ARGB32.

Using:

 QImage image (width, height, QImage::Format_ARGB32_Premultiplied); 

instead:

 QImage image (width, height, QImage::Format_ARGB32); 

Improved alpha blending makes it 2 times faster! Do you have other ideas how to make it better?

+5
source

You might want to consider the “ Image Layout Example, ” which is available in the Qt examples. This seems to be what you're looking for?

0
source

Source: https://habr.com/ru/post/1403013/


All Articles