From 622d0114245bf397c5fc503f6ebb8b1fc6de3ac5 Mon Sep 17 00:00:00 2001 From: Tonton Th Date: Fri, 7 Feb 2020 18:01:28 +0100 Subject: [PATCH] added fimg_killcolors_a effect --- floatimg.h | 7 ++++++- funcs/Makefile | 5 ++++- funcs/sfx0.c | 37 +++++++++++++++++++++++++++++++++++++ funcs/t.c | 26 ++++++++++++++++++++++++-- 4 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 funcs/sfx0.c diff --git a/floatimg.h b/floatimg.h index 272c059..1967db0 100644 --- a/floatimg.h +++ b/floatimg.h @@ -2,7 +2,7 @@ * floatimg.h */ -#define FIMG_VERSION 88 +#define FIMG_VERSION 89 /* * in memory descriptor @@ -75,6 +75,11 @@ int fimg_mul_3(FloatImg *a, FloatImg *b, FloatImg *d); int fimg_minimum(FloatImg *a, FloatImg *b, FloatImg *d); int fimg_maximum(FloatImg *a, FloatImg *b, FloatImg *d); + +/* 'sfx0' module */ +int fimg_killcolors_a(FloatImg *fimg, float fval); + + /* PNM files module */ int fimg_save_as_pnm(FloatImg *head, char *fname, int flags); int fimg_load_from_pnm(char *fname, FloatImg *head, int notused); diff --git a/funcs/Makefile b/funcs/Makefile index 55fa0fe..10ab591 100644 --- a/funcs/Makefile +++ b/funcs/Makefile @@ -3,7 +3,7 @@ COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0 DEPS = ../floatimg.h Makefile OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ - fimg-libpnm.o rampes.o + fimg-libpnm.o rampes.o sfx0.o #--------------------------------------------------------------- @@ -30,6 +30,9 @@ misc-plots.o: misc-plots.c $(DEPS) filtrage.o: filtrage.c $(DEPS) gcc $(COPT) -c $< +sfx0.o: sfx0.c $(DEPS) + gcc $(COPT) -c $< + rampes.o: rampes.c $(DEPS) gcc $(COPT) -c $< diff --git a/funcs/sfx0.c b/funcs/sfx0.c new file mode 100644 index 0000000..d602691 --- /dev/null +++ b/funcs/sfx0.c @@ -0,0 +1,37 @@ +/* + * FLOATIMG + * rampes diverses, trucs etranges + */ + +#include + +#include "../floatimg.h" + +/* --------------------------------------------------------------------- */ +/* + * OMG ! a Color Graphic Adaptor emulator :) + */ +int fimg_killcolors_a(FloatImg *fimg, float fval) +{ +int nbpix, foo; + +if (FIMG_TYPE_RGB != fimg->type) { + fprintf(stderr, "%s: bad src type %d on %p\n", __func__, + fimg->type, fimg); + return -8; + } + +nbpix = fimg->width * fimg->height; + +for (foo=0; fooR[foo] > fimg->G[foo]) + fimg->B[foo] = fimg->R[foo]; + else + fimg->B[foo] = fimg->G[foo]; + + } + +return 0; +} +/* --------------------------------------------------------------------- */ diff --git a/funcs/t.c b/funcs/t.c index 8e33468..b6eff52 100644 --- a/funcs/t.c +++ b/funcs/t.c @@ -10,6 +10,25 @@ int verbosity; +int fimg_killcolors_a(FloatImg *fimg, float fval); + +/* --------------------------------------------------------------------- */ +int essai_sfx0(char *infile) +{ +FloatImg fimg; +int foo; + +fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB); + +fimg_draw_something(&fimg); +foo = fimg_save_as_pnm(&fimg, "something.pnm", 0); + +foo = fimg_killcolors_a(&fimg, 0.0); + +foo = fimg_save_as_pnm(&fimg, "colorskilled.pnm", 0); + +return 0; +} /* --------------------------------------------------------------------- */ int essai_parse_double(void) { @@ -44,7 +63,10 @@ char *fname; foo = format_from_extension(fname="foo.fimg"); printf("%-10s %d\n\n", fname, foo); -foo = format_from_extension(fname="foo.pNm"); +foo = format_from_extension(fname="foo.pnm"); +printf("%-10s %d\n\n", fname, foo); + +foo = format_from_extension(fname="foo.png"); printf("%-10s %d\n\n", fname, foo); foo = format_from_extension(fname="foo.xyzzy"); @@ -103,7 +125,7 @@ int foo; puts("++++++++++++++++++++++++++++++++"); -foo = essai_rampes(); +foo = essai_sfx0(NULL); return 0; }