7 int main(int argc, char ** argv)
12 puts("Fallout 1 AAF converter");
13 puts("Converts INPUT.AAF file into set of PGM images");
14 printf("\n\tUsage: %s INPUT\n\n", argv[0]);
18 struct aaf_glyph_data ** glyph_data = NULL;
21 in = fopen(argv[1], "r");
23 perror("Unable to open file for conversion");
27 if (read_aaf(in, &_aaf) != 0) {
28 fprintf(stderr, "Problem occured when trying to read AAF file\n");
33 glyph_data = read_aaf_glyph_data(in, &_aaf);
34 if (glyph_data == NULL) {
35 fprintf(stderr, "Problem occured when trying to read AAF glyph data\n");
40 for (i = 0; i < AAF_GLYPH_MAX; i++) {
41 const struct aaf_glyph * glyph = &(_aaf.glyphs[i]);
42 const struct aaf_glyph_data * data = glyph_data[i];
46 'F', 'O', 'N', 'T', '-', '0', '0', '0', '.', 'P', 'G', 'M'
49 if ((glyph->w * glyph->h) == 0) {
54 filename[5] = i / 100 + '0';
57 filename[6] = (i % 100) / 10 + '0';
60 filename[7] = i % 10 + '0';
63 out = fopen(filename, "w");
65 perror("Unable to open file for writing glyph");
66 free_aaf_glyph_data(glyph_data);
71 if (write_aaf_glyph_as_pgm(out, glyph, data)) {
72 fprintf(stderr, "Error occured when trying to write glyph into PGM\n");
74 free_aaf_glyph_data(glyph_data);
81 free_aaf_glyph_data(glyph_data);