X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=retrocrawl;a=blobdiff_plain;f=tools%2Fconv_gimp.c;fp=tools%2Fconv_gimp.c;h=b124d37e8d48196b637804108730ffae6c42ca3b;hp=0000000000000000000000000000000000000000;hb=87c45ef8c82a3925719cbf2024e5932208b244ce;hpb=bba694e9bc50fb24ffe4b3c8f7b5d33f01b3ea4d diff --git a/tools/conv_gimp.c b/tools/conv_gimp.c new file mode 100644 index 0000000..b124d37 --- /dev/null +++ b/tools/conv_gimp.c @@ -0,0 +1,71 @@ +#include +#include +#include + +#include HDRFILE + +#define NBPL 5 + +int main(int argc, char **argv) +{ + int i, j, k, palsz; + FILE *fp; + char *buf; + unsigned char *src; + + if(!argv[1]) { + fprintf(stderr, "missing argument: output name\n"); + return 1; + } + + if(!(buf = malloc(strlen(argv[1]) + 4))) { + perror("malloc failed"); + return 1; + } + sprintf(buf, "%s.img", argv[1]); + + if(!(fp = fopen(buf, "wb"))) { + perror("failed to open output file"); + return 1; + } + + src = header_data; + + printf("image: %dx%d\n", width, height); + for(i=0; i> bit) & 1); + if((k & 7) == 7) { + fputc(out, fp); + } + } + } + src += width; + } + fclose(fp); + + sprintf(buf, "%s.pal", argv[1]); + if(!(fp = fopen(buf, "wb"))) { + perror("failed to open palette output file"); + return 1; + } + + palsz = 1 << NBPL; + + printf("palette:\n"); + for(i=0; i> 4; + int g = header_data_cmap[i][1] >> 4; + int b = header_data_cmap[i][2] >> 4; + unsigned int col = ((r & 0xf) << 8) | ((g & 0xf) << 4) | (b & 0xf); + printf("0x%03x\n", col); + fputc(col >> 8, fp); + fputc(col, fp); + } + fclose(fp); + + return 0; +}