blob: 058b4450f2d746a07f8d503a51eec16feb278b2d (
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
|
#include "pgm.h"
#include <stdio.h>
#include <stdlib.h>
int pgm_write_header(FILE *fp, unsigned int w, unsigned int h)
{
return fprintf(fp, "P3\n%d %d\n255\n", w, h);
}
int pgm_write_pixel(FILE *fp, color_t *c)
{
return fprintf(fp, "%d %d %d\n", c->r, c->g, c->b);
}
color_t *color_set(color_t *c, uint8_t r, uint8_t g, uint8_t b)
{
if (!c) {
c = (color_t *) malloc(sizeof(c));
}
c->r = r;
c->g = g;
c->b = b;
return c;
}
|