+ upside-down

This commit is contained in:
2020-12-18 10:18:09 +01:00
parent 0def451bf4
commit d369babbb3
6 changed files with 66 additions and 6 deletions

View File

@@ -18,6 +18,58 @@
*/
extern int verbosity;
/* -------------------------------------------------------------- */
/* nouveau du 19 decembre 2020, pour le grand ecran de da Scritch */
int upside_down(FloatImg *pimg)
{
float *rowpix;
float *Ps, *Pd;
int Os, Od; /* offset of lines */
int wsz;
int ya, y2;
fprintf(stderr, "%s: image width is %d\n", __func__, pimg->width);
rowpix = calloc(pimg->width, sizeof(float));
if (NULL==rowpix) {
fprintf(stderr, "%s : memory full\n", __func__);
exit(1);
}
wsz = pimg->width * sizeof(float);
fprintf(stderr, "%s: wsx = %d\n", __func__, wsz);
for (ya=0; ya<pimg->height/2; ya++) {
y2 = pimg->height - (ya+1);
Os = (pimg->width * ya);
Od = (pimg->width * y2);
/* let's go, crash coredumping... */
Ps = pimg->R + Os;
Pd = pimg->R + Od;
memcpy(rowpix, Ps, wsz);
memcpy(Ps, Pd, wsz);
memcpy(Pd, rowpix, wsz);
Ps = pimg->G + Os;
Pd = pimg->G + Od;
memcpy(rowpix, Ps, wsz);
memcpy(Ps, Pd, wsz);
memcpy(Pd, rowpix, wsz);
Ps = pimg->B + Os;
Pd = pimg->B + Od;
memcpy(rowpix, Ps, wsz);
memcpy(Ps, Pd, wsz);
memcpy(Pd, rowpix, wsz);
}
free(rowpix);
return 0;
}
/* -------------------------------------------------------------- */
/* nouveau du 9 decembre 2020, en ecoutant le Fermion raconter du
superbe portnawak */
@@ -113,7 +165,7 @@ return 0;
int trinarize(FloatImg *pimg, int notused)
{
float mm[6], mRa, mGa, mBa, mRb, mGb, mBb;
float val, *fptr;
float *fptr;
int foo, size;
#if DEBUG_LEVEL