This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user