[Qt-interest] QPainter performance
Glenn Pierce
glennpierce at gmail.com
Fri Feb 6 19:38:28 CET 2009
HI
I am new to QT and I have been following the guide at
http://labs.trolltech.com/blogs/2006/05/13/fast-transformed-pixmapimage-drawing/
This is so I can create an QImageView that would allow one to pan and zoom
an image to any size.
I have, I believe, implemented my fast drawing in the same way. I have also
used similar techniques for doing the same with GDI and GTK without
problems.
However, although the code works OK when there is no scaling as soon as I
add painter.scale(2.0, 2.0) the scrolling of the image is very slow.
The image I am testing with is 3888x2592 pixels in size.
My code is
QScrollBar *hs = this->horizontalScrollBar(); QScrollBar *vs =
this->verticalScrollBar();
int horz*pos = hs->value(); int vert*pos = vs->value();
QPainter painter(this->viewport());
painter.scale(2, 2); painter.translate(-horz*pos, -vert*pos);
QRect exposedRect =
painter.matrix().inverted().mapRect(event->rect()).adjusted(-1, -1, 1, 1);
// the adjust is to account for half pixels along edges
painter.drawPixmap(exposedRect, this->pix, exposedRect);
Although I am only drawing only a very small portion of the image using the
scrollbars or panning is dead slow ?
Should this not be fast ?
Any advice is appreciated.
Thank you
Glenn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090206/a7417c6c/attachment.html
More information about the Qt-interest-old
mailing list