2020-02-08 04:01:28 +11:00
|
|
|
/*
|
|
|
|
* FLOATIMG
|
2020-02-14 06:44:22 +11:00
|
|
|
* effets spéciaux àlc sur les couleurs
|
2020-02-08 04:01:28 +11:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2020-03-24 19:31:52 +11:00
|
|
|
#include <string.h>
|
2021-05-18 07:38:56 +11:00
|
|
|
#include <stdint.h>
|
2022-03-19 11:21:58 +11:00
|
|
|
#include <sys/time.h>
|
2020-02-08 04:01:28 +11:00
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/*
|
|
|
|
* OMG ! a Color Graphic Adaptor emulator :)
|
|
|
|
*/
|
|
|
|
int fimg_killcolors_a(FloatImg *fimg, float fval)
|
|
|
|
{
|
|
|
|
int nbpix, foo;
|
|
|
|
|
|
|
|
if (FIMG_TYPE_RGB != fimg->type) {
|
|
|
|
fprintf(stderr, "%s: bad src type %d on %p\n", __func__,
|
|
|
|
fimg->type, fimg);
|
|
|
|
return -8;
|
|
|
|
}
|
|
|
|
|
|
|
|
nbpix = fimg->width * fimg->height;
|
|
|
|
for (foo=0; foo<nbpix; foo++) {
|
2022-07-06 19:27:55 +11:00
|
|
|
if ((fimg->R[foo]+fval) > fimg->G[foo])
|
2020-02-08 04:01:28 +11:00
|
|
|
fimg->B[foo] = fimg->R[foo];
|
|
|
|
else
|
|
|
|
fimg->B[foo] = fimg->G[foo];
|
2020-02-08 06:09:03 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2021-03-18 04:32:51 +11:00
|
|
|
/*
|
|
|
|
* parameter fval is not used, why ?
|
|
|
|
*/
|
2020-02-08 06:09:03 +11:00
|
|
|
int fimg_killcolors_b(FloatImg *fimg, float fval)
|
|
|
|
{
|
|
|
|
int nbpix, foo;
|
|
|
|
|
|
|
|
if (FIMG_TYPE_RGB != fimg->type) {
|
|
|
|
fprintf(stderr, "%s: bad src type %d on %p\n", __func__,
|
|
|
|
fimg->type, fimg);
|
|
|
|
return -8;
|
2020-02-08 04:01:28 +11:00
|
|
|
}
|
|
|
|
|
2020-02-08 06:09:03 +11:00
|
|
|
nbpix = fimg->width * fimg->height;
|
|
|
|
for (foo=0; foo<nbpix; foo++) {
|
2022-07-06 19:27:55 +11:00
|
|
|
if ((fimg->R[foo]+fval) > fimg->B[foo])
|
2020-02-08 06:09:03 +11:00
|
|
|
fimg->G[foo] = fimg->R[foo];
|
|
|
|
else
|
|
|
|
fimg->G[foo] = fimg->B[foo];
|
|
|
|
}
|
|
|
|
|
2020-02-08 04:01:28 +11:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2020-06-22 21:15:01 +11:00
|
|
|
int fimg_colors_mixer_a(FloatImg *fimg, float fval)
|
|
|
|
{
|
|
|
|
int nbpix, foo;
|
|
|
|
float R, G, B;
|
|
|
|
|
|
|
|
if (FIMG_TYPE_RGB != fimg->type) {
|
|
|
|
fprintf(stderr, "%s: bad src type %d on %p\n", __func__,
|
|
|
|
fimg->type, fimg);
|
|
|
|
#if MUST_ABORT
|
|
|
|
abort();
|
|
|
|
#endif
|
|
|
|
return -8;
|
|
|
|
}
|
|
|
|
|
|
|
|
nbpix = fimg->width * fimg->height;
|
|
|
|
|
|
|
|
for (foo=0; foo<nbpix; foo++) {
|
|
|
|
|
|
|
|
R = (fimg->G[foo] + fimg->B[foo]) / fval;
|
|
|
|
G = (fimg->R[foo] + fimg->B[foo]) / fval;
|
|
|
|
B = (fimg->R[foo] + fimg->G[foo]) / fval;
|
|
|
|
|
|
|
|
fimg->R[foo] = R;
|
|
|
|
fimg->G[foo] = G;
|
|
|
|
fimg->B[foo] = B;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|