diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2010-02-13 00:49:06 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2010-02-13 00:49:06 +0000 |
commit | 2de8808ff45e8a8bf73cd6c6fd7379b76c318491 (patch) | |
tree | 6850612851563efc399bfa7cd65a39a1567f3d6d /palette2c.c | |
parent | 40e60828463a7762c3da9995812803374bca0cf1 (diff) | |
download | librosprite-2de8808ff45e8a8bf73cd6c6fd7379b76c318491.tar.gz librosprite-2de8808ff45e8a8bf73cd6c6fd7379b76c318491.tar.bz2 |
Merge imported librosprite onto trunk
svn path=/trunk/librosprite/; revision=10029
Diffstat (limited to 'palette2c.c')
-rw-r--r-- | palette2c.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/palette2c.c b/palette2c.c new file mode 100644 index 0000000..bbe272c --- /dev/null +++ b/palette2c.c @@ -0,0 +1,48 @@ +/* + * This file is part of librosprite. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2008 James Shaw <js102@zepler.net> + */ + +#include <stdio.h> +#include <stdlib.h> + +#include "librosprite.h" + +int main(int argc, char *argv[]) +{ + if (argc < 2) { + printf("Usage: palette2c palettefile\n"); + exit(EXIT_FAILURE); + } + + char* filename = argv[1]; + + FILE* f = fopen(filename, "rb"); + if (f == NULL) { + printf("Can't load palettefile %s\n", filename); + exit(EXIT_FAILURE); + } + + struct rosprite_file_context* ctx; + if (rosprite_create_file_context(f, &ctx) != ROSPRITE_OK) { + exit(EXIT_FAILURE); + } + + struct rosprite_palette* palette; + if (rosprite_load_palette(rosprite_file_reader, ctx, &palette) != ROSPRITE_OK) { + exit(EXIT_FAILURE); + } + + for (uint32_t i = 0; i < palette->size; i++) { + printf("0x%x, ", palette->palette[i]); + } + + fclose(f); + + rosprite_destroy_file_context(ctx); + rosprite_destroy_palette(palette); + + return EXIT_SUCCESS; +} |