enhancing the test proggy
This commit is contained in:
67
essai.c
67
essai.c
@@ -5,11 +5,14 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "floatimg.h"
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int add(FloatImg *a, FloatImg *b)
|
||||
{
|
||||
@@ -51,43 +54,63 @@ fprintf(stderr, "%s = %f seconds\n", __func__, tb);
|
||||
puts("");
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int parse_WxH(char *str, int *pw, int *ph)
|
||||
{
|
||||
// char *ptr;
|
||||
int foo, w, h;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' %p %p )\n", __func__,
|
||||
str, pw, ph);
|
||||
#endif
|
||||
|
||||
foo = sscanf(str, "%dx%d", &w, &h);
|
||||
if (2 != foo) {
|
||||
fprintf(stderr, "%s : arg '%s' is invalid\n", __func__, str);
|
||||
return foo;
|
||||
}
|
||||
|
||||
*pw = w; *ph = h;
|
||||
|
||||
return 2;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
void help(int k)
|
||||
{
|
||||
puts("Options :");
|
||||
puts("\t-d WxH\timage size");
|
||||
exit(0);
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FloatImg fimgA, fimgB;
|
||||
int foo;
|
||||
int foo, opt;
|
||||
int W = 800, H = 600;
|
||||
double tb;
|
||||
|
||||
fimg_print_version(0);
|
||||
while ((opt = getopt(argc, argv, "d:hv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'd': parse_WxH(optarg, &W, &H);
|
||||
break;
|
||||
case 'h': help(0); break;
|
||||
case 'v': verbosity++; break;
|
||||
}
|
||||
}
|
||||
|
||||
#define W 2000
|
||||
#define H 1700
|
||||
|
||||
fait_un_dessin("dessin.fimg");
|
||||
if (verbosity) fimg_print_version(0);
|
||||
|
||||
fimg_create(&fimgA, W, H, 3);
|
||||
fimg_create(&fimgB, W, H, 3);
|
||||
|
||||
fimg_draw_something(&fimgA);
|
||||
|
||||
fimg_timer_set(0);
|
||||
fimg_drand48(&fimgB, 100.0);
|
||||
fimg_drand48(&fimgA, 100.0);
|
||||
add(&fimgA, &fimgB);
|
||||
tb = fimg_timer_get(0);
|
||||
fprintf(stderr, "%s = %f seconds\n", __func__, tb);
|
||||
|
||||
foo = fimg_save_as_pnm(&fimgB, "drand48.pnm", 0);
|
||||
|
||||
/*
|
||||
fimg_printhead(&fimgA); fimg_printhead(&fimgB);
|
||||
fimg_describe(&fimgA, "image A");
|
||||
*/
|
||||
|
||||
add(&fimgA, &fimgB);
|
||||
|
||||
foo = fimg_save_as_pnm(&fimgA, "t.pnm", 0);
|
||||
fprintf(stderr, "save as pnm -> %d\n", foo);
|
||||
foo = fimg_dump_to_file(&fimgA, "t.fimg", 0);
|
||||
fprintf(stderr, "save as fimg -> %d\n", foo);
|
||||
foo = fimg_save_as_pnm(&fimgA, "drand48.pnm", 0);
|
||||
|
||||
fimg_destroy(&fimgA);
|
||||
fimg_destroy(&fimgB);
|
||||
|
||||
Reference in New Issue
Block a user