2021-06-01 09:44:48 +02:00
|
|
|
/*
|
|
|
|
* FLOATIMG - a kluge from tTh
|
|
|
|
* ---------------------------
|
|
|
|
*
|
|
|
|
* some strange effects on floating pictures, made in
|
|
|
|
* the batcave of "Le Bib", in Montpellier.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdint.h>
|
2022-03-19 01:21:58 +01:00
|
|
|
#include <sys/time.h>
|
2021-06-01 09:44:48 +02:00
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
extern int verbosity;
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------- */
|
|
|
|
int fimg_crump_hard(FloatImg *src, FloatImg *dst, float kval, int notused)
|
|
|
|
{
|
|
|
|
float halfval;
|
|
|
|
float rgb[3];
|
|
|
|
int x, y, foo;
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, ">>> %s ( %p %p %f 0x%04x )\n", __func__,
|
|
|
|
src, dst, kval, notused);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
halfval = fimg_get_maxvalue(src) / 2.0;
|
2021-06-01 10:03:09 +02:00
|
|
|
if (verbosity > 1) {
|
2021-06-01 09:44:48 +02:00
|
|
|
fprintf(stderr, "%s: halfval=%f\n", __func__, halfval);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y=0; y<src->height; y++) {
|
|
|
|
for (x=0; x<src->width; x++) {
|
|
|
|
foo = fimg_get_rgb(src, x, y, rgb);
|
|
|
|
if (foo) return foo;
|
|
|
|
|
|
|
|
if (rgb[0] > halfval) rgb[0] /= 2.0;
|
|
|
|
if (rgb[1] > halfval) rgb[1] /= 2.0;
|
|
|
|
if (rgb[2] > halfval) rgb[2] /= 2.0;
|
|
|
|
|
|
|
|
foo = fimg_put_rgb(dst, x, y, rgb);
|
|
|
|
if (foo) return foo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* -------------------------------------------------------------- */
|
|
|
|
|