fix a bug in rotate_90

This commit is contained in:
tonton th 2020-07-04 19:32:33 +02:00
parent 085387aba2
commit b39660cc78
3 changed files with 13 additions and 7 deletions

View File

@ -3,7 +3,7 @@
* ugly code from tTh * ugly code from tTh
*/ */
#define FIMG_VERSION 101 #define FIMG_VERSION 102
/* /*
* in memory descriptor * in memory descriptor

View File

@ -15,7 +15,7 @@ extern int verbosity;
int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused) int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused)
{ {
int foo; int foo;
int x, y; int x, y, j, k;
float rgb[3]; float rgb[3];
#if DEBUG_LEVEL #if DEBUG_LEVEL
@ -56,7 +56,12 @@ if ( (src->type != dst->type) ||
for (y=0; y<src->height; y++) { for (y=0; y<src->height; y++) {
for (x=0; x<src->width; x++) { for (x=0; x<src->width; x++) {
fimg_get_rgb(src, x, y, rgb); fimg_get_rgb(src, x, y, rgb);
fimg_put_rgb(dst, y, x, rgb); j = (dst->height - x) - 1;
k = (dst->width - y) - 1;
#if DEBUG_LEVEL > 1
fprintf(stderr, "%6d %6d\n", k, j);
#endif
fimg_put_rgb(dst, k, x, rgb);
} }
} }

View File

@ -369,10 +369,11 @@ switch (contrast) {
} }
/* XXX warning, new from coronahome 26 mars 2020 */ /* XXX warning, new from coronahome 26 mars 2020 */
to_save = &cumul;
if (90 == rotfactor) { if (90 == rotfactor) {
memset(&tmpfimg, 0, sizeof(FloatImg)); memset(&tmpfimg, 0, sizeof(FloatImg));
foo = fimg_rotate_90(&cumul, &tmpfimg, 0); foo = fimg_rotate_90(&cumul, &tmpfimg, 0);
if (verbosity > 1) { if (verbosity > 2) {
fprintf(stderr, "dump rot90 %p\n", &tmpfimg); fprintf(stderr, "dump rot90 %p\n", &tmpfimg);
foo = fimg_save_as_png(&tmpfimg, "rot90.png", 0); foo = fimg_save_as_png(&tmpfimg, "rot90.png", 0);
} }
@ -383,13 +384,13 @@ if (90 == rotfactor) {
foo = format_from_extension(outfile); foo = format_from_extension(outfile);
switch (foo) { switch (foo) {
case FILE_TYPE_FIMG: case FILE_TYPE_FIMG:
foo = fimg_dump_to_file(&cumul, outfile, 0); foo = fimg_dump_to_file(to_save, outfile, 0);
break; break;
case FILE_TYPE_PNM: case FILE_TYPE_PNM:
foo = fimg_save_as_pnm(&cumul, outfile, 1); foo = fimg_save_as_pnm(to_save, outfile, 1);
break; break;
case FILE_TYPE_PNG: case FILE_TYPE_PNG:
foo = fimg_save_as_png(&cumul, outfile, 0); foo = fimg_save_as_png(to_save, outfile, 0);
break; break;
default: default:
fprintf(stderr, "can't save as %s\n", outfile); fprintf(stderr, "can't save as %s\n", outfile);