我的截图代码:
def savepng(self):
fileName = QFileDialog.getSaveFileName(self.win, "Save Page", QDesktopServices.storageLocation(QDesktopServices.DesktopLocation), "Portable Network Graphics (*.png)")
if fileName != "":
mw.progress.start(immediate=True)
if not ".png" in fileName:
fileName += ".png"
p = self.wv.page()
oldsize = p.viewportSize()
p.setViewportSize(p.mainFrame().contentsSize())
image = QImage(p.viewportSize(), QImage.Format_ARGB32)
painter = QPainter(image)
p.mainFrame().render(painter)
painter.end()
image.save(fileName, "png", 100)
p.setViewportSize(oldsize)
mw.progress.finish()
showInfo("Image saved to %s!" % os.path.abspath(fileName))
return
Here是截图。通常,图像也有很多伪影。我如何获得最佳质量?我不在乎文件大小。