blob: 409316cb1d9c3116e6c5486a0e8f8a0c866d9875 [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001#include <stdio.h>
2#include <stdlib.h>
3
4int main(int argc, char *argv)
5{
6 unsigned n;
7 unsigned char *x;
8 unsigned m;
9 unsigned run_val;
10 unsigned run_count;
Matt Mowerfb1c4ff2014-04-16 13:43:36 -050011
Dees_Troy51a0e822012-09-05 15:24:24 -040012 n = gimp_image.width * gimp_image.height;
13 m = 0;
14 x = gimp_image.pixel_data;
15
16 printf("struct {\n");
17 printf(" unsigned width;\n");
18 printf(" unsigned height;\n");
19 printf(" unsigned cwidth;\n");
20 printf(" unsigned cheight;\n");
21 printf(" unsigned char rundata[];\n");
22 printf("} font = {\n");
23 printf(" .width = %d,\n .height = %d,\n .cwidth = %d,\n .cheight = %d,\n", gimp_image.width, gimp_image.height,
24 gimp_image.width / 96, gimp_image.height);
25 printf(" .rundata = {\n");
Matt Mowerfb1c4ff2014-04-16 13:43:36 -050026
Dees_Troy51a0e822012-09-05 15:24:24 -040027 run_val = (*x ? 0 : 255);
28 run_count = 1;
29 n--;
30 x+=3;
31
32 while(n-- > 0) {
33 unsigned val = (*x ? 0 : 255);
34 x+=3;
35 if((val == run_val) && (run_count < 127)) {
36 run_count++;
37 } else {
38eject:
39 printf("0x%02x,",run_count | (run_val ? 0x80 : 0x00));
40 run_val = val;
41 run_count = 1;
42 m += 5;
43 if(m >= 75) {
44 printf("\n");
45 m = 0;
46 }
47 }
48 }
49 printf("0x%02x,",run_count | (run_val ? 0x80 : 0x00));
50 printf("\n0x00,");
51 printf("\n");
52 printf(" }\n};\n");
53 return 0;
54}