add dummy image output

This commit is contained in:
Bruno BELANYI 2020-11-10 16:40:06 +01:00
parent 5c071adb8c
commit 232dbbeb35

View file

@ -1,6 +1,29 @@
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include "image.h"
#include "ppm.h"
int main(void) {
return 0;
static void fill_image(struct image *image) {
for (size_t i = 0; i < image->h; ++i) {
for (size_t j = 0; j < image->w; ++j) {
struct pixel *p = &image->buf[i * image->w + j];
p->r = 255 * i / image->h;
p->g = 255 * j / image->w;
p->g = 255 * (i + j) / (image->h + image->w);
}
}
}
int main(void) {
struct image *image = create_image(960, 540);
if (!image)
err(EXIT_FAILURE, "could not allocate image");
fill_image(image);
print_ppm(image, stdout);
destroy_image(image);
return EXIT_SUCCESS;
}