Results 1 to 11 of 11

Thread: QPainter problem (a HW issue perhaps?)

  1. #1
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QPainter problem (a HW issue perhaps?)

    Hi,

    I have something odd going on with QPainter/QPixmap that I don't understand.
    Before I start - I'm not using OpenGL.

    I have a image which is 1798x1709x24bit (it's a texture map which contains multiple textures).
    I load it into a Pixmap and use QPainter::drawPixmap to draw a sub-sections of it.
    This works as expected on my PC with a low end graphics card.

    I've just discovered on a friend's PC that the pixmap is not rendered at all when QPainter::drawPixmap is called (exactly the same binaries were used in both cases, the image is embedded as a resource).

    I also load other images from other resources (much small images) and sub-sections of these are using the same QPainter::drawPixmap calls.
    These images are rendered correctly.

    The end result is there is a large transparent empty space where the big image should be surrounded by smaller images.

    We've verified that the QPixmap loaded with the image returns the correct dimensions, etc, so it appears that the QPainter::drawPixmap call is failing silently.

    Are there any known issues with QPixmap/QPainter on different flavors of graphics HW?
    (should images ideally be power-of-2 when they are used for textures?)
    (He has a mid-range to higher end graphics card)

    Are there any good debugging techniques that I could use to find out the root cause of this issue?

    Also, assuming it is a HW issue, is there an API I can use to determine the limitations of the HW so that I can adjust things on the fly so my SW works for all HW?

    Thanks
    J

  2. #2
    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: QPainter problem (a HW issue perhaps?)

    What are you drawing the pixmap to?
    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.


  3. #3
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QPainter problem (a HW issue perhaps?)

    a QGraphicsScene

    the scene params (if it's important):

    Qt Code:
    1. scene.setItemIndexMethod(QGraphicsScene::NoIndex);
    2. scene.setSceneRect(QRectF(-2500, -2500, 5000, 5000));
    To copy to clipboard, switch view to plain text mode 

    All of the view params:

    Qt Code:
    1. view->setRenderHint(QPainter::Antialiasing);
    2. view->setCacheMode(QGraphicsView::CacheBackground);
    3. view->setDragMode(QGraphicsView::RubberBandDrag);
    4. view->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
    To copy to clipboard, switch view to plain text mode 

    For the draw image function, src = (0,0,100,100), dest = (0,0,100,100).
    The 100x100 block of pixels is rendered on my PC, but not on my friend's.

  4. #4
    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: QPainter problem (a HW issue perhaps?)

    Can we see the exact sequence of calls you use to draw? Or better yet try to provide a minimal compilable example reproducing the problem.
    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.


  5. #5
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QPainter problem (a HW issue perhaps?)

    I've just created a minimal implementation.
    I'm waiting to hear for the result.
    I'll post it as soon as I hear.

    Thanks

  6. #6
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QPainter problem (a HW issue perhaps?)

    Hi - back again
    Here's a short prog that reproduces the problem.
    In this case, the red square is missing from his, but not mine.

    main.cpp

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. MainWindow w;
    8. w.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 


    MainWindow.h

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QtGui/QMainWindow>
    5. #include <QGraphicsView>
    6. #include <QPainter>
    7. #include <QStyleOptionGraphicsItem>
    8. #include <QWidget>
    9. #include <QGraphicsItem>
    10.  
    11. namespace Ui
    12. {
    13. class MainWindow;
    14. }
    15.  
    16.  
    17. class MyGraphicsItem : public QGraphicsItem
    18. {
    19. QPixmap pixmap;
    20. public:
    21. MyGraphicsItem(const QString &source, QGraphicsScene *scene) : QGraphicsItem(0, scene)
    22. {
    23. pixmap.load(source);
    24. }
    25. QRectF boundingRect() const
    26. {
    27. return QRectF(0,0, 100, 100);
    28. }
    29. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    30. {
    31. painter->drawPixmap(0,
    32. 0,
    33. 100,
    34. 100,
    35. pixmap,
    36. 0,0,
    37. 100,
    38. 100);
    39. }
    40. };
    41.  
    42.  
    43. class MainWindow : public QMainWindow
    44. {
    45. Q_OBJECT
    46.  
    47. public:
    48. MainWindow(QWidget *parent = 0);
    49. ~MainWindow();
    50.  
    51. private:
    52. Ui::MainWindow *ui;
    53. MyGraphicsItem* missing;
    54. MyGraphicsItem* notMissing;
    55. };
    56. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 


    MainWindow.cpp

    Qt Code:
    1. #include <QGraphicsScene.h>
    2. #include <QHBoxLayout>
    3. #include <QPixmap>
    4. #include "mainwindow.h"
    5. #include "ui_mainwindow.h"
    6.  
    7. MainWindow::MainWindow(QWidget *parent)
    8. : QMainWindow(parent), ui(new Ui::MainWindow)
    9. {
    10. ui->setupUi(this);
    11. scene.setItemIndexMethod(QGraphicsScene::NoIndex);
    12. scene.setSceneRect(QRectF(-2500, -2500, 5000, 5000));
    13. view = new QGraphicsView(&scene);
    14. view->setRenderHint(QPainter::Antialiasing);
    15. view->setCacheMode(QGraphicsView::CacheBackground);
    16. view->setDragMode(QGraphicsView::RubberBandDrag);
    17. view->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
    18.  
    19. QHBoxLayout *layout = new QHBoxLayout;
    20. layout->addWidget(view);
    21. QWidget *widget = new QWidget;
    22. widget->setLayout(layout);
    23. setCentralWidget(widget);
    24.  
    25.  
    26. MyGraphicsItem* missing1 = new MyGraphicsItem(":/missing1", &scene);
    27. MyGraphicsItem* missing2 = new MyGraphicsItem(":/missing2", &scene);
    28. MyGraphicsItem* notMissing = new MyGraphicsItem(":/notmissing", &scene);
    29. MyGraphicsItem* notMissing2 = new MyGraphicsItem(":/notmissing", &scene);
    30. missing1->setPos(0, 0);
    31. missing2->setPos(0, 100);
    32. notMissing->setPos(-100, 0);
    33. notMissing2->setPos(100, 100);
    34. }
    35.  
    36. MainWindow::~MainWindow()
    37. {
    38. delete ui;
    39. }
    To copy to clipboard, switch view to plain text mode 

    resources.qrc
    Qt Code:
    1. <RCC>
    2. <qresource prefix="/" >
    3. <file alias="notmissing" >notmissing.png</file>
    4. <file alias="missing1" >missing.jpg</file>
    5. <file alias="missing2" >missing2.png</file>
    6. </qresource>
    7. </RCC>
    To copy to clipboard, switch view to plain text mode 

    Minimal.pro
    Qt Code:
    1. # -------------------------------------------------
    2. # Project created by QtCreator 2009-06-07T06:49:19
    3. # -------------------------------------------------
    4. TARGET = Minimal
    5. TEMPLATE = app
    6. SOURCES += main.cpp \
    7. mainwindow.cpp
    8. HEADERS += mainwindow.h
    9. FORMS += mainwindow.ui
    10. RESOURCES += resources.qrc
    To copy to clipboard, switch view to plain text mode 

    "notmissing.png"


    "missing.jpg"
    Only a link here because the image dimensions are so large (1798x1709x24 48Kb)
    This is the missing "red square" texture source.
    http://img13.imageshack.us/img13/5735/missingz.jpg

    "missing2.png" (1798x1709x24 WARNING 2.2MB)
    Only a link here because the image dimensions and file size are large (1798x1709x24 2.2MB)
    http://img44.imageshack.us/img44/8383/missing2.png

    My result:


    His result:
    Last edited by jonks; 9th June 2009 at 07:08.

  7. #7
    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: QPainter problem (a HW issue perhaps?)

    Are both systems Windows? What happens if you run the application with "-graphicssystem raster" and "-graphicssystem opengl"? Does it change anything?
    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.


  8. #8
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QPainter problem (a HW issue perhaps?)

    Hi thanks for staying interested.

    Both are running windows Vista. Mine is 32bit, I'm not sure if his is 64bit (I suspect it is).
    For me "-graphicssystem raster" and "-graphicssystem opengl" produce the correct results.
    For him....I'll have the results later

    BRB

  9. #9
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QPainter problem (a HW issue perhaps?)

    Quote Originally Posted by wysota View Post
    Are both systems Windows? What happens if you run the application with "-graphicssystem raster" and "-graphicssystem opengl"? Does it change anything?
    He has 64bit Vista with a GTS8800 with latest drivers.

    -graphicssystem raster" and "-graphicssystem opengl" had no effect.

    We just discovered that by changing the red jpg to a 32bit png it works on his PC as well.

  10. #10
    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: QPainter problem (a HW issue perhaps?)

    In that case maybe he simply doesn't have a JPEG image plugin installed?
    http://www.qtcentre.org/forum/faq.ph...missing_images
    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.


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

    jonks (10th June 2009)

  12. #11
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QPainter problem (a HW issue perhaps?) - solved

    Thank you!

    I assumed the FAQ link in the menu above for for forum FAQs, not for QT specifics!
    I really should browse around this forum more.

Similar Threads

  1. Problem when mixing openGL and QPainter
    By sanjayshelke in forum Qt Programming
    Replies: 9
    Last Post: 21st March 2008, 12:49
  2. use Qpainter to draw lines + problem in my painter
    By ReSu in forum Qt Programming
    Replies: 4
    Last Post: 5th March 2008, 15:44
  3. problem with opengl, zooming, drawpixels, and origin
    By ntp in forum General Programming
    Replies: 0
    Last Post: 22nd February 2008, 21:48
  4. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  5. QPainter problem - migration from qt3 [SOLVED]
    By tpomorsk in forum Qt Programming
    Replies: 7
    Last Post: 28th August 2006, 14:43

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.