Sprite Sheet Conversion

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

When I was an OP games developer in the early 1980s, we pretty much used oddball file formats. I'm struggling to remember, but I think Paint Shop Pro had a format I used. I had to write conversion software to read files of PSP format and convert them into various graphics formats for the game. It was a major pain.

I recall using one frame of animation per file - which wqs obviously inefficient. I did later find out that other companies were using 'sprite sheets' - a single image with all the animations on a single image. Towards the end of my professional life as a games developer, I did write some software to isolate those individual frames and alllow me to use sprite sheets as source data.

Anyway, I'm back to doing that - putting multiple frames in a single image and then processing that image to produce individual frames. They're culled out of the sprite sheet by virtue of them being surrounded by black pixels. That's enough to allow fairly simple code to detect them.  BITD I did this with a flood fill. These days I can ask an AI to do it for me, and tweak things.

The attached code does just that - given input file(s) it will separate out the individual sprites in those files, and do a few things with them.

1) write new image files containing each sprite into a temp directory
1b) Convert the image files from source format (up to 24bpp) into 8-colour iCC format.
2) append the sprite metadata (frame name, center point, height) to a manifest.txt file
3) create C structures with the graphics data in chronocolour format (with masks!)
4) Create C and asm structures to reference this data
5) Include center point information from the manifest file into C structures

It's all pretty cool - the manifest is persistent, and the tool detects if you're reprocessing the same image file. If you are, it will preserve the center point information and frame name information that's in the manifest.  So you can reference frames with sensible names (such as WALK_0) instead of some random name.

It basically means when I add or modify frames I go to my graphics editor (GIMP), make the changes, save the file, go back to VSCodium (my IDE) and hit build.... and the changes are there, including new frames immediately accessible. It's pretty cool and saves heaps of time.

I expect nobody will be interested, but it's a cool tool so I thought I'd share. Note that this is not professionally coded, in that it's very much a quick and dirty hack. Most tools are like that, right?