[Qt-interest] QtConcurrent::run results in random crashes

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Wed Jul 28 11:37:23 CEST 2010


Justus Best wrote on Wednesday, July 28, 2010 1:05 AM:

> ... Is the conversion from QImage
> to QPixmap very expensive, if I use a QImage whith the same Format as
> the Pixmap on the current system 

It is relatively expensive, yes! This is because the "pixel data alignment" could be completely different on the hardware (QPixmap uses the "native hardware format") and the software (QImage), even though you are dealing in both cases with "32bit RGBA" data. 

For instance the data in QImage could be stored as RGBA, whereas in the QPixmap it could be ABGR, or even BGRA, or any order you could think of. Then there is the issue of "byte padding": the QImage data is "32-bit aligned (http://doc.qt.nokia.com/4.6/qimage.html#scanLine) whereas in a QPixmap it could be different.

Also, how do you make sure that your QImage has the same format as the QPixmap? Do you query that at runtime? But again, even if you use the same depth it is still not guaranteed that the byte ordering and padding is the same - and hence the conversion is "relatively expensive". 

Even though in practise it might be cheap, since 32-bit alignment is probably very common and if you really *know* that the byte ordering in your QPixmap is one of http://doc.qt.nokia.com/4.6/qimage.html#Format-enum then the conversion might be a simple memory copy for Qt to do.

Cheers, Oliver
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list