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