PDA

View Full Version : Diff between QImage, QPixmap, QPicture



nupul
1st April 2006, 07:16
Well I sort of don't understand the difference between QImage, QPixmap, and Qpicture...could any one please help me out here....

Request: Be as clear as possible, as it's v.important for me to understand this concept.

Thanks

Nupul

Kapil
1st April 2006, 07:24
Hi..

Did you try these docs out:

QPixmap URL (http://doc.trolltech.com/4.1/qpixmap.html)

QImage URL (http://doc.trolltech.com/4.1/qimage.html)

QPicture URL (http://doc.trolltech.com/4.1/qpicture.html)

nupul
1st April 2006, 07:25
Sorry for not mentioning it before YES, I did try the docs out.....I just want someone to throw more light on the concept....still a bit dicey after reading the docs...

Nupul

Kapil
1st April 2006, 07:36
QPicture: The QPicture class is a paint device that records and replays QPainter commands. It helps you create a picture of the whatever you are painting on the Painter.. You can save your painting and can reuse it... An example on the doc about QPicture explains you the same properly on how to do it...

Though the use of QImage and QPixmap i have found pretty similar but the difference lies in pixel access and manipulation... QImage is designed and optimized for I/O, and for direct pixel access and manipulation whereas while QPixmap is designed and optimized for showing images on screen.

The functions for the same explain you properly... just go thru them.. you can convert a QPixmap to QImage and use it functionality...

Just try to go thru each of the functions which would help you build on the understanding pretty well..

wysota
1st April 2006, 12:49
QPixmap is stored on the XServer when using X11 backend, whereas QImage is just an "array in memory" of the client program. So drawing QPixmaps on XWindow systems should be much faster than drawing QImages, as the data is already on the server, processed and ready to use.

From the programmer's point of view, treat QImage as an array of pixels and QPixmap as a "picture object" whose pixel contents are of no interest to you.

dadvir
29th April 2008, 13:59
The QImage class provides a hardware-independent image representation that allows direct access to the pixel data, and can be used as a paint device.

Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPicture. QImage is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen. QBitmap is only a convenience class that inherits QPixmap, ensuring a depth of 1. Finally, the QPicture class is a paint device that records and replays QPainter commands.

Brandybuck
30th April 2008, 02:02
QImage: Fast to draw to, slow to display.
QPixmap: Slow to draw to, fast to display.

If you want to draw or manipulate an image, then QImage is the class for you. But if you just want to draw an existing image over and over (icon, background pixmap, OpenGL texture, etc) then use QPixmap. You can convert one to the other easily, but it is a slow operation.

QPicture stores QPainter drawing commands, and is a completely different kind of class.