Thursday, October 04, 2007

QImage::Format_ARGB32_Premultiplied is your friend

If you have looked at QImage in Qt4 you'll have noticed that there is the typical QImage::Format_RGB32 and QImage::Format_ARGB32 plus QImage::Format_ARGB32_Premultiplied.

Maybe you have wondered why is there, well, i'll tell you, it's FAST.

I have done a simple test rendering 100 times gear-flowers.svg wallpaper in a qimage of 1024x768. The results follow

RGB32: 20351 msec
ARGB32: 39273 msec
ARGB32_Premultiplied: 20248 msec

So if you look at the numbers, you'll see ARGB32_Premultiplied is actually faster than RGB32 that is not even producing correct results.

So QImage::Format_ARGB32_Premultiplied should be probably renamed to QImage::Format_ARGB32_UseMeBecauseImFast :D

2 comments:

Anonymous said...

Sounds really interesting. I'm also wondering if there are tone artifacts due to composition with the Premultiplied format.. Can you also make a difference between the 2 pictures? (maybe the eye won't notice, but there might be some small artifacts)
Thanks for the info!!

Anonymous said...

Yes, but for just painting on an image they are so subtle that basically people won't notice.

For a discussion on a KDE mailing list about this topic have a look at

http://lists.kde.org/?l=kde-core-devel&m=111625613119531&w=2

with the last URL basically pointing to the relevant summary.

Tackat