diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-14 13:39:03 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-14 13:39:38 +0100 |
commit | e0a2d71eb4aa821428a86b97a03b083f227f524c (patch) | |
tree | 73e42f18f5810462407fab609192e79947214a30 | |
parent | 00abf3e6113704676d8ca0262d9e5d73c8af5969 (diff) | |
download | advtime-e0a2d71eb4aa821428a86b97a03b083f227f524c.tar.gz advtime-e0a2d71eb4aa821428a86b97a03b083f227f524c.tar.bz2 advtime-e0a2d71eb4aa821428a86b97a03b083f227f524c.zip |
Add util.c
-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_ */ |