Browse Source

fix a bug in rotate_90

tonton th 1 month ago
parent
commit
b39660cc78
3 changed files with 13 additions and 7 deletions
  1. 1
    1
      floatimg.h
  2. 7
    2
      funcs/rotate.c
  3. 5
    4
      v4l2/grabvidseq.c

+ 1
- 1
floatimg.h View File

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

+ 7
- 2
funcs/rotate.c View File

@@ -15,7 +15,7 @@ extern int		verbosity;
15 15
 int fimg_rotate_90(FloatImg *src, FloatImg *dst, int notused)
16 16
 {
17 17
 int			foo;
18
-int			x, y;
18
+int			x, y, j, k;
19 19
 float			rgb[3];
20 20
 
21 21
 #if DEBUG_LEVEL
@@ -56,7 +56,12 @@ if ( (src->type != dst->type)    ||
56 56
 for (y=0; y<src->height; y++) {
57 57
 	for (x=0; x<src->width; x++) {
58 58
 		fimg_get_rgb(src, x, y, rgb);
59
-		fimg_put_rgb(dst, y, x, rgb);
59
+		j = (dst->height - x) - 1;
60
+		k = (dst->width  - y) - 1;
61
+#if DEBUG_LEVEL > 1
62
+		fprintf(stderr, "%6d %6d\n", k, j);
63
+#endif
64
+		fimg_put_rgb(dst, k, x, rgb);
60 65
 		}
61 66
 	}
62 67
 

+ 5
- 4
v4l2/grabvidseq.c View File

@@ -369,10 +369,11 @@ switch (contrast) {
369 369
 	}
370 370
 
371 371
 /* XXX warning, new from coronahome 26 mars 2020 */
372
+to_save = &cumul;
372 373
 if (90 == rotfactor) {
373 374
 	memset(&tmpfimg, 0, sizeof(FloatImg));
374 375
 	foo = fimg_rotate_90(&cumul, &tmpfimg, 0);
375
-	if (verbosity > 1) {
376
+	if (verbosity > 2) {
376 377
 		fprintf(stderr, "dump rot90 %p\n", &tmpfimg);
377 378
 		foo = fimg_save_as_png(&tmpfimg, "rot90.png", 0);
378 379
 		}
@@ -383,13 +384,13 @@ if (90 == rotfactor) {
383 384
 foo = format_from_extension(outfile);
384 385
 switch (foo) {
385 386
 	case FILE_TYPE_FIMG:
386
-		foo = fimg_dump_to_file(&cumul, outfile, 0);
387
+		foo = fimg_dump_to_file(to_save, outfile, 0);
387 388
 		break;
388 389
 	case FILE_TYPE_PNM:
389
-		foo = fimg_save_as_pnm(&cumul, outfile, 1);
390
+		foo = fimg_save_as_pnm(to_save, outfile, 1);
390 391
 		break;
391 392
 	case FILE_TYPE_PNG:
392
-		foo = fimg_save_as_png(&cumul, outfile, 0);
393
+		foo = fimg_save_as_png(to_save, outfile, 0);
393 394
 		break;
394 395
 	default:
395 396
 		fprintf(stderr, "can't save as %s\n", outfile);

Loading…
Cancel
Save