문제

What would be a short simple way to generate a raster image with PyQt? Ideally I would like to supply a function with a desired image resolution (such as 16x16 pixels) and save the resulted image to drive as a simple JPG.

도움이 되었습니까?

해결책

Use the QImage class:

def create_image(width, height, path):
    img = QtGui.QImage(width, height, QtGui.QImage.Format_RGB32)
    img.fill(QtCore.Qt.red)
    img.save(path, 'JPG')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top