Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | |
| 4 | int 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 Mower | fb1c4ff | 2014-04-16 13:43:36 -0500 | [diff] [blame] | 11 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 12 | 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 Mower | fb1c4ff | 2014-04-16 13:43:36 -0500 | [diff] [blame] | 26 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 27 | 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 { |
| 38 | eject: |
| 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 | } |