first semi-good run of the Interpolator

This commit is contained in:
le vieux
2020-11-12 23:36:06 +01:00
parent f2e170c7d2
commit bec63e97f5
4 changed files with 151 additions and 28 deletions

View File

@@ -1,18 +1,25 @@
/*
* glitches.c
* ----------
*
* initially developped for the interpolator
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "../floatimg.h"
#include "glitches.h"
extern int verbosity;
/* -------------------------------------------------------------- */
int kill_a_random_line(FloatImg *pvictime, float fval, int bits)
{
int line, xpos, offset;
float ftmp;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pvictime, bits);
@@ -27,11 +34,14 @@ if (verbosity > 1) {
offset = pvictime->width * line;
for (xpos=0; xpos<pvictime->width; xpos++) {
if (bits & 1) pvictime->R[offset+xpos] = fval;
if (bits & 1) { ftmp = pvictime->R[offset+xpos] * fval;
pvictime->R[offset+xpos] = sqrt(ftmp); }
else pvictime->R[offset+xpos] = 0.0;
if (bits & 2) pvictime->G[offset+xpos] = fval;
if (bits & 2) { ftmp = pvictime->G[offset+xpos] * fval;
pvictime->G[offset+xpos] = sqrt(ftmp); }
else pvictime->G[offset+xpos] = 0.0;
if (bits & 4) pvictime->B[offset+xpos] = fval;
if (bits & 4) { ftmp = pvictime->B[offset+xpos] * fval;
pvictime->B[offset+xpos] = sqrt(ftmp); }
else pvictime->B[offset+xpos] = 0.0;
}
@@ -59,7 +69,6 @@ int x, y, off;
/*
* please add boundary check ?
*/
sr = sg = sb = 0.0;
for (y=0; y<8; y++) {
off = xpos + (picture->width * (y+ypos));
@@ -80,7 +89,6 @@ for (y=0; y<8; y++) {
off++;
}
}
return 0;
}
/* -------------------------------------------------------------- */
@@ -88,12 +96,15 @@ int un_moyen_flou_8x8(FloatImg *picture, int xpos, int ypos)
{
int i, j, x, y;
/*
* please add boundary check ?
*/
for (i=y=0; i<8; i++, y+=8) {
for (j=x=0; j<8; j++, x+=8 ) {
un_petit_flou_8x8(picture, x+xpos, y+ypos);
}
}
return -1;
return 0;
}
/* -------------------------------------------------------------- */
int poke_a_random_pixel(FloatImg *picz, float fval, int kaboo)