[英]How to make a high quality screenshot in Python
I have this Python function and it works well taking a regular screenshot. 我具有此Python函数,并且可以正常拍摄常规屏幕截图。
I would like to be able to take the screenshot in high resolution. 我希望能够以高分辨率拍摄屏幕截图。 Could this code be modified to accomplish this, or would I need to integrate with another library?
可以修改此代码来完成此操作,还是需要与另一个库集成?
def SaveScreen(self):
print "save screen"
# SCREENSHOT_CWDSAVE
if SCREENSHOT_CWDSAVE:
if not os.path.exists(os.getcwd()+os.sep+"screenshot"):
os.mkdir(os.getcwd()+os.sep+"screenshot")
(succeeded, name) = grp.SaveScreenShotToPath(os.getcwd()+os.sep+"screenshot"+os.sep)
elif SCREENSHOT_DIR:
(succeeded, name) = grp.SaveScreenShot(SCREENSHOT_DIR)
else:
(succeeded, name) = grp.SaveScreenShot()
# END_OF_SCREENSHOT_CWDSAVE
if succeeded:
pass
"""
chat.AppendChat(chat.CHAT_TYPE_INFO, name + localeInfo.SCREENSHOT_SAVE1)
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SCREENSHOT_SAVE2)
"""
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SCREENSHOT_SAVE_FAILURE)
2 solutions for you: either you try another module like MSS (easy, efficient and creates high quality PNG pictures), either you change the code of the function SaveJPEG
: 为您提供2种解决方案:您尝试使用另一个模块(例如MSS) (简单,高效并创建高质量PNG图片),或者更改功能
SaveJPEG
的代码:
// https://pastebin.com/xAv30gK1 at line 169
return jpeg_save(pbyBuffer, uWidth, uHeight, 85, pszFileName) != 0;
You see the 85
? 您看到
85
吗? It is the picture quality. 这是画质。 Just change to
100
;) 只需更改为
100
;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.