How do you change the color of the picels of the picture?



  • I want to write a program that would make blur effect. QPixmapQImage

    from PyQt4.QtGui import * 
    from PyQt4.QtCore import * 
    import sys
    

    def main():
    app = QApplication(sys.argv)
    window = QMainWindow()
    label = QLabel(window)
    pixmap = QPixmap('myimage.gif')
    label.setPixmap(pixmap)
    window.setCentralWidget(label)
    window.setWindowTitle("Blur Effect Example")
    window.show()

    sys.exit(app.exec_())
    

    if name == 'main':
    main()

    How do I change the colors of the pixmap pickles?



  • We add a button to a pressurization panel that will be in an accidental place with an accidental flower of 20x20:

    app = QApplication(sys.argv)
    

    window = QMainWindow()
    label = QLabel()
    pixmap = QPixmap(label.size())
    pixmap.fill(Qt.transparent)

    label.setPixmap(pixmap)

    window.setCentralWidget(label)
    window.setWindowTitle("Blur Effect Example")

    def draw_random():
    painter = QPainter(label.pixmap())
    # or:
    # painter = QPainter(pixmap)

    painter.setBrush(QColor(randint(0, 0xFF), randint(0, 0xFF), randint(0, 0xFF)))
    
    x, y = randint(0, pixmap.width()), randint(0, pixmap.height())
    painter.drawRect(x, y, 20, 20)
    
    label.update()
    # or:
    # label.setPixmap(pixmap)
    

    general_tool_bar = window.addToolBar('General')
    action = general_tool_bar.addAction('Draw Rand Rect')
    action.triggered.connect(draw_random)

    window.show()

    sys.exit(app.exec_())

    Skinshot:

    введите сюда описание изображения




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2