mkk
mkk

Reputation: 675

Qt: the fastest merging and displaying of images


I'm looking for the fastest way of:

  1. merging (it means making one image from couple of images, putting one on other with respect to their alpha values)
  2. display images

in Qt. This is my solution:

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

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

/* some operations with images */

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

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

If there exists anything better, faster? I found information, that QPixmap is better for displaying it on a screen, but this: displayPainter.drawPixmap (.) is slower then this: displayPainter.drawImage (.).

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

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

but in my case using QGLWidget is little bit complicated. I'm using necessitas and this is not stable with paintEvent in QGLWidget. With paintGL has no problem. Regards,

Upvotes: 4

Views: 5449

Answers (2)

mkk
mkk

Reputation: 675

I found solution to make my code more optimal. In my case, I deal with alpha blending of multiple images. I found in documentation, that:

"Certain operations (such as image composition using alpha blending) are faster using premultiplied ARGB32 than with plain ARGB32."

Using:

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

instead of:

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

improved alpha blending making it 2 times faster! Do you have any other ideas how to make it better?

Upvotes: 5

azf
azf

Reputation: 2189

You may consider the "Image Composition Example" code available in Qt examples. It seems to be what you are looking for ?

Upvotes: 0

Related Questions