Issue
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.
Solution
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')
Answered By - ekhumoro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.