在使用qt3.3.2开发实时系统的图形时,如果我们需要设置图形的背景图,需要使用下面的函数进行绘制:
void QPainter::drawImage ( const QPoint &, const QImage &, const QRect & sr, int conversionFlags = 0 )
或者是
void QPainter::drawPixmap ( int x, int y, const QPixmap & pixmap, int sx = 0, int sy = 0, int sw = -1, int sh = -1 )
如果你在绘制大的背景图时使用了drawImage()函数,你将会发现背景图刷新的速度会比较慢,这一点在qt的文档中也进行了说明:
There are functions to draw pixmaps/images, namely drawPixmap(), drawImage() and drawTiledPixmap(). drawPixmap() and drawImage() produce the same result, except that drawPixmap() is faster on-screen and drawImage() faster and sometimes better on QPrinter and QPicture.
还有在drawImage()函数的说明中:
This function may convert image to a pixmap and then draw it, if device() is a QPixmap or a QWidget, or else draw it directly, if device() is a QPrinter or QPicture.
所以我们要做的第一步就是要把程序中使用drawImage()函数的地方转化为drawPixmap(); Ok,完成了上面