diff --git a/funcs/sfx4.c b/funcs/sfx4.c index 5b14e3b1..1e4da9b8 100644 --- a/funcs/sfx4.c +++ b/funcs/sfx4.c @@ -83,4 +83,38 @@ for(idx=0; idx>> %s ( %p %p 0x%04x )\n", __func__, src, dst, notused); +#endif + +if (fimg_images_not_compatible(src, dst)) { + fprintf(stderr, "%s : compatibility error\n", __func__); + return -8; + } + +fimg_clear(dst); + +ow = src->width / 3; +for (y=0; yheight; y++) { + for (x=0; xwidth/3; x++) { + r = g = b = 0.0; + for (sh=0; sh<3; sh++) { + foo = fimg_get_rgb(src, (x*3)+sh, y, in); + r+=in[0], g+=in[1], b+=in[2]; + } + for (sh=0; sh<3; sh++) { + fimg_plot_rgb(dst, x, y, r, 0, 0); + fimg_plot_rgb(dst, x+ow, y, 0, g, 0); + fimg_plot_rgb(dst, x+(2*ow), y, 0, 0, b); + } + } + } + +return 0; +} /* -------------------------------------------------------------- */ diff --git a/funcs/t.c b/funcs/t.c index 025f52bb..d0d21257 100644 --- a/funcs/t.c +++ b/funcs/t.c @@ -26,7 +26,7 @@ enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff, Geometrie, FileType, Mirror, KillRGB, Pixelize,SplitLevel, DecompRgbz, DecompRgbg, Rectangle, Dicom, Fakolor0, Fakolor3, - Fmorpho0, Fluffy, ThermoCol }; + Fmorpho0, Fluffy, ThermoCol, TriPtyq }; typedef struct { char *name; int Cmd; @@ -66,6 +66,7 @@ Command commands[] = { { "fmorpho0", Fmorpho0 }, { "fluffy", Fluffy }, { "thermocol", ThermoCol }, + { "triptyq", TriPtyq }, { NULL, 0 } } ; @@ -271,6 +272,10 @@ switch(opt) { foo = essai_thermocol(filename, outfile); fprintf(stderr, "retour thermocolor = %d\n", foo); break; + case TriPtyq: + foo = essai_triptyq(filename, outfile); + fprintf(stderr, "retour triptyq = %d\n", foo); + break; default: fprintf(stderr, "'%s' is a bad command\n", command); diff --git a/funcs/tests.c b/funcs/tests.c index 2797abd7..5b279fed 100644 --- a/funcs/tests.c +++ b/funcs/tests.c @@ -23,6 +23,39 @@ extern int verbosity; #define W 1024 #define H 768 +/* --------------------------------------------------------------------- */ +/* new Mon Apr 1 15:35:57 UTC 2024 -> sfx4.c */ +int essai_triptyq(char *infile, char *outfile) +{ +FloatImg src, dst; +int idx, foo; + +fprintf(stderr, ">>> %s ( %s %s )\n", __func__, infile, outfile); + +foo = fimg_create_from_dump(infile, &src); +if (0 != foo) { + fprintf(stderr, "%s: err %d loading image '%s'\n", __func__, + foo, infile); + return foo; + } +fimg_clone(&src, &dst, 1); + +foo = fimg_make_triptyq(&src, &dst, 0); +if (0 != foo) { + fprintf(stderr, "%s: make_triptyq -> %d\n", __func__, foo); + return foo; + } + +foo = fimg_export_picture(&dst, outfile, 0); +if (0 != foo) { + fprintf(stderr, "%s: err %d exporting to '%s'\n", __func__, + foo, outfile); + return foo; + } + +return 0; +} + /* --------------------------------------------------------------------- */ /* * nouveau 30 octobre 2022 --> fmorpho.c diff --git a/funcs/tests.h b/funcs/tests.h index 9349d895..e270d2fb 100644 --- a/funcs/tests.h +++ b/funcs/tests.h @@ -31,6 +31,7 @@ int fimg_essai_histo(FloatImg *src, char *outpic, int k); /* histogram.c */ int essai_histogramme(char *fname, int k); int essai_0_fausses_couleurs(char *dstfile, int type); int essai_thermocol(char *infile, char *outfile); +int essai_triptyq(char *infile, char *outfile); int essai_lecture_png(char *fname, char *outfile, int notused);