-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
33 lines (28 loc) · 832 Bytes
/
test.py
File metadata and controls
33 lines (28 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from PIL import Image
width, height = 3, 3
# Beispiel: Deine Liste mit n = width * height Einträgen
# (Hier nur Demo, du hast sie wahrscheinlich schon)
data = [0, 1, 2, 3, 4, 5, 0, 1, 2]
data = [i % 6 for i in range(width * height)] # Beispiel
# Farbzuordnung (0–5)
colors = {
0: (255, 0, 0), # Rot
1: (0, 255, 0), # Grün
2: (0, 0, 255), # Blau
3: (255, 255, 0), # Gelb
4: (255, 0, 255), # Magenta
5: (0, 255, 255) # Cyan
}
# Neues RGB-Bild anlegen
img = Image.new("RGB", (width, height))
pixels = img.load()
# Jeden Pixel gemäß Liste setzen
index = 0
for y in range(height):
for x in range(width):
color_index = data[index]
pixels[x, y] = colors[color_index]
index += 1
# Ergebnis anzeigen oder speichern
img.show()
# img.save("colored_output.png")