modularizing the crapulator

This commit is contained in:
Tonton Th 2020-11-04 10:41:21 +01:00
parent f9a09871bf
commit 905022e782
1 changed files with 40 additions and 21 deletions

View File

@ -10,6 +10,44 @@
#include "fonctions.h"
#include "crapulator.h"
/* -------------------------------------------------------------- */
/* support function for the crapulator */
static int effect_3(FloatImg *image)
{
float value;
int foo;
value = fimg_get_maxvalue(image);
fimg_mul_cste(image, -1.0);
fimg_add_cste(image, value);
foo = fimg_count_negativ(image);
if (foo) {
fimg_dump_to_file(image, "err.fimg", 0);
fprintf(stderr, "%s negativ %d\n",
__func__, foo);
return -78;
}
return 0;
}
/* -------------------------------------------------------------- */
static int insitu_ctr2x2(FloatImg *pimg)
{
FloatImg img;
int retval;
fimg_clone(pimg, &img, 0);
// XXX fimg_clear(&img);
retval = fimg_contour_2x2(pimg, &img, 0);
if (retval) {
fprintf(stderr, "%s : err contour %d\n",
__func__, retval);
exit(1);
}
fimg_copy_data(&img, pimg);
fimg_destroy(&img);
return 0;
}
/* -------------------------------------------------------------- */
/*
* This is the main filter engine
@ -21,7 +59,6 @@ int retval, foo;
FloatImg imgtmp;
static int count = 0;
int flag_debug = 0;
float value;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %f )\n", __func__,
@ -49,16 +86,7 @@ switch (idFx) {
fimg_get_maxvalue(image));
break;
case 3:
value = fimg_get_maxvalue(image);
fimg_mul_cste(image, -1.0);
fimg_add_cste(image, value);
foo = fimg_count_negativ(image);
if (foo) {
fimg_dump_to_file(image, "err.fimg", 0);
fprintf(stderr, "%s negativ %d\n",
__func__, foo);
return -78;
}
retval = effect_3(image);
break;
case 4:
brotche_rand48_a(image, 0.20,
@ -77,16 +105,7 @@ switch (idFx) {
break;
case 8:
fimg_clone(image, &imgtmp, 0);
fimg_clear(&imgtmp);
retval = fimg_contour_2x2(image, &imgtmp, 0);
if (retval) {
fprintf(stderr, "%s : err contour %d\n",
__func__, retval);
exit(1);
}
fimg_copy_data(&imgtmp, image);
fimg_destroy(&imgtmp);
retval = insitu_ctr2x2(image);
break;
case 9: