summaryrefslogtreecommitdiff
path: root/img2map
diff options
context:
space:
mode:
authoresquizo <esquizo+noreply@esquizo.net>2026-05-02 14:55:03 -0300
committeresquizo <esquizo+noreply@esquizo.net>2026-05-02 14:55:03 -0300
commit2416783679eafe35aea7af15bf1308a6895e251a (patch)
treef3d08269b9dff0eeedff8312e4b96b99169652ff /img2map
parentd2d0886cf770488d1b4890a3a414bbf983e784a6 (diff)
mapa arbitrário a partir de uma imagem
Diffstat (limited to 'img2map')
-rwxr-xr-ximg2map21
1 files changed, 21 insertions, 0 deletions
diff --git a/img2map b/img2map
new file mode 100755
index 0000000..d9e7e78
--- /dev/null
+++ b/img2map
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+import sys
+from PIL import Image
+
+img = Image.open(sys.argv[1]).convert('1')
+width, height = img.size
+
+print(f"int map_width = {width};")
+print(f"int map_height = {height};")
+print("char map_data[] = {")
+
+for y in range(height):
+ linha = []
+ for x in range(width):
+ pixel = img.getpixel((x, y))
+ valor = '0' if pixel == 0 else '1'
+ linha.append(valor)
+ print(f" {', '.join(linha)},")
+
+print("};")