9 int main(int argc, char **argv)
17 fprintf(stderr, "missing argument: output name\n");
21 if(!(buf = malloc(strlen(argv[1]) + 4))) {
22 perror("malloc failed");
25 sprintf(buf, "%s.img", argv[1]);
27 if(!(fp = fopen(buf, "wb"))) {
28 perror("failed to open output file");
34 printf("image: %dx%d\n", width, height);
35 for(i=0; i<height; i++) {
36 for(j=0; j<NBPL; j++) {
38 unsigned char out = 0;
39 for(k=0; k<width; k++) {
40 out = (out << 1) | ((src[k] >> bit) & 1);
50 sprintf(buf, "%s.pal", argv[1]);
51 if(!(fp = fopen(buf, "wb"))) {
52 perror("failed to open palette output file");
59 for(i=0; i<palsz; i++) {
60 int r = header_data_cmap[i][0] >> 4;
61 int g = header_data_cmap[i][1] >> 4;
62 int b = header_data_cmap[i][2] >> 4;
63 unsigned int col = ((r & 0xf) << 8) | ((g & 0xf) << 4) | (b & 0xf);
64 printf("0x%03x\n", col);