4


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,

2 Answers 2

5

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?

0

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

1
  • Not exactly. My code gives me result which I expect. The problem is that I need this result faster than I get it now. For 4 items: QImage(640, 480, QImage::Format_ARGB32) its around 80 miliseconds (lot). I thought, that there exists some better method for do it. Do you have some ideas how make it faster?
    – mkk
    Commented Mar 26, 2012 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.