2019-09-12 19:48:12 +02:00
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <pam.h>
|
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
2019-10-30 15:49:53 +01:00
|
|
|
int essai_parse_double(void)
|
2019-09-12 19:48:12 +02:00
|
|
|
{
|
|
|
|
int foo;
|
2019-09-16 12:28:47 +02:00
|
|
|
double dval;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
str = "12.34"; dval = 0.0;
|
|
|
|
foo = parse_double(str, &dval);
|
|
|
|
printf("%-10s -> %3d %g\n", str, foo, dval);
|
2019-09-12 19:48:12 +02:00
|
|
|
|
2019-09-16 12:28:47 +02:00
|
|
|
str = "12e4"; dval = 0.0;
|
|
|
|
foo = parse_double(str, &dval);
|
|
|
|
printf("%-10s -> %3d %g\n", str, foo, dval);
|
2019-09-12 19:48:12 +02:00
|
|
|
|
2019-09-16 12:28:47 +02:00
|
|
|
str = "5s"; dval = 0.0;
|
|
|
|
foo = parse_double(str, &dval);
|
|
|
|
printf("%-10s -> %3d %g\n", str, foo, dval);
|
2019-09-13 14:34:56 +02:00
|
|
|
|
2019-09-16 12:28:47 +02:00
|
|
|
str = "PORN"; dval = 0.0;
|
|
|
|
foo = parse_double(str, &dval);
|
|
|
|
printf("%-10s -> %3d %g\n", str, foo, dval);
|
2019-09-12 19:48:12 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2019-10-30 15:49:53 +01:00
|
|
|
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);
|
|
|
|
|
2020-01-03 15:39:11 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int essai_rampes(void)
|
|
|
|
{
|
|
|
|
FloatImg fimg;
|
|
|
|
int foo;
|
|
|
|
|
|
|
|
fimg_create(&fimg, 640, 480, FIMG_TYPE_RGB);
|
|
|
|
|
|
|
|
foo = fimg_hdeg_a(&fimg, (double)3.141592654);
|
|
|
|
fprintf(stderr, "make h deg -> %d\n", foo);
|
|
|
|
foo = fimg_save_as_pnm(&fimg, "hdeg.pnm", 0);
|
|
|
|
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
|
|
|
|
|
|
|
|
foo = fimg_vdeg_a(&fimg, (double)3.141592654);
|
|
|
|
fprintf(stderr, "make h deg -> %d\n", foo);
|
|
|
|
foo = fimg_save_as_pnm(&fimg, "vdeg.pnm", 0);
|
|
|
|
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
|
|
|
|
|
2019-12-13 18:18:07 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int essai_ecrire_png(char *fname)
|
|
|
|
{
|
|
|
|
FloatImg fimg;
|
|
|
|
int foo;
|
|
|
|
|
|
|
|
fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB);
|
2019-12-31 12:02:37 +01:00
|
|
|
|
|
|
|
fimg_draw_something(&fimg);
|
|
|
|
|
|
|
|
/* XXX
|
2019-12-13 18:18:07 +01:00
|
|
|
for (foo=0; foo<512; foo++) {
|
|
|
|
fimg_plot_rgb(&fimg, foo, foo, 17000.0, 8000.0, 11111.1);
|
|
|
|
}
|
2019-12-31 12:02:37 +01:00
|
|
|
*/
|
2019-12-13 18:18:07 +01:00
|
|
|
|
2019-12-31 12:02:37 +01:00
|
|
|
foo = fimg_save_as_pnm(&fimg, "quux.pnm", 0);
|
|
|
|
fprintf(stderr, "save as pnm -> %d\n", foo);
|
2019-12-13 18:18:07 +01:00
|
|
|
|
|
|
|
foo = fimg_save_as_png(&fimg, fname, 0);
|
2019-12-31 12:02:37 +01:00
|
|
|
fprintf(stderr, "save as png -> %d\n", foo);
|
2019-12-13 18:18:07 +01:00
|
|
|
|
2019-10-30 15:49:53 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
|
2019-12-13 18:18:07 +01:00
|
|
|
puts("++++++++++++++++++++++++++++++++");
|
|
|
|
|
2020-01-03 15:39:11 +01:00
|
|
|
foo = essai_rampes();
|
2019-10-30 15:49:53 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|