Results 1 to 3 of 3

Thread: Anyway to increase paint performance

  1. #1
    Join Date
    Jun 2012
    Posts
    18
    Thanked 9 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Anyway to increase paint performance

    This is just an experiment I have been doing. It takes about 7 seconds to run with 200 points. The CPU and memory on the machine are not that great 454 MHz ARM9 processor with 128MB RAM, there might not be a way to speed this up, but I thought I'd ask.

    Qt Code:
    1. void HeatMap::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
    2. {
    3. int x = 0;
    4. int y = 0;
    5. qreal intensity = 0;
    6. qDebug() << QTime::currentTime();
    7.  
    8. QImage image(m_width, m_height, QImage::Format_ARGB32_Premultiplied);
    9. QPainter *paint = new QPainter(&image);
    10.  
    11. foreach (QVariant v, m_data)
    12. {
    13. QStringList tmp = v.toString().split(",");
    14.  
    15. x = tmp[0].toInt();
    16. y = tmp[1].toInt();
    17. intensity = tmp[2].toDouble();
    18. QRadialGradient g(QPointF(x, y), m_radius, QPointF(x, y));
    19. g.setColorAt(0.0, QColor::fromRgbF(0, 0, 0, intensity));
    20. g.setColorAt(1.0, QColor::fromRgbF(0, 0, 0, 0.0));
    21. paint->fillRect(QRectF(x - m_radius, y - m_radius, x + m_radius, y + m_radius), g);
    22. }
    23.  
    24. painter->drawImage(QPoint(0, 0), image);
    25. qDebug() << QTime::currentTime();
    26. }
    To copy to clipboard, switch view to plain text mode 

    Thanks

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

    Default Re: Anyway to increase paint performance

    Do not create the image in the paint() method. In the above method you should only have what is in your line #24.
    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
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Anyway to increase paint performance

    And it is currently leaking the painter "paint". Just create it on the stack.

    Cheers,
    _

Similar Threads

  1. How to increase progress bar
    By shivendra46d in forum Newbie
    Replies: 7
    Last Post: 11th September 2013, 13:07
  2. How to increase available RAM for Qt Creator?
    By fezvez in forum Qt Tools
    Replies: 4
    Last Post: 19th April 2011, 21:37
  3. Replies: 1
    Last Post: 14th April 2011, 15:21
  4. Increase QPainter performance
    By travelan in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2009, 11:52
  5. Replies: 1
    Last Post: 9th June 2008, 20:41

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
  •  
Qt is a trademark of The Qt Company.