/* * FLOATIMG * rotation matricielle des images * #coronamaison Mon 23 Mar 2020 11:45:59 AM CET */ #include #include #include "../floatimg.h" extern int verbosity; /* --------------------------------------------------------------------- */ int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused) { int foo; int x, y; float rgb[3]; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, notused); #endif 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) ) { fprintf(stderr, "in %s, %p is empty\n", __func__, dst); /* 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; } if (verbosity) fimg_describe(dst, "new pic"); } /* 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; yheight; y++) { for (x=0; xwidth; x++) { fimg_get_rgb(src, x, y, rgb); fimg_plot_rgb(dst, y, x, rgb[0], rgb[1], rgb[2]); } } /* we don't have any cleanup to make */ return 0; } /* --------------------------------------------------------------------- */