diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/util.c | 12 | ||||
-rw-r--r-- | src/util.h | 7 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..bd4b7b8 --- /dev/null +++ b/src/util.c @@ -0,0 +1,12 @@ +void +pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, char *filename) +{ + FILE *f; + int i; + + f = fopen(filename, "w"); + fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255); + for(i=0; i < ysize; i++) + fwrite(buf + i * wrap, 1, xsize, f); + fclose(f); +} diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..a58585e --- /dev/null +++ b/src/util.h @@ -0,0 +1,7 @@ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +void +pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, char *filename); + +#endif /* _UTIL_H_ */ |