From 5845ab796290b0f3d14b95ab36576cfefaec26bd Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 19 Oct 2021 03:56:56 +0200 Subject: [PATCH] is _clear_rectangle working ? --- Fonderie/sfx.c | 8 ++------ floatimg.h | 4 +++- funcs/rectangle.c | 8 +++++++- funcs/t.c | 7 ++++++- funcs/tests.c | 25 +++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Fonderie/sfx.c b/Fonderie/sfx.c index a826eaa6..cff425fb 100644 --- a/Fonderie/sfx.c +++ b/Fonderie/sfx.c @@ -54,14 +54,10 @@ static int pixel_trinitron(FloatImg *pimg, int pos[4], float *fvals) { int x, y, pline, off; +fimg_clear_rectangle(pimg, pos); + for (y=pos[1]; ywidth; -#if 0 - for (x=0; x<(pos[0]+pos[2]); x++) { - off = pline + x; - pimg->R[off]=pimg->G[off]=pimg->B[off]=0.0; - } -#endif for (x=pos[0]+2; x<(pos[0]+pos[2]-2); x++) { off = pline + x; /* wtf i'm doing here ? */ diff --git a/floatimg.h b/floatimg.h index d8364807..2de8bd4c 100644 --- a/floatimg.h +++ b/floatimg.h @@ -4,7 +4,7 @@ * http://la.buvette.org/photos/cumul */ -#define FIMG_VERSION 158 +#define FIMG_VERSION 160 /* * in memory descriptor @@ -108,6 +108,7 @@ typedef struct { int fimg_killborders(FloatImg *img); int fimg_lissage_2x2(FloatImg *img); +int fimg_show_filter(char *title, FimgFilter3x3 *filtr); int fimg_filter_3x3(FloatImg *s, FloatImg *d, FimgFilter3x3 *filtr); @@ -248,6 +249,7 @@ int parse_rectangle(char *str, FimgArea51 *r, int notused); int format_from_extension(char *fname); char * extension_from_format(int fmt); +int fimg_clear_rectangle(FloatImg *pimg, int rect[4]); diff --git a/funcs/rectangle.c b/funcs/rectangle.c index 83da1743..b835c6d2 100644 --- a/funcs/rectangle.c +++ b/funcs/rectangle.c @@ -6,6 +6,8 @@ #include #include #include +#include + #include #include "../floatimg.h" @@ -23,7 +25,11 @@ fprintf(stderr, ">>> %s ( %p %p )\n", __func__, pi, coo); for (line=0; linewidth + coo[0]; - fprintf(stderr, "line %d off %d\n", line, off); + // fprintf(stderr, "line %3d off %8d\n", line, off); + /* Kaboum ! */ + memset(pi->R + off, 0, coo[2]*sizeof(float)); + memset(pi->G + off, 0, coo[2]*sizeof(float)); + memset(pi->B + off, 0, coo[2]*sizeof(float)); } return -1; diff --git a/funcs/t.c b/funcs/t.c index 58826467..ad767f0c 100644 --- a/funcs/t.c +++ b/funcs/t.c @@ -24,7 +24,7 @@ enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff, Histo, Hsv, Classif, Ctr2x2, Qsortrgb, Displace, ReadPNG, Plasmas, Hilight, OpenEXR, Geometrie, FileType, Mirror, KillRGB, - Pixelize,SplitLevel,DecompRgbz }; + Pixelize,SplitLevel,DecompRgbz, Rectangle }; typedef struct { char *name; int Cmd; @@ -56,6 +56,7 @@ Command commands[] = { { "pixelize", Pixelize }, { "spltlvl", SplitLevel }, { "decomprgbz", DecompRgbz }, + { "rectangle", Rectangle }, { NULL, 0 } } ; @@ -233,6 +234,10 @@ switch(opt) { case DecompRgbz: foo = essai_decomprgb(filename, outfile); break; + case Rectangle: + essai_rectangle(outfile, 0); + break; + default: fprintf(stderr, "'%s' is a bad command\n", command); exit(1); diff --git a/funcs/tests.c b/funcs/tests.c index eaee9a05..6ff3e503 100644 --- a/funcs/tests.c +++ b/funcs/tests.c @@ -17,6 +17,31 @@ extern int verbosity; +/* --------------------------------------------------------------------- */ +int essai_rectangle(char *outf, int k) +{ +FloatImg img; +int foo; +int rect[4]; + +foo = fimg_create(&img, 320, 240, FIMG_TYPE_RGB); + +fimg_drand48(&img, 1.0); + +rect[0] = 100; rect[1] = 100; +rect[2] = 32; rect[3] = 16; + +foo = fimg_clear_rectangle(&img, rect); + +foo = fimg_export_picture(&img, outf, 0); +if (foo) { + fprintf(stderr, "%s : err %d saving result\n", __func__, foo); + return foo; + } + +fimg_destroy(&img); +return 0; +} /* --------------------------------------------------------------------- */ int essai_killrgb(char *inf, char *outf) {