[Qt-interest] QPixmap / QImage performance question

Lucas Jacobs lucas.jacobs at mines.sdsmt.edu
Sat Jul 25 20:39:11 CEST 2009


Thanks for your response. I knew of easy ways to provide read/write
access to pixels within a QImage, like bits(), scanLine() and
QImage(uchar *data, ...), but as I currently understand Qt's image
support:

- QImages cannot be displayed to the screen. They must be converted to
QPixmap objects first.
- Individual pixels of a QPixmap cannot be read by users without
obtaining system-specific bitmap handles like HBITMAP.
- Looking through QPixmap's implementation, QPixmap::fromImage()
copies all pixel data from the QImage into another allocated block of
memory at least once, also checking for alpha pixels among other
things.

The possible overhead associated with having to call
QPixmap::fromImage() every time the image is changed and needs to be
redisplayed is my main concern. Initial testing shows that this won't
be much of a problem, I was just wondering if anyone else has worked
with native image handles for these sorts of applications, or tried
something completely different, and managed to get better performance
as a result.

- Lucas

> QImage ( uchar * data, int width, int height, Format format )
> QImage ( const uchar * data, int width, int height, Format format )
> QImage ( uchar * data, int width, int height, int bytesPerLine,
> Format format )
> QImage ( const uchar * data, int width, int height, int bytesPerLine,
> Format format)
>
>  the four contruct function will create the QImage object, and use the
> buffer named data with the format, when you change the data, such as
> data[100], the image will change immediately.




More information about the Qt-interest-old mailing list