Репозитории ALT
S: | 1.17.0-alt9 |
5.1: | 1.17.0-alt8 |
4.1: | 1.17.0-alt6 |
4.0: | 1.17.0-alt6 |
3.0: | 1.17.0-alt6 |
Группа :: Графика
Пакет: xli
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: 130-zoom_auto_440768.patch
Скачать
Скачать
Subject: Bug#440768: xli: -zoom auto
From: Alan Curry <pacman@TheWorld.com>
Date: Tue, 4 Sep 2007 01:09:05 -0400 (EDT)
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.
Subject: Bug#440768: (xli -zoom auto) patch improvement
From: Alan Curry <pacman@TheWorld.com>
Date: Tue, 4 Sep 2007 18:53:56 -0400 (EDT)
Update: the first version of the patch didn't allow the -zoom auto option to
persist across multiple images. This version fixes that.
Index: xli-1.17.0+20061110/TODO
===================================================================
--- xli-1.17.0+20061110.orig/TODO
+++ xli-1.17.0+20061110/TODO
@@ -20,7 +20,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?
Index: xli-1.17.0+20061110/misc.c
===================================================================
--- xli-1.17.0+20061110.orig/misc.c
+++ xli-1.17.0+20061110/misc.c
@@ -105,6 +105,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;
@@ -133,6 +135,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) &&
Index: xli-1.17.0+20061110/options.c
===================================================================
--- xli-1.17.0+20061110.orig/options.c
+++ xli-1.17.0+20061110/options.c
@@ -737,13 +737,20 @@ 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)
+ if (setpersist) {
persist_ops->xzoom = persist_ops->yzoom = image_ops->xzoom;
+ persist_ops->zoom_auto = image_ops->zoom_auto;
+ }
}
break;
Index: xli-1.17.0+20061110/xli.c
===================================================================
--- xli-1.17.0+20061110.orig/xli.c
+++ xli-1.17.0+20061110/xli.c
@@ -96,6 +96,7 @@ int main(int argc, char *argv[])
persist_ops.xpmkeyc = 0; /* none */
persist_ops.xzoom = 0;
persist_ops.yzoom = 0;
+ persist_ops.zoom_auto = FALSE;
persist_ops.iscale = 0;
persist_ops.iscale_auto = FALSE;
@@ -208,6 +209,7 @@ int main(int argc, char *argv[])
images[nimages].xpmkeyc = persist_ops.xpmkeyc;
images[nimages].xzoom = persist_ops.xzoom;
images[nimages].yzoom = persist_ops.yzoom;
+ images[nimages].zoom_auto = persist_ops.zoom_auto;
images[nimages].iscale_auto = persist_ops.iscale_auto;
nimages++;
INIT_IMAGE_OPTS(images[nimages]);
@@ -564,6 +566,7 @@ int main(int argc, char *argv[])
break;
}
io->xzoom = io->yzoom = 0;
+ io->zoom_auto = 0;
io->iscale_auto = 0;
if (globals.verbose) {
Index: xli-1.17.0+20061110/xli.h
===================================================================
--- xli-1.17.0+20061110.orig/xli.h
+++ xli-1.17.0+20061110/xli.h
@@ -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