2020-03-24 19:31:52 +11:00
|
|
|
/*
|
|
|
|
* FLOATIMG
|
|
|
|
* rotation matricielle des images
|
|
|
|
* #coronamaison Mon 23 Mar 2020 11:45:59 AM CET
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#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-03-24 19:31:52 +11:00
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
extern int verbosity;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused)
|
|
|
|
{
|
|
|
|
int foo;
|
2021-03-09 21:55:48 +11:00
|
|
|
int x, y, k;
|
2020-03-24 19:31:52 +11:00
|
|
|
float rgb[3];
|
|
|
|
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
|
|
|
|
src, dst, notused);
|
|
|
|
#endif
|
|
|
|
|
2022-07-06 19:27:55 +11:00
|
|
|
if (notused) fprintf(stderr, "notused %d in %s\n", notused, __func__);
|
|
|
|
|
2020-03-24 19:31:52 +11:00
|
|
|
if (src->type != FIMG_TYPE_RGB) {
|
|
|
|
fprintf(stderr, "%s: src type %d not valid\n", __func__,
|
|
|
|
src->type);
|
|
|
|
return -6;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if dst pic is not allocated */
|
|
|
|
if ( 0 == (dst->type | dst->width | dst->height) ) {
|
2020-03-24 20:41:57 +11:00
|
|
|
#if DEBUG_LEVEL
|
2020-03-24 19:31:52 +11:00
|
|
|
fprintf(stderr, "in %s, %p is empty\n", __func__, dst);
|
2020-03-24 20:41:57 +11:00
|
|
|
#endif
|
2020-03-24 19:31:52 +11:00
|
|
|
/* OK allocate a new fpic */
|
|
|
|
foo = fimg_create(dst, src->height, src->width, src->type);
|
|
|
|
if (foo) {
|
|
|
|
fprintf(stderr, "%s: err %d create new pic\n", __func__, foo);
|
|
|
|
return -887;
|
|
|
|
}
|
2020-07-07 03:08:18 +11:00
|
|
|
// if (verbosity>1) fimg_describe(dst, "new pic");
|
2020-03-24 19:31:52 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check if dst and src are conpatibles */
|
|
|
|
if ( (src->type != dst->type) ||
|
|
|
|
(src->width != dst->height) || (src->height != dst->width) ) {
|
|
|
|
fprintf(stderr, "%s: src & dst not compatibles\n", __func__);
|
|
|
|
return -888;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* THIS IS A CRUDE IMPLEMENTATION
|
|
|
|
*/
|
|
|
|
for (y=0; y<src->height; y++) {
|
|
|
|
for (x=0; x<src->width; x++) {
|
|
|
|
fimg_get_rgb(src, x, y, rgb);
|
2021-03-09 21:55:48 +11:00
|
|
|
// XXX ??? j = (dst->height - x) - 1;
|
2020-07-05 04:32:33 +11:00
|
|
|
k = (dst->width - y) - 1;
|
|
|
|
#if DEBUG_LEVEL > 1
|
|
|
|
fprintf(stderr, "%6d %6d\n", k, j);
|
|
|
|
#endif
|
|
|
|
fimg_put_rgb(dst, k, x, rgb);
|
2020-03-24 19:31:52 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we don't have any cleanup to make */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|