+ line shifter and bla

This commit is contained in:
2020-12-31 00:46:12 +01:00
parent af1a48f149
commit 864c8d2d05
8 changed files with 73 additions and 15 deletions

View File

@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../floatimg.h"
@@ -188,4 +189,48 @@ for (y=BB; y<h-BB; y++) {
return 0;
}
/* -------------------------------------------------------------- */
static void shifter(float *fs, float *fd, int w, int nbr)
{
int krkr;
for (krkr=0; krkr<nbr; krkr++) {
fd[krkr] = fs[(krkr+w)%nbr];
}
/* take your sixpack, film at 11 */
}
int multilines_shift_0(FloatImg *picz, int step, int nombre)
{
float *buffline, *sptr;
int idx, ypos;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d )\n", __func__, picz, step, nombre);
#endif
buffline = alloca(picz->width * sizeof(float));
if (NULL==buffline) {
fprintf(stderr, "%s: memory panic\n", __func__);
abort();
}
for (idx=0; idx<nombre; idx++) {
ypos = rand() % picz->height;
sptr = picz->R + (ypos * picz->width);
shifter(sptr, buffline, step, picz->width);
memcpy(sptr, buffline, picz->width*sizeof(float));
sptr = picz->G + (ypos * picz->width);
shifter(sptr, buffline, step, picz->width);
memcpy(sptr, buffline, picz->width*sizeof(float));
sptr = picz->B + (ypos * picz->width);
shifter(sptr, buffline, step, picz->width);
memcpy(sptr, buffline, picz->width*sizeof(float));
}
return 0;
}
/* -------------------------------------------------------------- */