[Qt-interest] QImage drawing performance with QPainter

Samuel Rødal samuel.rodal at nokia.com
Thu Jan 14 12:53:52 CET 2010


ext trinathpujari wrote:
> Hi All,
> 
>           In our embedded application we are using qimage with painter 
> for painting onto the screen and we need to call the drawImage function 
> many times with painter
>           object which is associated with the qimage but this is 
> hampering our screen drawing performance. It is a multi threaded 
> application thats why we can't use the
>           pixmap cache concept because in multi threaded environment we 
> can't use the pixmap. Can anybody suggests if the same cache concept is 
> there for qimage                 also. Waiting for your suggestions.....
> 
>           Thanking in Advance...
> 
> Thanks,
>   Trinath
>  

QPixmap on embedded is simply a wrapper around a QImage. The important 
consideration is to choose image formats that are optimal for drawing, 
such as RGB32 or RGB16 (ideally), or ARGB32_Premultiplied or 
ARGB8565_Premultiplied if you need an alpha channel. Choose the latter 
of each format if you only need 16-bit.

Also, if you're drawing the images with a scale that doesn't change too 
much it might help to pre-scale the images using QImage::scaled() to the 
desired resolution. For example if a 800x600 image is drawn at scales of 
80x60 to 160x120 it might be beneficial to pre-scale it to 160x120 or 
thereabouts. You can use the Qt::SmoothTransformation flag to 
QImage::scaled() to get good quality when downscaling. Note that you 
should only do this once, don't call scaled() over and over on the same 
image in order to blit it, then it's better to just scale it using QPainter.

QPixmapCache doesn't help too much with rendering performance, it's more 
of a way to cache pixmaps loaded from disk or generated on demand so 
that they can be discarded when not in use.

--
Samuel



More information about the Qt-interest-old mailing list