Bibliothèque de traitements d'images en virgule flottante. http://la.buvette.org/photos/cumul/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FloatImg/Fonderie/glitches.c

55 lines
1.2 KiB

/*
* glitches.c
*/
#include <stdio.h>
#include <stdlib.h>
#include "../floatimg.h"
extern int verbosity;
/* -------------------------------------------------------------- */
int kill_a_random_line(FloatImg *pvictime, float fval, int bits)
{
int line, xpos, offset;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pvictime, bits);
#endif
line = rand() % pvictime->height;
if (verbosity > 1) {
fprintf(stderr, "%s: try to kill line %d\n", __func__, line);
}
offset = pvictime->width * line;
2 years ago
for (xpos=0; xpos<pvictime->width; xpos++) {
if (bits & 1) pvictime->R[offset+xpos] = fval;
else pvictime->R[offset+xpos] = 0.0;
if (bits & 2) pvictime->G[offset+xpos] = fval;
else pvictime->G[offset+xpos] = 0.0;
if (bits & 4) pvictime->B[offset+xpos] = fval;
else pvictime->B[offset+xpos] = 0.0;
}
return 0;
}
/* -------------------------------------------------------------- */
int kill_a_few_lines(FloatImg *who, float fval, int number)
{
int idx, foo;
/* Frag the pixels */
for (idx=0; idx<number; idx++) {
foo = kill_a_random_line(who, fval, rand() & 0x0f);
if (foo) abort();
}
return foo;
}
/* -------------------------------------------------------------- */