PDA

View Full Version : QImage or QPixmap?



Dark_Tower
1st April 2006, 15:54
Hi, in my app I need to paint several times an image using QPainter. I'm thinking in having a copy of the image using a QImage because I need to access to its pixels contents. The problem is that I think that to paint this image using QPainter maybe should be faster if I use a QPixamp. Is it true? What do you recommend me?

jacek
1st April 2006, 16:08
How much is "several times" and how big is that image?

Dark_Tower
1st April 2006, 16:28
How much is "several times"
Some times I should need to paint it almost continously

...and how big is that image?
The image could be very big (sometimes up to 3000pix), to paint it some times I should need to scale it with QPainter itself.

Do you think that with QPixmap it should be painted fater?

jacek
1st April 2006, 16:40
Some times I should need to paint it almost continously
How many times per second?


The image could be very big (sometimes up to 3000pix),
50x50 image has 2500 pixels.


Do you think that with QPixmap it should be painted fater?
On windows QImage and QPixmap have the same internal representation. What do you need from QImage functionality?

Dark_Tower
1st April 2006, 16:43
How many times per second?


50x50 image has 2500 pixels.


On windows QImage and QPixmap have the same internal representation. What do you need from QImage functionality?

I mean 3000 pix by side. Sometimes I need to acess to the pixels and modify them: fill some areas of the image with a given color, etc. But if in widnows they have the same representation seems like they will be painted with the same behaviour, no?

jacek
1st April 2006, 16:49
Sometimes I need to acess to the pixels and modify them: fill some areas of the image with a given color, etc.
If you need to read pixel values, then you must use QImage, but maybe QPainter::fillRect() or QPainter::fillPath() will be enough?

Or maybe you don't need an image at all, but something like Q3Canvas?

Dark_Tower
1st April 2006, 16:52
If you need to read pixel values, then you must use QImage, but maybe QPainter::fillRect() or QPainter::fillPath() will be enough?

Or maybe you don't need an image at all, but something like Q3Canvas?

jacek, I need to modify the source image because I need to save it at the end. But thanks for the suggestions. I think I will use a QImage seems like it will be painted just like a QPixamp.
Thanks jacek

jacek
1st April 2006, 16:55
You can save QPixmap just like QImage. If you don't have to read particular pixels and you have only one thread, you don't need QImage.

Dark_Tower
1st April 2006, 16:58
You can save QPixmap just like QImage. If you don't have to read particular pixels and you have only one thread, you don't need QImage.

I need to read particular pixels ;) Do you think that QPixmap might be faster?

jacek
1st April 2006, 17:08
Do you think that QPixmap might be faster?
On windows there shouldn't be any difference.