blob: 1bb1f53d8291c3c3e72d7393a03841f9ac400eba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <stdio.h>
#include <stdlib.h>
#include <stddef.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"
"# https://www.kraxel.org/blog/linux/fbida/\n"
"%d %d\n255\n",
img->i.width,img->i.height);
fwrite(ida_image_scanline(img, 0),
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);
}
|