diff options
Diffstat (limited to 'wr/write-ppm.c')
-rw-r--r-- | wr/write-ppm.c | 34 |
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); +} |