Bug#440768: xli: -zoom auto
Package: xli
Version: 1.17.0-22
Severity: wishlist
Tags: patch
This patch implements the "-zoom auto" feature suggested in xli's TODO file.
It doesn't implement the related TODO item of merging -zoom and -iscale.
With -zoom auto, images smaller than 90% of the screen size are displayed
un-zoomed. Images larger than 90% of the screen size are reduced to fit.
diff -ruNp a/TODO b/TODO
--- a/TODO 2000-02-09 04:23:32.000000000 -0500
+++ b/TODO 2007-09-03 23:31:28.000000000 -0500
@@ -22,7 +22,6 @@ add vicar reader, copyright Noel Gorelic
developed by NASA/JPL.'
make fast image scaling a subfeature of -zoom, eliminate -iscale
-and add -zoom auto
add a TIFF reader?
diff -ruNp a/xli.man b/xli.man
--- a/xli.man 2007-09-03 22:40:08.000000000 -0500
+++ b/xli.man 2007-09-04 00:02:38.000000000 -0500
@@ -317,6 +317,9 @@ more information. Technically the perce
square of the number supplied since the zoom is to both axes, but I
opted for consistency instead of accuracy.
.TP
+\-zoom auto
+Zoom large images to fit the screen; don't zoom small images.
+.TP
\-newoptions
Reset options that propagate. The \fI\-bright, \-colors, \-colordither, \-delay,
\-dither, \-gamma, \-gray, \-normalize, \-smooth, \-xzoom, \-yzoom\fR, and
diff -ruNp a/misc.c b/misc.c
--- a/misc.c 2000-02-09 04:23:33.000000000 -0500
+++ b/misc.c 2007-09-03 22:40:36.000000000 -0500
@@ -104,6 +104,8 @@ char *tail(char *path)
return (t);
}
+#define MIN(a,b) ( (a)<(b) ? (a) : (b))
+
Image *processImage(DisplayInfo *dinfo, Image *iimage, ImageOptions *options)
{
Image *image = iimage, *tmpimage;
@@ -132,6 +134,19 @@ Image *processImage(DisplayInfo *dinfo,
image = tmpimage;
}
/* zoom image */
+ if (options->zoom_auto) {
+ if (image->width > globals.dinfo.width * .9)
+ options->xzoom = globals.dinfo.width * 90 / image->width;
+ else
+ options->xzoom = 100;
+ if (image->height > globals.dinfo.height * .9)
+ options->yzoom = globals.dinfo.height * 90 / image->height;
+ else
+ options->yzoom = 100;
+ /* both dimensions should be shrunk by the same factor */
+ options->xzoom = options->yzoom =
+ MIN(options->xzoom, options->yzoom);
+ }
if (options->xzoom || options->yzoom) {
/* if the image is to be blown up, compress before doing it */
if (!options->colors && RGBP(image) &&
diff -ruNp a/options.c b/options.c
--- a/options.c 1999-10-24 21:15:00.000000000 -0500
+++ b/options.c 2007-09-03 23:54:39.000000000 -0500
@@ -731,11 +731,16 @@ int doLocalOption(OptionId opid, char **
case ZOOM:
if (argv[++a]) {
- if (atoi(argv[a]) < 0) {
- printf("Zoom argument must be positive (ignored).\n");
- break;
+ if (!strcmp(argv[a], "auto")) {
+ image_ops->zoom_auto = TRUE;
+ } else {
+ if (atoi(argv[a]) < 0) {
+ printf("Zoom argument must be positive (ignored).\n");
+ break;
+ }
+ image_ops->xzoom = image_ops->yzoom = atoi(argv[a]);
+ image_ops->zoom_auto = FALSE;
}
- image_ops->xzoom = image_ops->yzoom = atoi(argv[a]);
if (setpersist)
persist_ops->xzoom = persist_ops->yzoom = image_ops->xzoom;
}
diff -ruNp a/xli.c b/xli.c
--- a/xli.c 2000-02-09 04:23:35.000000000 -0500
+++ b/xli.c 2007-09-03 22:40:36.000000000 -0500
@@ -541,6 +541,7 @@ int main(int argc, char *argv[])
break;
}
io->xzoom = io->yzoom = 0;
+ io->zoom_auto = 0;
io->iscale_auto = 0;
if (globals.verbose) {
diff -ruNp a/xli.h b/xli.h
--- a/xli.h 1999-10-24 21:15:07.000000000 -0500
+++ b/xli.h 2007-09-03 22:40:36.000000000 -0500
@@ -55,6 +55,7 @@ typedef struct {
char *title; /* Override title on image */
unsigned int xzoom, yzoom;
/* zoom percentages */
+ boolean zoom_auto; /* automatically zoom to fit on screen */
char *fg, *bg; /* foreground/background colors if mono image */
boolean done_to; /* TRUE if we have already looked for trailing
* options
-- System Information:
Debian Release: 4.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: powerpc (ppc)
Shell: /bin/sh linked to /bin/dash
Kernel: Linux 2.6.22.1
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages xli depends on:
ii libc6 2.3.6.ds1-13etch2 GNU C Library: Shared libraries
ii libjpeg62 6b-13 The Independent JPEG Group's JPEG
ii libpng12-0 1.2.15~beta5-1 PNG library - runtime
ii libx11-6 2:1.0.3-7 X11 client-side library
ii libxext6 1:1.0.1-2 X11 miscellaneous extension librar
ii zlib1g 1:1.2.3-13 compression library - runtime
xli recommends no packages.
-- no debconf information
Reply to: