diff --git a/funcs/Makefile b/funcs/Makefile index 765f181a..4ae67470 100644 --- a/funcs/Makefile +++ b/funcs/Makefile @@ -1,9 +1,9 @@ #--------------------------------------------------------------- -COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0 +COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=1 DEPS = ../floatimg.h Makefile OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ - fimg-libpnm.o + fimg-libpnm.o rampes.o #--------------------------------------------------------------- @@ -30,5 +30,8 @@ misc-plots.o: misc-plots.c $(DEPS) filtrage.o: filtrage.c $(DEPS) gcc $(COPT) -c $< +rampes.o: rampes.c $(DEPS) + gcc $(COPT) -c $< + utils.o: utils.c $(DEPS) gcc $(COPT) -c $< diff --git a/funcs/rampes.c b/funcs/rampes.c new file mode 100644 index 00000000..1680b0d5 --- /dev/null +++ b/funcs/rampes.c @@ -0,0 +1,62 @@ +/* + * FLOATIMG + * rampes diverses, trucs etranges + */ + +#include + +#include "../floatimg.h" + +/* --------------------------------------------------------------------- */ +int fimg_hdeg_a(FloatImg *img, double dcoef) +{ +int x, y; +float value; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %f )\n", __func__, img, dcoef); +#endif + +if (FIMG_TYPE_RGB != img->type) { + fprintf(stderr, "%s bad type\n", __func__); + return -6; + } + +for (x=0; xwidth; x++) + { + value = (float)x / (float)img->width; + value *= dcoef; + for (y=0; yheight; y++) { + fimg_plot_rgb(img, x, y, value, value, value); + } + } + +return 0; +} +/* --------------------------------------------------------------------- */ +int fimg_vdeg_a(FloatImg *img, double dcoef) +{ +int x, y; +float value; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %f )\n", __func__, img, dcoef); +#endif + +if (FIMG_TYPE_RGB != img->type) { + fprintf(stderr, "%s bad type\n", __func__); + return -6; + } + +for (y=0; yheight; y++) + { + value = (float)y / (float)img->height; + value *= dcoef; + for (x=0; xwidth; x++) { + fimg_plot_rgb(img, x, y, value, value, value); + } + } + +return 0; +} +/* --------------------------------------------------------------------- */ diff --git a/funcs/t.c b/funcs/t.c index 019b7bb4..dbd0e54d 100644 --- a/funcs/t.c +++ b/funcs/t.c @@ -48,6 +48,26 @@ 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_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); + return 0; } /* --------------------------------------------------------------------- */ @@ -81,7 +101,7 @@ int foo; puts("++++++++++++++++++++++++++++++++"); -foo = essai_ecrire_png("dessin.png"); +foo = essai_rampes(); return 0; }