forked from tTh/FloatImg
enhancing the test proggy
This commit is contained in:
parent
7809e33e55
commit
5564b24c54
7
Makefile
7
Makefile
@ -1,6 +1,7 @@
|
||||
|
||||
# Before running make, you must have
|
||||
# a look to the 'build.sh' script !
|
||||
####################################################
|
||||
# Before running make, you must have #
|
||||
# a look to the 'build.sh' script ! #
|
||||
####################################################
|
||||
|
||||
COPT = -Wall -fpic -g -pg -DDEBUG_LEVEL=0
|
||||
LDOPT = libfloatimg.a -pg -lm
|
||||
|
6
build.sh
6
build.sh
@ -1,23 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd lib
|
||||
echo EEEEEEEEEE we are in $PWD
|
||||
echo ============= we are in $PWD
|
||||
make
|
||||
error=$?
|
||||
if [ 0 -ne $error ]; then
|
||||
printf "in %s err %d in %s\n" $PWD $error $0
|
||||
exit $error
|
||||
fi
|
||||
echo
|
||||
cd ..
|
||||
|
||||
cd funcs
|
||||
echo EEEEEEEEEE we are in $PWD
|
||||
echo ============= we are in $PWD
|
||||
make
|
||||
error=$?
|
||||
if [ 0 -ne $error ]; then
|
||||
printf "in %s err %d in %s\n" $PWD $error $0
|
||||
exit $error
|
||||
fi
|
||||
echo
|
||||
cd ..
|
||||
|
||||
cd tools
|
||||
|
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);
|
||||
|
Loading…
Reference in New Issue
Block a user