Results 1 to 10 of 10

Thread: QImage or QPixmap?

  1. #1
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question QImage or QPixmap?

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage or QPixmap?

    How much is "several times" and how big is that image?

  3. #3
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QImage or QPixmap?

    Quote Originally Posted by jacek
    How much is "several times"
    Some times I should need to paint it almost continously
    Quote Originally Posted by jacek
    ...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?
    Last edited by Dark_Tower; 1st April 2006 at 16:36.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage or QPixmap?

    Quote Originally Posted by Dark_Tower
    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?

  5. #5
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QImage or QPixmap?

    Quote Originally Posted by jacek
    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?
    Last edited by Dark_Tower; 1st April 2006 at 16:46.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage or QPixmap?

    Quote Originally Posted by Dark_Tower
    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?

  7. #7
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QImage or QPixmap?

    Quote Originally Posted by jacek
    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

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage or QPixmap?

    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.

  9. #9
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QImage or QPixmap?

    Quote Originally Posted by jacek
    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?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QImage or QPixmap?

    Quote Originally Posted by Dark_Tower
    Do you think that QPixmap might be faster?
    On windows there shouldn't be any difference.

  11. The following user says thank you to jacek for this useful post:

    Dark_Tower (1st April 2006)

Similar Threads

  1. drawing on a QPixmap or QImage
    By gren15 in forum Newbie
    Replies: 15
    Last Post: 3rd March 2009, 17:48
  2. Construct QPixmap or QImage from raw data.
    By The Storm in forum Qt Programming
    Replies: 5
    Last Post: 1st December 2008, 08:21
  3. DIB to QImage or QPixmap
    By ^NyAw^ in forum Qt Programming
    Replies: 0
    Last Post: 8th August 2008, 20:18
  4. Diff between QImage, QPixmap, QPicture
    By nupul in forum Newbie
    Replies: 6
    Last Post: 30th April 2008, 02:02
  5. Replies: 7
    Last Post: 12th August 2006, 15:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.