From 360459d93870fb5f4088ca23519be4b92512310e Mon Sep 17 00:00:00 2001 From: tonton Th Date: Fri, 3 Jan 2020 15:39:11 +0100 Subject: [PATCH] two nice bw sweeepsss --- funcs/Makefile | 7 ++++-- funcs/rampes.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ funcs/t.c | 22 +++++++++++++++++- 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 funcs/rampes.c diff --git a/funcs/Makefile b/funcs/Makefile index 765f181..4ae6747 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 0000000..1680b0d --- /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 019b7bb..dbd0e54 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; }