从磁盘上的2个png文件开始(我可以加载到2个pixmaps)具有相同的尺寸,如何在它们之间用一个小的垂直(透明)空间水平平铺它们,如下所示:
aaaaa bbbbb
aaaaa bbbbb
aaaaa bbbbb
并将结果保存为另一个像素图?
环境:Windows上的PyQt 4.8.3
答案 0 :(得分:2)
这应该是一个很好的起点(未经测试):
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