summaryrefslogtreecommitdiff
path: root/src/util.c
blob: bd4b7b8c4d5d14b73b523e66360a43e65c3b533c (plain)
1
2
3
4
5
6
7
8
9
10
11
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);
}