From 2b8ebc514854fdd0cf90bb84163ce9dba140ada6 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 25 Apr 2023 21:02:11 +0800 Subject: [PATCH] 1 --- test.py | 9 +++++++++ test1.py | 21 +++++++++++++++++++++ test2.py | 10 ++++++++++ test3.py | 15 +++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 test.py create mode 100644 test1.py create mode 100644 test2.py create mode 100644 test3.py diff --git a/test.py b/test.py new file mode 100644 index 0000000..3e5da23 --- /dev/null +++ b/test.py @@ -0,0 +1,9 @@ +import json +with open("/tmp/map.json") as f: + cmap = json.load(f) + c = 0 + for y in range(1080): + for x in range(1920): + if str(c) not in cmap: + print(f"{c=} {x=} {y=}") + c+=1 diff --git a/test1.py b/test1.py new file mode 100644 index 0000000..2da2175 --- /dev/null +++ b/test1.py @@ -0,0 +1,21 @@ +import PIL.Image +im = PIL.Image.open("/tmp/1.png") +im = im.convert("RGB") +c = 0 +mapping = {} +mapping1 = {} +for y in range(1080): + for x in range(1920): + r, g, b = im.getpixel((x, y)) + rc = (r << 16) + (g << 8) + b + #assert c == rc, f"c={c:#08x} rc={rc:#08x} {r=} {g=} {b=}" + assert type(rc) == int + mapping[rc] = c + mapping1[c] = rc + c += 1 + +import json +with open("/tmp/map.json", "w") as f: + json.dump(mapping, f) +with open("/tmp/map1.json", "w") as f: + json.dump(mapping1, f) diff --git a/test2.py b/test2.py new file mode 100644 index 0000000..d34aaae --- /dev/null +++ b/test2.py @@ -0,0 +1,10 @@ +import PIL.Image +import subprocess +im = PIL.Image.new("RGB", (1920, 1080)) +c = 0 +for y in range(1080): + for x in range(1920): + im.putpixel((x, y), (c >> 16, c >> 8 & 0xff, c & 0xff)) + c += 1 +im.save("/tmp/1.png") +subprocess.run(["ffplay", "-fs", "/tmp/1.png"]) diff --git a/test3.py b/test3.py new file mode 100644 index 0000000..337faac --- /dev/null +++ b/test3.py @@ -0,0 +1,15 @@ +import PIL.Image +import subprocess +import random +im = PIL.Image.new("RGB", (1920, 1080)) +c = 0x000000 +color = (255, 255, 255) +if 0: + if c % 256 == 0: + color = (random.randint(0, 256), random.randint(0, 256), random.randint(0, 256)) +for x in range(16): + for y in range(16): + im.putpixel((x+16*8*2, y+16*0), color) + c += 1 +im.save("/tmp/1.png") +subprocess.run(["ffplay", "-fs", "/tmp/1.png"])