MCPcopy Create free account
hub / github.com/NetHack/NetHack / fopen_ppm_file

Function fopen_ppm_file

win/share/ppmwrite.c:47–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47boolean
48fopen_ppm_file(const char *filename, const char *type)
49{
50 int i;
51
52 if (strcmp(type, WRBMODE)) {
53 Fprintf(stderr, "using writing routine for non-writing?\n");
54 return FALSE;
55 }
56 ppm_file = fopen(filename, type);
57 if (ppm_file == (FILE *) 0) {
58 Fprintf(stderr, "cannot open ppm file %s\n", filename);
59 return FALSE;
60 }
61
62 if (!colorsinmainmap) {
63 Fprintf(stderr, "no colormap set yet\n");
64 return FALSE;
65 }
66
67 tiles_across = 20;
68 curr_tiles_across = 0;
69 PpmScreen.Width = 20 * TILE_X;
70
71 tiles_down = 0;
72 PpmScreen.Height = 0; /* will be rewritten later */
73
74 write_header();
75
76 image = (pixel **) alloc(TILE_Y * sizeof(pixel *));
77 for (i = 0; i < TILE_Y; i++) {
78 image[i] = (pixel *) alloc(PpmScreen.Width * sizeof(pixel));
79 }
80
81 return TRUE;
82}
83
84boolean
85write_ppm_tile(pixel (*pixels)[TILE_X])

Callers 1

mainFunction · 0.85

Calls 2

write_headerFunction · 0.85
allocFunction · 0.50

Tested by

no test coverage detected