Converts images to GameBoy tiles
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
img2gb
.gitignore
LICENSE
README.rst
banner.png
img.png
setup.py

README.rst

img2gb - Converts Images to GameBoy Tileset

./banner.png

Dependencies

  • Python 2.7 / 3.5
  • Pillow

Install

From Sources

Clone this repository:

git clone https://github.com/flozz/img2gb.git

Go the the project repository:

cd img2gb

Then install the software (as root):

python setup.py install

From PYPI

Run the following command (as root):

pip install img2gb

Windows Binary

Download the latest img2gb.exe binary here:

and use it from command line:

img2gb.exe -h

Usage

usage: img2gb [-h] [-H HEADER_FILE] [-m] [-d] [-n NAME] image c_file

Converts images to GameBoy tiles

positional arguments:
  image                 Input image file
  c_file                Ouput C File

optional arguments:
  -h, --help            show this help message and exit
  -H HEADER_FILE, --header-file HEADER_FILE
                        Output file for C Header (.h)
  -m, --map             Add tilemap to the .c / .h files
  -d, --deduplicate     Remove duplicated tiles from the tileset
  -n NAME, --name NAME  Name of the tileset (used for variable names in
                        generated code, default=TILESET)

Examples:

img2gb tileset.png tileset.c
img2gb tileset.png tileset.c -H tileset.h
img2gb --deduplicate --name MY_TILESET_01 tileset.png tileset.c -H tileset.h

Example Generated Code

Command:

img2gb --map --name TILESET img.png tileset.c -H tileset.h

img.png:

./img.png

tileset.h:

// This file was generated by img2gb, DO NOT EDIT

#ifndef _TILESET_H
#define _TILESET_H

extern const UINT8 TILESET[];
#define TILESET_TILE_COUNT 97

extern const UINT8 TILESET_MAP[];
#define TILESET_MAP_WIDTH 20
#define TILESET_MAP_HEIGHT 18

#endif

tilset.c (truncated):

// This file was generated by img2gb, DO NOT EDIT

#include <types.h>

const UINT8 TILESET[] = {
    0xFF, 0x00, 0xFF, 0x00, // ...
};

const UINT8 TILESET_MAP[] = {
    0x00, 0x00, 0x00, 0x00, // ...
};

Links

Changelog

  • 0.10.0: Adds non-RGB image support (indexed images,...)
  • 0.9.1: Fixes an issue with Python 3
  • 0.9.0: Initial release (generates tiles, tilesets and tilemaps)