修改SDR色准深色异常、修改保存结果深色模式异常

This commit is contained in:
xinzhu.yin
2026-06-09 11:02:55 +08:00
parent 9ad9cf9aa0
commit 8916f2fff0
6 changed files with 206 additions and 83 deletions

View File

@@ -2,15 +2,14 @@
import os
_EXPORT_BG_COLOR = "#FFFFFF"
def _save_with_light_background(fig, path, *, dpi=300, bbox_inches=None):
"""导出统一浅色背景,避免深色主题下图片背景变暗。"""
def _save_with_theme_background(fig, path, *, dpi=300, bbox_inches=None):
"""按图表当前主题背景导出,避免深色模式下被强制写成白底。"""
bg = fig.get_facecolor()
kwargs = {
"dpi": dpi,
"facecolor": _EXPORT_BG_COLOR,
"edgecolor": _EXPORT_BG_COLOR,
"facecolor": bg,
"edgecolor": bg,
"transparent": False,
}
if bbox_inches is not None:
kwargs["bbox_inches"] = bbox_inches
@@ -85,7 +84,7 @@ def save_result_images(result_dir, current_test_type, selected_items,
continue
per_ref_name = f"色域测试结果_{ref}.png"
path = os.path.join(result_dir, per_ref_name)
_save_with_light_background(fig, path, dpi=300)
_save_with_theme_background(fig, path, dpi=300)
log(f"已保存: {per_ref_name}")
finally:
ref_var.set(original_ref)
@@ -97,7 +96,7 @@ def save_result_images(result_dir, current_test_type, selected_items,
continue
path = os.path.join(result_dir, filename)
if default_bbox:
_save_with_light_background(fig, path, dpi=300)
_save_with_theme_background(fig, path, dpi=300)
else:
_save_with_light_background(fig, path, dpi=300, bbox_inches="tight")
_save_with_theme_background(fig, path, dpi=300, bbox_inches="tight")
log(f"已保存: {filename}")