FloatImg4PythonBinding/lib/t.c

66 lines
1.2 KiB
C
Raw Normal View History

2019-06-29 23:50:03 +02:00
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
2019-08-07 11:55:29 +02:00
#include <string.h>
2019-08-08 17:16:20 +02:00
#include <math.h>
2019-06-29 23:50:03 +02:00
#include "../floatimg.h"
int verbosity;
2019-08-08 17:16:20 +02:00
/* ---------------------------------------------------------------- */
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;
}
/* ---------------------------------------------------------------- */
2019-08-10 18:37:52 +02:00
#define W 4000
#define H 3000
2019-06-29 23:50:03 +02:00
int main(int argc, char *argv[])
{
int foo;
2019-08-08 17:16:20 +02:00
FloatImg dessin, noise, result;
2019-07-08 06:28:04 +02:00
int datas[3];
2019-06-29 23:50:03 +02:00
2019-08-08 17:16:20 +02:00
verbosity = 1;
2019-08-07 11:55:29 +02:00
2019-08-08 17:16:20 +02:00
fimg_print_version(1);
2019-06-29 23:50:03 +02:00
2019-08-10 18:37:52 +02:00
foo = fimg_create(&dessin, W, H, 3);
2019-08-08 17:16:20 +02:00
petit_dessin(&dessin);
fimg_save_as_pnm(&dessin, "dessin.pnm", 0);
2019-06-29 23:50:03 +02:00
2019-08-10 18:37:52 +02:00
foo = fimg_create(&noise, W, H, 3);
2019-08-08 17:16:20 +02:00
fimg_drand48(&noise, 1.0);
fimg_save_as_pnm(&noise, "noise.pnm", 0);
2019-07-08 06:28:04 +02:00
2019-08-10 18:37:52 +02:00
foo = fimg_create(&result, W, H, 3);
2019-06-29 23:50:03 +02:00
2019-08-08 17:16:20 +02:00
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);
2019-08-07 17:30:16 +02:00
2019-06-29 23:50:03 +02:00
return 0;
2019-07-08 06:28:04 +02:00
}