QPixmap vs. QImage

Sebastian Kügler sebas at kde.org
Wed Nov 11 17:00:21 CET 2009


Hey fellow plasmoids,

I've been wondering for a while now what I should use for rendering pixmap-based 
imaged onto Plasma running on X, QPixmap or QImage. The usecase I'm coming across 
regularly is that I paint an icon, and something on top of that. Possibly animated so 
we sometimes are rendering a few frames per second.

To give a usecase, last summer, I've moved the picture frame applet from using QImage 
all over to QPixmaps. Resizing (which involved often resizing the image shown from 
original size down to displayed size) seems to be smoother and less CPU-heavy with 
these changes. One observation I made was that t
The resizing is done by drawing a larger QPixmap into a smaller rect, as advised on 
techbase ( http://techbase.kde.org/Development/Tutorials/Graphics/Performance ).

So ...

(1) what's faster?
(2) what saves my battery? (probably related to (1))
(3) what's most memory-efficient?
(4) ... what should I use?

My assumptions (I take it, they're likely over-generalized and possibly wrong, that's 
why I'm writing them down -- corrected wrong assumptions are better than just wrong 
assumptions).

- QPixmap is managed in video memory, what you're dealing with is more or less a 
reference to an X pixmap. Painting on a QPixmap means, if done well, that it's done 
on the graphicscard. This seems more power-efficient, and faster since we can use 
acceleration of the GPU.

- Painting QImages with the raster graphicssystem seems a lot faster because the 
raster engine is more optimized and doesn't depend heavily on good quality drivers. 
Many people report smoother rendering when using the raster graphicssystem, compared 
with the default, "image" graphicssystem. It does, however, everything on the CPU, 
which is less ideal for such tasks.

I guess a whole lot of the answer depends on driver quality, so there's probably not 
one clear, right answer. Or maybe the real question seems to be: are we writing code 
for the ideal system, with well working drivers, or are we writing code that will run 
well on what we have now?

Zack, I hope you still haven't torn out all your hair after reading my email. :)

Thanks for your input,
-- 
sebas

http://www.kde.org | http://vizZzion.org | GPG Key ID: 9119 0EF9


More information about the Plasma-devel mailing list