From 2416783679eafe35aea7af15bf1308a6895e251a Mon Sep 17 00:00:00 2001 From: esquizo Date: Sat, 2 May 2026 14:55:03 -0300 Subject: mapa arbitrário a partir de uma imagem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- img2map | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 img2map (limited to 'img2map') 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("};") -- cgit v1.2.3