diff options
| author | esquizo <esquizo+noreply@esquizo.net> | 2026-05-02 14:55:03 -0300 |
|---|---|---|
| committer | esquizo <esquizo+noreply@esquizo.net> | 2026-05-02 14:55:03 -0300 |
| commit | 2416783679eafe35aea7af15bf1308a6895e251a (patch) | |
| tree | f3d08269b9dff0eeedff8312e4b96b99169652ff /img2map | |
| parent | d2d0886cf770488d1b4890a3a414bbf983e784a6 (diff) | |
mapa arbitrário a partir de uma imagem
Diffstat (limited to 'img2map')
| -rwxr-xr-x | img2map | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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("};") |
