Convert an image into a row of tiles using the GIMP

From Uzebox Wiki
Jump to navigation Jump to search

Overview

If you are writing a game using graphics mode 74, the tile generator c4bppsh.c expects the 8x8 pixel tiles to be input as one horizontal row of tiles, but that isn't likely how you would be drawing any mega sprites ie sprites composed of more than one tile. This guide explains how to at least partly automate the process of converting a GIMP image into a horizontal row of tiles suitable to be input into a tile generator program.

Installation

This process requires the installation of the GIMP guides-grid.scm script and the guillotine-into-layers plug-in. You can download a zip file containing the script and binaries of the plugin for both Linux x64 and Windows from here or here.

After extracting Guillotine_and_guides_GIMP_plugins.zip, Linux users should copy guides-grid.scm into ~/.config/GIMP/2.10/scripts and guillotine-into-layers into ~/.config/GIMP/2.10/plug-ins. You may need to replace 2.10 in those paths with your version of GIMP, if you're running a different version.

If you're running GIMP on an ARM machine or you need to re-build guillotine-into-layers for some other reason you can download the source for the plugin here or here. Under Debian and Ubuntu you will need to have libgimp2.0-dev installed to build the guillotine plugin.

Instructions

Here is a video demonstrating the steps below but using a different X offset value.

When your image is ready to be converted into a row of tiles open Image -> Guides -> Grid and enter the number of horizontal and vertical divisions required.

Next choose Image -> Transform -> Guillotine into layers followed by Layer -> Stack -> Reverse layer order.

In the Tools palette, select the Alignment tool (or just push the q key) then, after zooming as required, drag a box around the current tile/layer to select it which should make some little squares appear on each corner.

In the alignment tool options, ensure Align: relative to is set to image, Offset X should be set to 8 and Offset Y set to 0 then click Distribute right edges of targets, which is the icon with a single arrow pointing to the right within the Distribute icon section of the Alignment tool options.

Finally, choose Image -> Fit canvas to layers and then to get a single layer Image -> Merge Visible layers.

Save your image with a .h file extension using File -> Export As... to produce a header file suitable for use with a tile generator.