making operators from garbage

This commit is contained in:
2019-08-08 17:16:20 +02:00
parent 6258bd08ed
commit 016497c870
7 changed files with 172 additions and 18 deletions

54
lib/t.c
View File

@@ -2,35 +2,63 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include "../floatimg.h"
int verbosity;
/* ---------------------------------------------------------------- */
int petit_dessin(FloatImg *img)
{
int x, y;
float r, g, b;
for (y=0; y<img->height; y++) {
r = (float)y / (float)img->height;
for (x=0; x<img->width; x++) {
g = (float)x / (float)img->width;
b = 0.0;;
fimg_plot_rgb(img, x, y, r, g, b);
}
}
return -1;
}
/* ---------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
FloatImg fimg;
FloatImg dessin, noise, result;
int datas[3];
char *fname = "foo.fimg";
verbosity = 1;
fimg_print_version(0);
fimg_print_version(1);
foo = fimg_create(&fimg, 640, 480, 3);
printf("retour fimg_create ---> %d\n", foo);
foo = fimg_create(&dessin, 640, 480, 3);
petit_dessin(&dessin);
fimg_save_as_pnm(&dessin, "dessin.pnm", 0);
fimg_printhead(&fimg);
fimg_describe(&fimg, "vroum");
foo = fimg_create(&noise, 640, 480, 3);
fimg_drand48(&noise, 1.0);
fimg_save_as_pnm(&noise, "noise.pnm", 0);
// fimg_save_as_pnm(&fimg, "foo.pnm", 0);
foo = fimg_dump_to_file(&fimg, fname, 0);
foo = fimg_create(&result, 640, 480, 3);
foo = fimg_fileinfos("foo.fimg", datas);
printf("%s : largeur %d hauteur %d type %d\n",
fname, datas[0], datas[1], datas[2]);
foo = fimg_add(&dessin, &noise, &result);
fimg_save_as_pnm(&result, "r_add.pnm", 0);
foo = fimg_sub(&dessin, &noise, &result);
fimg_save_as_pnm(&result, "r_sub.pnm", 0);
foo = fimg_mul(&dessin, &noise, &result);
fimg_save_as_pnm(&result, "r_mul.pnm", 0);
return 0;
}