FloatImg/funcs/t.c

82 lines
1.7 KiB
C

/*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pam.h>
#include "../floatimg.h"
/* --------------------------------------------------------------------- */
int essai_parse_double(void)
{
int foo;
double dval;
char *str;
str = "12.34"; dval = 0.0;
foo = parse_double(str, &dval);
printf("%-10s -> %3d %g\n", str, foo, dval);
str = "12e4"; dval = 0.0;
foo = parse_double(str, &dval);
printf("%-10s -> %3d %g\n", str, foo, dval);
str = "5s"; dval = 0.0;
foo = parse_double(str, &dval);
printf("%-10s -> %3d %g\n", str, foo, dval);
str = "PORN"; dval = 0.0;
foo = parse_double(str, &dval);
printf("%-10s -> %3d %g\n", str, foo, dval);
return 0;
}
/* --------------------------------------------------------------------- */
int essai_detect_type(void)
{
int foo;
char *fname;
foo = format_from_extension(fname="foo.fimg");
printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.pNm");
printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.xyzzy");
printf("%-10s %d\n\n", fname, foo);
return 0;
}
/* --------------------------------------------------------------------- */
int essai_ecrire_png(char *fname)
{
FloatImg fimg;
int foo;
fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
for (foo=0; foo<512; foo++) {
fimg_plot_rgb(&fimg, foo, foo, 17000.0, 8000.0, 11111.1);
}
fimg_save_as_pnm(&fimg, "quux.pnm", 0);
foo = fimg_save_as_png(&fimg, fname, 0);
return 0;
}
/* --------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
puts("++++++++++++++++++++++++++++++++");
foo = essai_ecrire_png("dessin.png");
return 0;
}
/* --------------------------------------------------------------------- */