aboutsummaryrefslogtreecommitdiffstats
path: root/wr/write-ppm.c
diff options
context:
space:
mode:
authorkraxel <kraxel>2004-03-28 11:31:57 +0000
committerkraxel <kraxel>2004-03-28 11:31:57 +0000
commite9e9684117719204929821028ba9dbb7915ea119 (patch)
tree6dd2d71940b33a9f960945335e9124ef4fea9fe7 /wr/write-ppm.c
downloadfbida-e9e9684117719204929821028ba9dbb7915ea119.tar.gz
Initial revision
Diffstat (limited to 'wr/write-ppm.c')
-rw-r--r--wr/write-ppm.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/wr/write-ppm.c b/wr/write-ppm.c
new file mode 100644
index 0000000..d16035b
--- /dev/null
+++ b/wr/write-ppm.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "readers.h"
+#include "writers.h"
+#include "viewer.h"
+
+/* ---------------------------------------------------------------------- */
+/* save */
+
+static int
+ppm_write(FILE *fp, struct ida_image *img)
+{
+ fprintf(fp,"P6\n"
+ "# written by ida " VERSION "\n"
+ "# http://bytesex.org/ida/\n"
+ "%d %d\n255\n",
+ img->i.width,img->i.height);
+ fwrite(img->data, img->i.height, 3*img->i.width, fp);
+ return 0;
+}
+
+static struct ida_writer ppm_writer = {
+ label: "PPM",
+ ext: { "ppm", NULL},
+ write: ppm_write,
+};
+
+static void __init init_wr(void)
+{
+ write_register(&ppm_writer);
+}