Results 1 to 3 of 3

Thread: QGraphicsView + OpenGL -> Pixmap rendering issue

  1. #1

    Question QGraphicsView + OpenGL -> Pixmap rendering issue

    Hi folks,

    here comes my first posting

    I want to display raw data from a camera by using QGraphicsView and pixmap.
    For performance issues I have to enable OpenGl, but this leads to my problem.

    If OpenGL is enabled, the pixmap is getting transformed. For me it looks like the nearest neighbor algorithm for smoothing an image.

    So my question:
    - is it possible to disable this effect, so that QGLWidget engine is NOT antialiasing edges?

    I played with QPainter::RenderHints, but no success.

    Attached you'll find the source code and screenshots of the test-application. I am using version 4.3 of qt.

    Kind regards
    Joerg
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Posts
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Question Re: QGraphicsView + OpenGL -> Pixmap rendering issue

    Ahoy,
    Is it necessary that you use QPixmap? can you use QImage, or raw data buffer? if yes, then I recommend using glDrawPixels or better texture-mapping (http://www.qtcentre.org/forum/f-qt-p...ghlight=opengl)it is much faster than QT4 painting implementation in a QGLWidget.
    cheers

  3. #3
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Thanked 38 Times in 30 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Smile Re: QGraphicsView + OpenGL -> Pixmap rendering issue

    Try translating the image item, or setting an offset, of exactly (0.5, 0.5). This is the only way to ensure that Graphics View's untransformed logical units map perfectly to the center of each pixel in device coordinates. That should remove your smoothing effect, which is caused by OpenGL's subtexel support to cause smoothing as the pixmap is drawn at (-0.5, -0.5). QWidget (not OpenGL) does not support subtexels, so the pixmap will "snap to grid" instead of being smoothed / which is why you don't see this without enabling OpenGL. Note that OpenGL does not guarantee pixel perfection so this is highly hardware and driver dependent.

    So, you can 1) translate the item:

    Qt Code:
    1. pixmapItem->translate(0.5, 0.5);
    To copy to clipboard, switch view to plain text mode 

    Or 2) set an offset:

    Qt Code:
    1. pixmapItem->setOffset(QPointF(0.5, 0.5));
    To copy to clipboard, switch view to plain text mode 

    Or 3) translate the view:

    Qt Code:
    1. view->translate(0.5, 0.5);
    To copy to clipboard, switch view to plain text mode 
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

  4. The following user says thank you to Bitto for this useful post:

    JohannesMunk (27th September 2010)

Similar Threads

  1. problem in rendering opengl on QGraphicsView
    By Sandip in forum Qt Programming
    Replies: 17
    Last Post: 15th April 2008, 08:27
  2. Replies: 3
    Last Post: 12th February 2008, 21:17
  3. QGraphicsView rendering issue
    By guilugi in forum Qt Programming
    Replies: 9
    Last Post: 6th April 2007, 09:09

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.