继续优化深色模式显示
This commit is contained in:
@@ -2,6 +2,21 @@
|
||||
import os
|
||||
|
||||
|
||||
_EXPORT_BG_COLOR = "#FFFFFF"
|
||||
|
||||
|
||||
def _save_with_light_background(fig, path, *, dpi=300, bbox_inches=None):
|
||||
"""导出统一浅色背景,避免深色主题下图片背景变暗。"""
|
||||
kwargs = {
|
||||
"dpi": dpi,
|
||||
"facecolor": _EXPORT_BG_COLOR,
|
||||
"edgecolor": _EXPORT_BG_COLOR,
|
||||
}
|
||||
if bbox_inches is not None:
|
||||
kwargs["bbox_inches"] = bbox_inches
|
||||
fig.savefig(path, **kwargs)
|
||||
|
||||
|
||||
def _gamut_refs_for_type(test_type):
|
||||
"""按测试类型返回需要导出的参考色域列表。"""
|
||||
if test_type == "sdr_movie":
|
||||
@@ -70,7 +85,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)
|
||||
fig.savefig(path, dpi=300)
|
||||
_save_with_light_background(fig, path, dpi=300)
|
||||
log(f"已保存: {per_ref_name}")
|
||||
finally:
|
||||
ref_var.set(original_ref)
|
||||
@@ -82,7 +97,7 @@ def save_result_images(result_dir, current_test_type, selected_items,
|
||||
continue
|
||||
path = os.path.join(result_dir, filename)
|
||||
if default_bbox:
|
||||
fig.savefig(path, dpi=300)
|
||||
_save_with_light_background(fig, path, dpi=300)
|
||||
else:
|
||||
fig.savefig(path, dpi=300, bbox_inches="tight")
|
||||
_save_with_light_background(fig, path, dpi=300, bbox_inches="tight")
|
||||
log(f"已保存: {filename}")
|
||||
|
||||
Reference in New Issue
Block a user