action
All checks were successful
Deploy WebSocket Server / deploy (push) Successful in 18s

This commit is contained in:
jeremygan2021
2026-03-05 20:56:21 +08:00
parent 6a64c54cae
commit a784c88c60
5 changed files with 108 additions and 10 deletions

View File

@@ -70,13 +70,13 @@ def image_to_tspl_commands(image_path):
for x in range(target_width):
pixel = img.getpixel((x, y))
should_print = False
# 修正逻辑:用户反馈打印出来是负片(黑底白字),说明原有的判断反了。
# 我们现在采用完全相反的逻辑。
# 之前的逻辑: if pixel != 0: should_print = True (导致背景被打印)
# 现在的逻辑: if pixel == 0: should_print = True (即 0(黑)打印255(白)不打印)
# 逻辑修正:
# 我们希望 黑色像素(0) -> 打印(1)
# 白色像素(255) -> 不打印(0)
# 使用 < 128 判定,增加容错性,防止像素值偏移
if pixel == 0:
should_print = False
if pixel < 128: # Black or Dark Gray
should_print = True
if should_print: