Results 1 to 3 of 3

Thread: QGraphicsScene Low Image Quality

  1. #1
    Join Date
    Feb 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question QGraphicsScene Low Image Quality

    Hi all,

    we are porting our software to QT. In our software we have a view that shows an image, and the user can drag objects from the toolbar to the page.

    The image is always a jpeg, with high resolution, so when we see it on screen is always shrinked. The problem is that the image when shrinked has very poor quality, when comparing to our previous Windows platform using GDI+.

    We tried all the render hints available, but the quality is still very poor. I was expecting that for a 3000$ license (not paid, we are testing before), at least the resize algorithms would be some good. In GDI+ we never had to do extra work, just set the render hints, and we get good shrinked image quality!

    What do we need to do to have a good shrink image quality?

    The JPEG image object is a subclassed QGraphicsRectItem. We tried QImage and QPixmap for drawing the image, but results are the same! The images are drawed inside the paint event in our subclassed QGraphicsRectItem.

    void CCanvasPageImage:aint( QPainter *p, const QStyleOptionGraphicsItem *option, QWidget * widget)
    {
    p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing | QPainter::NonCosmeticDefaultPen, true);

    p->drawImage( option->exposedRect, m_image, option->exposedRect, Qt::OrderedAlphaDither );
    // p->drawPixmap( option->exposedRect, m_pixmap, option->exposedRect );
    }

    Any help would be appreciatted here...

    Thanks

  2. #2
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsScene Low Image Quality

    Couple things:
    Use drawPixmap. QImage is optimized for editing, and QPixmap is optimized for display. So if you are painting often, then do it with QPixmap and drawPixmap (drawImage will internally convert to a QPixmap which is slow).

    Your drawing code seems alright. You could try setting the SmoothPixmapTransform render hint on the view, although that shouldn't make a difference.

    Are you drawing your image in full and unscaled, scaled, or clipped? Because if you're scaling your image and are using something like QPixmap::scaled(), then you have to pass it the Qt::SmoothTransformation transformation mode. Post the code where you load your pixmap/image.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene Low Image Quality

    Quote Originally Posted by nemmartins View Post
    I was expecting that for a 3000$ license (not paid, we are testing before), at least the resize algorithms would be some good. In GDI+ we never had to do extra work, just set the render hints, and we get good shrinked image quality!
    $3000 have nothing to do with image scaling. Algorithms for image scaling are well known and are free of charge. It would be silly to implement something bad if at the same price you can have something good so assuming something like that could be considered silly as well.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QPainter error saving an image from a QGraphicsScene
    By cydside in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2010, 04:53
  2. Replies: 4
    Last Post: 16th March 2009, 09:08
  3. Saving QGraphicsScene with OpenGL to image
    By elbaschid in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2009, 20:32
  4. Painter greyscale, image quality paint-brush!
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 22nd March 2007, 20:32

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.