diff --git a/plugins/dagu-ocr/CHANGELOG.md b/plugins/dagu-ocr/CHANGELOG.md index c80042730..a61fb84e2 100644 --- a/plugins/dagu-ocr/CHANGELOG.md +++ b/plugins/dagu-ocr/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.2.2 - 2026-11-11 + +### 修复 + +- 修复 Windows HDR 显示器下桌面捕获帧可能全白的问题:检测到整帧纯白时自动回退 ZTools 系统截图,再进入同一套标注界面,避免把过曝冻帧当成正常画面。 + ## 1.2.1 - 2026-10-30 ### 修复 diff --git a/plugins/dagu-ocr/plugin.json b/plugins/dagu-ocr/plugin.json index 994afda48..623e3b9b9 100644 --- a/plugins/dagu-ocr/plugin.json +++ b/plugins/dagu-ocr/plugin.json @@ -1,7 +1,7 @@ { "name": "dagu-ocr", "title": "大古截图", - "version": "1.2.1", + "version": "1.2.2", "description": "截图、OCR 文字识别与图片翻译,从图片中提取并翻译文字", "author": "beierweiwei", "logo": "icon.png", diff --git a/plugins/dagu-ocr/src/capture/desktop-capture.js b/plugins/dagu-ocr/src/capture/desktop-capture.js index e1acde72b..9b7b335c5 100644 --- a/plugins/dagu-ocr/src/capture/desktop-capture.js +++ b/plugins/dagu-ocr/src/capture/desktop-capture.js @@ -84,6 +84,29 @@ export function pickSourceForDisplay(sources, display) { return list.find((source) => /^screen/i.test(String(source.id || ''))) || list[0]; } +async function isSolidWhiteFrame(dataUrl, win = globalThis.window) { + if (!dataUrl.startsWith('data:image/') || !win?.Image || !win?.document?.createElement) return false; + const image = new win.Image(); + const loaded = new Promise((resolve, reject) => { + image.onload = resolve; + image.onerror = () => reject(new Error('截图帧解码失败')); + }); + image.src = dataUrl; + await loaded; + + const canvas = win.document.createElement('canvas'); + canvas.width = 16; + canvas.height = 16; + const context = canvas.getContext('2d', { willReadFrequently: true }); + if (!context) return false; + context.drawImage(image, 0, 0, canvas.width, canvas.height); + const pixels = context.getImageData(0, 0, canvas.width, canvas.height).data; + for (let index = 0; index < pixels.length; index += 4) { + if (pixels[index] !== 255 || pixels[index + 1] !== 255 || pixels[index + 2] !== 255) return false; + } + return true; +} + // 返回原始分辨率截图(image 像素与显示器物理像素一致)。 export async function captureDisplay(win, display) { const host = hostApi(win); @@ -96,6 +119,9 @@ export async function captureDisplay(win, display) { const thumbnail = source?.thumbnail; const dataUrl = typeof thumbnail?.toDataURL === 'function' ? thumbnail.toDataURL() : ''; if (!dataUrl) throw new Error('未获取到屏幕截图'); + if (await isSolidWhiteFrame(dataUrl, win)) { + throw new Error('HDR 环境截图输出全白,已回退系统截图'); + } const size = typeof thumbnail?.getSize === 'function' ? thumbnail.getSize() : requested; return { dataUrl,