-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2k屏幕电脑,在使用HDMI接口外接显示屏之后,点击截图键会出现蓝色的颜色块,影响截图 #279
Comments
我的天选4是win11系统,cpu是amd,屏幕刷新率较高,但是外接显示屏只有60hz,我不太清楚和这个有没有关系。另一台没问题的电脑屏幕是1080p,60hz刷新率,win10系统,cpu是英特尔,除此之外想不到有啥差别了...... |
补充一下,我的2k屏的笔记本电脑,如果不外接显示器,直接用截图功能,就不会出现蓝色的块。只有在使用HDMI外接显示器之后才会出现这个情况。 |
请尝试下列操作:
def requestPixmap(self, path, size=None, resSize=None):
if "/" in path:
compID, imgID = path.split("/", 1)
self._delCompCache(compID) # 先清缓存
if imgID in self.pixmapDict:
self.compDict[compID] = imgID # 记录缓存
return self.pixmapDict[imgID]
print(f"[Error] imgID {imgID} not in pixmapDict")
else: # 清空一个组件的缓存
self._delCompCache(path)
return self._getNoneImg() # 返回占位符
def getScreenshot(self, wait=0):
if wait > 0:
time.sleep(wait)
try:
grabList = []
screensList = QGuiApplication.screens()
for screen in screensList:
pixmap = screen.grabWindow(0) # 截图
imgID = PixmapProvider.addPixmap(pixmap) # 存入提供器,获取imgID
grabList.append(
{
"imgID": imgID,
"screenName": screen.name(),
}
)
print(imgID)
print(screen.name())
print(screen.devicePixelRatio())
print(screen.virtualGeometry())
print(screen.geometry())
return grabList
except Exception as e:
return [f"[Error] Screenshot: {e}"] 然后,在命令行中运行Umi-OCR,也可以直接运行 |
啊??太玄学了,截图对象已经缓存到字典里了怎么会莫名其妙的消失了呢…… 麻烦再改一下, requestPixmap函数改为: def requestPixmap(self, path, size=None, resSize=None):
print(f"request: {path}")
print(" ", list(k[-6:] for k in self.pixmapDict.keys()))
if "/" in path:
compID, imgID = path.split("/", 1)
self._delCompCache(compID) # 先清缓存
if imgID in self.pixmapDict:
self.compDict[compID] = imgID # 记录缓存
return self.pixmapDict[imgID]
print(f"[Error] imgID {imgID} not in pixmapDict!")
else: # 清空一个组件的缓存
self._delCompCache(path)
return self._getNoneImg() # 返回占位符 后面的 _delCompCache 函数改为: def _delCompCache(self, compID):
if compID in self.compDict:
last = self.compDict[compID]
if last in self.pixmapDict:
print(f"___del: {compID} {last}")
del self.pixmapDict[last]
del self.compDict[compID] |
Umi进行一次截图的流程是:
而在你的截图日志中,看到这一行出现了两次: 按理说,图片组件是不会重复请求id相同的缓存的。不知道为什么在你的设备上出现了重复的情况。 不过,既然知道问题发生的直接原因,咱们就能想办法绕开它。请打开 compID, imgID = path.split("/", 1)
self._delCompCache(compID) # 先清缓存 现在改动 compID, imgID = path.split("/", 1)
if compID in self.compDict and self.compDict[compID] != imgID: # 判断不是重复请求
self._delCompCache(compID) # 再清缓存 改动后,你的电脑上应该能正常使用双屏截图了。 |
The text was updated successfully, but these errors were encountered: