FloatImg4PythonBinding/essai.c

83 lines
1.6 KiB
C
Raw Normal View History

2019-03-03 16:22:55 +01:00
/*
testing some random funcs.
*/
#include <stdio.h>
#include <stdlib.h>
2021-05-20 09:31:28 +02:00
#include <stdint.h>
2019-04-03 12:09:04 +02:00
#include <unistd.h>
2019-03-03 16:22:55 +01:00
#include <math.h>
#include <string.h>
#include "floatimg.h"
2019-04-03 12:09:04 +02:00
int verbosity;
2019-03-03 16:22:55 +01:00
/* --------------------------------------------------------------------- */
2019-09-02 10:07:56 +02:00
void fait_un_dessin(FloatImg *dessin)
2019-03-03 16:22:55 +01:00
{
2019-09-02 10:07:56 +02:00
fimg_draw_something(dessin);
2019-03-03 16:22:55 +01:00
}
/* --------------------------------------------------------------------- */
2022-04-12 14:15:08 +02:00
void help(void)
2019-04-03 12:09:04 +02:00
{
puts("Options :");
puts("\t-d WxH\timage size");
exit(0);
}
/* --------------------------------------------------------------------- */
2019-03-03 16:22:55 +01:00
int main(int argc, char *argv[])
{
FloatImg fimgA, fimgB;
2019-04-03 12:09:04 +02:00
int foo, opt;
2022-04-12 14:15:08 +02:00
int W = 640, H = 480;
2019-03-03 16:22:55 +01:00
double tb;
2019-04-03 12:09:04 +02:00
while ((opt = getopt(argc, argv, "d:hv")) != -1) {
switch(opt) {
case 'd': parse_WxH(optarg, &W, &H);
break;
2022-04-12 14:15:08 +02:00
case 'h': help(); break;
2019-04-03 12:09:04 +02:00
case 'v': verbosity++; break;
}
}
2019-03-03 16:22:55 +01:00
2019-04-03 12:09:04 +02:00
if (verbosity) fimg_print_version(0);
2019-03-03 16:22:55 +01:00
fimg_create(&fimgA, W, H, 3);
fimg_create(&fimgB, W, H, 3);
2019-09-29 00:09:59 +02:00
fimg_clear(&fimgA);
2019-03-03 16:22:55 +01:00
fimg_drand48(&fimgB, 100.0);
2019-09-29 00:09:59 +02:00
foo = fimg_dump_to_file(&fimgB, "B.fimg", 0);
2019-09-02 10:07:56 +02:00
fimg_timer_set(0);
#define NBP 500
for (foo=0; foo<NBP; foo++) {
if (verbosity) {
printf("%5d / %5d\n", foo, NBP);
}
fait_un_dessin(&fimgB);
fimg_add_3(&fimgA, &fimgB, &fimgA);
2019-09-29 00:09:59 +02:00
// fimg_mul(&fimgA, &fimgB, &fimgA);
2019-09-02 10:07:56 +02:00
}
2019-03-03 16:22:55 +01:00
tb = fimg_timer_get(0);
fprintf(stderr, "%s = %f seconds\n", __func__, tb);
2019-04-03 12:09:04 +02:00
foo = fimg_save_as_pnm(&fimgA, "drand48.pnm", 0);
2019-09-29 00:09:59 +02:00
foo = fimg_dump_to_file(&fimgA, "drand48.fimg", 0);
2019-03-03 16:22:55 +01:00
fimg_destroy(&fimgA);
fimg_destroy(&fimgB);
return 0;
}
/* --------------------------------------------------------------------- */