summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-14 13:39:03 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-14 13:39:38 +0100
commite0a2d71eb4aa821428a86b97a03b083f227f524c (patch)
tree73e42f18f5810462407fab609192e79947214a30 /src
parent00abf3e6113704676d8ca0262d9e5d73c8af5969 (diff)
downloadadvtime-e0a2d71eb4aa821428a86b97a03b083f227f524c.tar.gz
advtime-e0a2d71eb4aa821428a86b97a03b083f227f524c.tar.bz2
advtime-e0a2d71eb4aa821428a86b97a03b083f227f524c.zip
Add util.c
Diffstat (limited to 'src')
-rw-r--r--src/util.c12
-rw-r--r--src/util.h7
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_ */