透明像素图:蓝色边框作为绘制人工制品

时间:2017-05-15 22:45:35

标签: python pyqt pyqt4 transparency qgraphicsview

我有一个带有QGraphicsScene scene的QGraphicsView,我在这个场景中添加了一个像素图。这很好用:

image = QtGui.QImage(1, 1, QtGui.QImage.Format_Indexed8)
image.load(fileName)
image = image.convertToFormat(6)

"""
# make white pixels transparent
transparency = QtGui.QColor(255, 255, 255, 255)
transparencyValue = transparency.value()

for x in range(image.width()):
    for y in range(image.height()):
        color = QtGui.QColor(image.pixel(x, y))
        if color.red() == 255 and color.green() == 255 and color.blue() == 255:
            image.setPixel(x, y, transparencyValue)
"""

pixmap = QtGui.QPixmap.fromImage(image)
pixmapItem = myScene.addPixmap(pixmap)

但是,当我为像素图添加透明度(代码中的多行注释)时,它会左右获得蓝色条纹边框,以及场景中的所有其他单个QGraphicsPixmapItem。我该如何摆脱边界?

Correct display without borders Faulty display with borders

0 个答案:

没有答案
相关问题