37 lines
951 B
C
37 lines
951 B
C
/*
|
|
* fractal
|
|
* Written in 2020 by Lucas
|
|
* CC0 1.0 Universal/Public domain - No rights reserved
|
|
*
|
|
* To the extent possible under law, the author(s) have dedicated all
|
|
* copyright and related and neighboring rights to this software to the
|
|
* public domain worldwide. This software is distributed without any
|
|
* warranty. You should have received a copy of the CC0 Public Domain
|
|
* Dedication along with this software. If not, see
|
|
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "palette.h"
|
|
#include "pnmout.h"
|
|
#include "util.h"
|
|
|
|
void
|
|
pnmout_header(FILE *fp, unsigned int width, unsigned int height)
|
|
{
|
|
if (fprintf(fp, "P6\n%u %u 255\n", width, height) < 0)
|
|
err(1, "fprintf");
|
|
}
|
|
|
|
void
|
|
pnmout_pixel(FILE *fp, struct color c)
|
|
{
|
|
uint8_t v[3];
|
|
v[0] = c.r / 256;
|
|
v[1] = c.g / 256;
|
|
v[2] = c.b / 256;
|
|
if (fwrite(v, sizeof(v[0]), sizeof(v) / sizeof(v[0]), fp) != 3)
|
|
err(1, "fwrite");
|
|
}
|