diff options
Diffstat (limited to 'crawl-ref/source/rltiles/tool/tile_convert.cc')
-rw-r--r-- | crawl-ref/source/rltiles/tool/tile_convert.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/crawl-ref/source/rltiles/tool/tile_convert.cc b/crawl-ref/source/rltiles/tool/tile_convert.cc new file mode 100644 index 0000000000..b65518cfb2 --- /dev/null +++ b/crawl-ref/source/rltiles/tool/tile_convert.cc @@ -0,0 +1,49 @@ +#include <stdio.h> +#include <string.h> + +// This is a standalone utility to convert old-style palettized BMPs +// to transparent PNGs. + +#include "tile.h" + +int main(int argc, char **argv) +{ + if (argc < 2) + { + printf("Usage: %s (filename.bmp)\n", argv[0]); + return -1; + } + + char dest[1024]; + strcpy(dest, argv[1]); + + size_t len = strlen(dest); + if (strcmp(&dest[len-4], ".bmp")) + { + printf("File '%s' does not end in bmp.\n", argv[1]); + return -2; + } + + dest[len-3] = 'p'; + dest[len-2] = 'n'; + dest[len-1] = 'g'; + + tile conv; + if (!conv.load(argv[1])) + { + printf("Failed to load '%s'.\n", argv[1]); + return -3; + } + + conv.replace_colour(tile_colour::background, tile_colour::transparent); + + if (!write_png(dest, &conv.get_pixel(0,0), conv.width(), conv.height())) + { + printf("Failed to write dest '%s'.\n", dest); + return -4; + } + + printf("Converted '%s'.\n", argv[1]); + + return 0; +} |