summaryrefslogtreecommitdiff
path: root/media-gfx/xli/files/xli-1.17.0-fix-scale-zoom.patch
blob: 44ee262aee25459f01d531697076418fb72f2cce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
As of jpeg-7, the scale coefficents may be set to non-unitary values by the
initial DCT transform. This caused the original already-scale detection
algorithm in xli to break.

To avoid this, set the already-scaled marker when we adjust the scale fraction
(that gets passed into the DCT).

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>

diff -Nuar -X x xli-2005-02-27.orig/jpeg.c xli-2005-02-27/jpeg.c
--- xli-2005-02-27.orig/jpeg.c	2005-02-27 16:42:39.000000000 -0800
+++ xli-2005-02-27/jpeg.c	2009-09-05 15:02:12.462635389 -0700
@@ -211,7 +211,7 @@
 	xli_jpg_err jerr;
 	Image *image = 0;
 	byte **rows = 0;
-	int i, rowbytes;
+	int i, rowbytes, flags;
 
 	CURRFUNC("jpegLoad");
 	zfp = zopen(fullname);
@@ -248,9 +248,13 @@
 	if (verbose)
 		describe_jpeg(&cinfo, fullname);
 
+	flags = 0;
 	if (image_ops->iscale > 0 && image_ops->iscale < 4) {
-		cinfo.scale_num = 1;
-		cinfo.scale_denom = 1 << image_ops->iscale;
+		flags |= FLAG_ISCALE;
+		//cinfo.scale_num = 1;
+		cinfo.scale_denom *= 1 << image_ops->iscale;
+		if (verbose)
+			printf("scaling to %d/%d\n", cinfo.scale_num, cinfo.scale_denom);
 	} else if (image_ops->iscale_auto) {
 		image_ops->iscale = 0;
 		while (image_ops->iscale < 3 && (cinfo.image_width >>
@@ -258,9 +262,11 @@
 				cinfo.image_height >> image_ops->iscale >
 				globals.dinfo.height * .9))
 			image_ops->iscale += 1;
-		cinfo.scale_denom = 1 << image_ops->iscale;
+		cinfo.scale_denom *= 1 << image_ops->iscale;
+		if(image_ops->iscale > 0)
+		    flags |= FLAG_ISCALE;
 		if (verbose)
-			printf("auto-scaling to 1/%d\n", cinfo.scale_denom);
+			printf("auto-scaling to %d/%d\n", cinfo.scale_num, cinfo.scale_denom);
 	}
 	znocache(zfp);
 
@@ -288,8 +294,7 @@
 	}
 
 	image->gamma = RETURN_GAMMA;
-	if (cinfo.scale_denom > 1)
-		image->flags |= FLAG_ISCALE;
+	image->flags |= flags;
 
 	rowbytes = cinfo.output_width * cinfo.output_components;
 	assert(image->pixlen * image->width == rowbytes);