FloatImg4PythonBinding/lib/t.c

80 lines
1.4 KiB
C

#include <stdio.h>
#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 essai_2gray(FloatImg *picz, char *outname)
{
return -1;
}
/* ---------------------------------------------------------------- */
#define W 4000
#define H 3000
int main(int argc, char *argv[])
{
int foo;
FloatImg dessin, noise, result;
int datas[3];
verbosity = 1;
fimg_print_version(1);
foo = fimg_create(&dessin, W, H, 3);
petit_dessin(&dessin);
fimg_save_as_pnm(&dessin, "dessin.pnm", 0);
foo = fimg_create(&noise, W, H, 3);
fimg_drand48(&noise, 1.0);
fimg_save_as_pnm(&noise, "noise.pnm", 0);
foo = fimg_create(&result, W, H, 3);
foo = fimg_add(&dessin, &noise, &result);
fimg_save_as_pnm(&result, "r_add.pnm", 0);
essai_2gray(&result, "gray.pnm");
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;
}