Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugins/dagu-ocr/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.2.2 - 2026-11-11

### 修复

- 修复 Windows HDR 显示器下桌面捕获帧可能全白的问题:检测到整帧纯白时自动回退 ZTools 系统截图,再进入同一套标注界面,避免把过曝冻帧当成正常画面。

## 1.2.1 - 2026-10-30

### 修复
Expand Down
2 changes: 1 addition & 1 deletion plugins/dagu-ocr/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dagu-ocr",
"title": "大古截图",
"version": "1.2.1",
"version": "1.2.2",
"description": "截图、OCR 文字识别与图片翻译,从图片中提取并翻译文字",
"author": "beierweiwei",
"logo": "icon.png",
Expand Down
26 changes: 26 additions & 0 deletions plugins/dagu-ocr/src/capture/desktop-capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down
Loading