From f08f860daaab45df1c46393e457ed7021256dabb Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 5 Oct 2021 00:35:56 +0200 Subject: [PATCH] killrgb: nice try, but... --- Fonderie/t.c | 3 ++- floatimg.h | 3 ++- funcs/Makefile | 2 +- funcs/killrgb.c | 42 ++++++++++++++++++++++++++++++++++++++++++ funcs/t.c | 6 +++++- funcs/tests.c | 31 +++++++++++++++++++++++++++++++ funcs/tests.h | 1 + 7 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 funcs/killrgb.c diff --git a/Fonderie/t.c b/Fonderie/t.c index 1a22ed9..07d5b39 100644 --- a/Fonderie/t.c +++ b/Fonderie/t.c @@ -170,7 +170,8 @@ fprintf(stderr, "EXPERIMENT\n"); foo = fimg_create_from_dump("01137.fimg", &image); if (foo) { - fprintf(stderr, "%s: err %d on create\n", __func__, foo); + fprintf(stderr, "%s: err %d on create_from_dump\n", + __func__, foo); return -1; } diff --git a/floatimg.h b/floatimg.h index 7d207b9..b863536 100644 --- a/floatimg.h +++ b/floatimg.h @@ -4,7 +4,7 @@ * http://la.buvette.org/photos/cumul */ -#define FIMG_VERSION 153 +#define FIMG_VERSION 154 /* * in memory descriptor @@ -133,6 +133,7 @@ int fimg_sfx_triplemul(FloatImg *s, FloatImg *d, int notused); /* #coronamaison */ int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused); +int fimg_killrgb_v(FloatImg *src, FloatImg *dst, int k); /* universal exporter XXX */ int fimg_export_picture(FloatImg *pic, char *fname, int flags); diff --git a/funcs/Makefile b/funcs/Makefile index 2a0d439..09e44b9 100644 --- a/funcs/Makefile +++ b/funcs/Makefile @@ -13,7 +13,7 @@ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ equalize.o fimg-fits.o saturation.o histogram.o \ hsv.o classif.o contour2x2.o qsortrgb.o exporter.o \ displacement.o dithering.o plasmas.o incrustator.o \ - recurse.o + killrgb.o recurse.o #--------------------------------------------------------------- diff --git a/funcs/killrgb.c b/funcs/killrgb.c new file mode 100644 index 0000000..2c8e1bf --- /dev/null +++ b/funcs/killrgb.c @@ -0,0 +1,42 @@ +/* + * KILL RGB ! + * + * nouveau TerreBlanque 4 octobre 2021 + */ + +#include +#include +#include +#include + +#include "../floatimg.h" +#include "tests.h" + +/* --------------------------------------------------------------------- */ + +int fimg_killrgb_v(FloatImg *src, FloatImg *dst, int k) +{ +int foo, line, col; +int ir, ig, ib; + +fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, + src, dst, k); + +fimg_clear(dst); + +ir = ig = ib = 0; + +for (line=0; lineheight; line++) { + for (col=0; colwidth; col+=3) { + + dst->R[ir ] = src->R[ir]; ir++; + dst->G[ir+1] = src->G[ir]; ir++; + dst->B[ir+2] = src->B[ir]; ir++; + + } + } + +return 0; +} + +/* --------------------------------------------------------------------- */ diff --git a/funcs/t.c b/funcs/t.c index 59948a0..56dbf9d 100644 --- a/funcs/t.c +++ b/funcs/t.c @@ -23,7 +23,7 @@ float global_fvalue; enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff, Histo, Hsv, Classif, Ctr2x2, Qsortrgb, Displace, ReadPNG, Plasmas, Hilight, OpenEXR, - Geometrie, FileType, Mirror }; + Geometrie, FileType, Mirror, KillRGB }; typedef struct { char *name; int Cmd; @@ -51,6 +51,7 @@ Command commands[] = { { "geometrie", Geometrie, }, { "filetype", FileType }, { "mirror", Mirror }, + { "killrgb", KillRGB }, { NULL, 0 } } ; @@ -216,6 +217,9 @@ switch(opt) { case Mirror: foo = essai_miroir(filename, outfile, 0); break; + case KillRGB: + foo = essai_killrgb(filename, outfile); + break; default: fprintf(stderr, "'%s' is a bad command\n", command); exit(1); diff --git a/funcs/tests.c b/funcs/tests.c index 8882205..e5dead9 100644 --- a/funcs/tests.c +++ b/funcs/tests.c @@ -17,6 +17,37 @@ extern int verbosity; +/* --------------------------------------------------------------------- */ +int essai_killrgb(char *inf, char *outf) +{ +int foo; +FloatImg src, dst; + +fprintf(stderr, ">>> %s ( %s %s )\n", __func__, inf, outf); + +foo = fimg_create_from_dump(inf, &src); +if (0 != foo) { + fprintf(stderr, "%s: err %d loading image '%s'\n", __func__, + foo, inf); + return foo; + } +fimg_clone(&src, &dst, 1); + +foo = fimg_killrgb_v(&src, &dst, 0); +if (foo) { + fprintf(stderr, "%s:%s(): fail %d line %d\n", + __FILE__, __func__, foo, __LINE__); + return foo; + } + +foo = fimg_export_picture(&dst, outf, 0); +if (foo) { + fprintf(stderr, "%s : err %d saving result\n", __func__, foo); + return foo; + } + +return 0; +} /* --------------------------------------------------------------------- */ int fimg_recursion_proto(FloatImg *src, FloatImg *dst, int notused); diff --git a/funcs/tests.h b/funcs/tests.h index e8ce240..5dbbde4 100644 --- a/funcs/tests.h +++ b/funcs/tests.h @@ -5,6 +5,7 @@ int essai_plasma(char *infile, char *outfile, int ikoef, float fkoef); int essai_miroir(char *inf, char *outf, int flags); +int essai_killrgb(char *inf, char *outf); int essai_displacement(char *infile, char *outfile); int essai_qsort_rgb(char *infile, char *outfile);