Starting with 2 png files on disk (which I can load to 2 pixmaps) with the same dimensions, how can I tile them horizontally with a small vertical (transparent) space开发者_如何学JAVA between them, like this:
aaaaa bbbbb
aaaaa bbbbb
aaaaa bbbbb
and save the result as another pixmap?
Environment: PyQt 4.8.3 on Windows
This should be a good starting point (untested):
painter = QPainter() // the QPainter to the object you want to paint
a = QImage("file1.png")
b = QImage("file2.png")
space = 5 // pixels
tile = QPixmap(QSize(a.width() + b.width(), a.height() + space)
painter2.setBrush(QBrush(QColor(0, 0, 0, 0)))
painter2.fillRect(0, 0, tile.width(), tile.height())
painter2 = QPainter(tile)
painter2.drawImage(QPoint(0, 0), a)
painter2.drawImage(QPoint(a.width(), 0), b)
painter.setBrush(tile.toImage())
// now anything you draw will be filled with the tiled pattern
精彩评论