Hello community,

here is the log from the commit of package mgp for openSUSE:Factory checked in 
at 2012-11-14 09:14:38
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/mgp (Old)
 and      /work/SRC/openSUSE:Factory/.mgp.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "mgp", Maintainer is "nadvor...@suse.com"

Changes:
--------
--- /work/SRC/openSUSE:Factory/mgp/mgp.changes  2011-12-08 11:53:10.000000000 
+0100
+++ /work/SRC/openSUSE:Factory/.mgp.new/mgp.changes     2012-11-14 
09:14:39.000000000 +0100
@@ -1,0 +2,12 @@
+Wed Aug 22 17:48:46 CEST 2012 - ti...@suse.de
+
+- Add recommends imlib2 to be installed automatically
+
+-------------------------------------------------------------------
+Thu Aug 16 16:53:19 CEST 2012 - ti...@suse.de
+
+- Add bilinear image resampling (bnc#789418)
+- Fix BadDrawable error with zoomonclk (bnc#789416)
+- Fix the potential buffer overflow in imlib handling code
+
+-------------------------------------------------------------------

New:
----
  mgp-bilinear-zoom.diff
  mgp-imlib2-segfault-fix.diff

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ mgp.spec ++++++
--- /var/tmp/diff_new_pack.K2yOqy/_old  2012-11-14 09:14:40.000000000 +0100
+++ /var/tmp/diff_new_pack.K2yOqy/_new  2012-11-14 09:14:40.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package mgp
 #
-# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -15,6 +15,7 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #
 
+
 Name:           mgp
 BuildRequires:  automake
 BuildRequires:  bison
@@ -29,13 +30,16 @@
 BuildRequires:  pkgconfig
 BuildRequires:  sharutils
 BuildRequires:  xorg-x11-devel
-License:        BSD-3-Clause
-Group:          Productivity/Publishing/Presentation
 Provides:       magicpoint 
-Requires:       perl freetype sharutils
+Requires:       freetype
+Requires:       perl
+Requires:       sharutils
+Recommends:     imlib2
 Version:        1.13a
 Release:        0
 Summary:        MagicPoint, an X Window System Presentation Tool
+License:        BSD-3-Clause
+Group:          Productivity/Publishing/Presentation
 Url:            http://member.wide.ad.jp/wg/mgp/
 Source:         magicpoint-%{version}.tar.bz2
 Source1:        README.SuSE
@@ -50,6 +54,8 @@
 Patch10:        magicpoint-%{version}-xft-rendering-fix.diff
 Patch11:        magicpoint-%{version}-lib64.diff
 Patch13:        magicpoint-%{version}-warnings.patch
+Patch14:        mgp-bilinear-zoom.diff
+Patch15:        mgp-imlib2-segfault-fix.diff
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 
 %description
@@ -75,6 +81,8 @@
 #patch10
 %patch11
 %patch13
+%patch14 -p1
+%patch15 -p1
 cp %{SOURCE1} .
 rm -rf sample/CVS
 

++++++ mgp-bilinear-zoom.diff ++++++
---
 image/zoom.c |  159 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 mgp.c        |    9 ++-
 mgp.man      |    2 
 3 files changed, 168 insertions(+), 2 deletions(-)

--- a/image/zoom.c
+++ b/image/zoom.c
@@ -11,6 +11,8 @@
 #include "copyright.h"
 #include "image.h"
 
+int smooth_scaling = 1;
+
 static unsigned int *buildIndex(width, zoom, rwidth)
      unsigned int  width;
      float         zoom;
@@ -36,6 +38,144 @@ static unsigned int *buildIndex(width, z
   return(index);
 }
 
+static Pixel rgb8_to_true(r, g, b)
+     byte r;
+     byte g;
+     byte b;
+{
+  return (Pixel)r << 16 | (Pixel)g << 8 | (Pixel)b;
+}
+
+/* simple bilinear resampling */
+static void resize_image(oimage, image)
+     Image *oimage;
+     Image *image;
+{
+  double cx, cy, xoff, yoff;
+  double xstep, ystep;
+  int maxx, maxy;
+  int x1, x2, y1, y2;
+  int i, j;
+  byte *line1, *line2;
+  byte *destptr;
+  unsigned int srclinelen;
+  unsigned int pixlen;
+  Pixel v[4];
+  unsigned int r, g, b;
+
+  maxx = oimage->width - 1;
+  maxy = oimage->height - 1;
+  pixlen= oimage->pixlen;
+  srclinelen= oimage->width * pixlen;
+  destptr = image->data;
+  cy = 0;
+  xstep = (double)oimage->width / (double)image->width;
+  ystep = (double)oimage->height / (double)image->height;
+  for (j = image->height; j > 0; j--) {
+    y1 = cy;
+    if (y1 >= maxy) {
+      y1 = y2 = maxy;
+      yoff = 0;
+    } else {
+      y2 = y1 + 1;
+      yoff = cy - y1;
+    }
+    line1 = oimage->data + srclinelen * y1;
+    line2 = oimage->data + srclinelen * y2;
+    cx = 0;
+    for (i = image->width; i > 0; i--) {
+      x1 = cx;
+      if (x1 >= maxx) {
+       x1 = x2 = maxx;
+       xoff = 0;
+      } else {
+       x2 = x1 + 1;
+       xoff = cx - x1;
+      }
+      v[0] = memToVal(line1 + pixlen * x1, pixlen);
+      v[1] = memToVal(line1 + pixlen * x2, pixlen);
+      v[2] = memToVal(line2 + pixlen * x1, pixlen);
+      v[3] = memToVal(line2 + pixlen * x2, pixlen);
+      r = (TRUE_RED(v[0]) * (1 - xoff) +
+          TRUE_RED(v[1]) * xoff) * (1 - yoff) +
+       (TRUE_RED(v[2]) * (1 - xoff) +
+        TRUE_RED(v[3]) * xoff) * yoff;
+      g = (TRUE_GREEN(v[0]) * (1 - xoff) +
+          TRUE_GREEN(v[1]) * xoff) * (1 - yoff) +
+       (TRUE_GREEN(v[2]) * (1 - xoff) +
+        TRUE_GREEN(v[3]) * xoff) * yoff;
+      b = (TRUE_BLUE(v[0]) * (1 - xoff) +
+          TRUE_BLUE(v[1]) * xoff) * (1 - yoff) +
+       (TRUE_BLUE(v[2]) * (1 - xoff) +
+        TRUE_BLUE(v[3]) * xoff) * yoff;
+      v[0] = rgb8_to_true(r, g, b);
+      valToMem(v[0], destptr, pixlen);
+      destptr += pixlen;
+      cx += xstep;
+    }
+    cy += ystep;
+  }
+}
+
+/* reduce the given image in integer factor */
+static Image *reduced_image(oimage, width, height)
+     Image *oimage;
+     unsigned int width;
+     unsigned int height;
+{
+  Image *dest;
+  byte *destptr;
+  unsigned int srclinelen;
+  unsigned int i, j;
+  unsigned int factorx = oimage->width / width;
+  unsigned int factory = oimage->height / height;
+  unsigned int pixlen= oimage->pixlen;
+
+  if (factorx < 1)
+    factorx = 1;
+  if (factory < 1)
+    factory = 1;
+
+  width = oimage->width / factorx;
+  if (oimage->width % factorx)
+    width++;
+  height = oimage->height / factory;
+  if (oimage->height % factory)
+    height++;
+
+  dest = newTrueImage(width, height);
+  destptr = dest->data;
+
+  srclinelen = oimage->width * oimage->pixlen;
+
+  for (j = 0; j < oimage->height; j += factory) {
+    for (i = 0; i < oimage->width; i += factorx) {
+      unsigned int r, g, b, div, x, y;
+      Pixel v;
+
+      r = g = b= 0;
+      div = 0;
+      for (y = 0; y < factory && j + y < oimage->height; y++) {
+       byte *src = oimage->data + srclinelen * (j + y);
+       for (x = 0; x < factorx && i + x < oimage->width; x++) {
+         v = memToVal(src + pixlen * (i + x), pixlen);
+         r += TRUE_RED(v);
+         g += TRUE_GREEN(v);
+         b += TRUE_BLUE(v);
+         div++;
+       }
+      }
+      r /= div;
+      g /= div;
+      b /= div;
+      v = rgb8_to_true(r, g, b);
+      valToMem(v, destptr, pixlen);
+      destptr += pixlen;
+    }
+  }
+  return dest;
+}
+
 Image *zoom(oimage, xzoom, yzoom, verbose)
      Image        *oimage;
      float        xzoom, yzoom;
@@ -145,8 +285,25 @@ Image *zoom(oimage, xzoom, yzoom, verbos
     /* FALLTHRU */
 
   case ITRUE:
-    if (!RGBP(oimage))
+    if (!RGBP(oimage)) {
+      Image *tmpimage = NULL;
+      if (smooth_scaling &&
+         (oimage->width / xwidth > 1 || oimage->height / ywidth > 1)) {
+       tmpimage = reduced_image(oimage, xwidth, ywidth);
+       if (tmpimage->width == xwidth && tmpimage->height == ywidth) {
+         image = tmpimage;
+         break;
+       }
+      }
       image= newTrueImage(xwidth, ywidth);
+      if (smooth_scaling) {
+       resize_image(tmpimage ? tmpimage : oimage, image);
+       if (tmpimage)
+         freeImage(tmpimage);
+       break;
+      }
+    }
+
     pixlen= oimage->pixlen;
     destptr= image->data;
     srcline= oimage->data;
--- a/mgp.c
+++ b/mgp.c
@@ -113,6 +113,8 @@ static int wantreload __P((void));
 /*image*/
 extern char *expandPath __P((char *));
 
+extern int smooth_scaling; /* in image/zoom.c */
+
 #ifdef TTY_KEYINPUT
 static void
 susp(int sig)
@@ -261,7 +263,7 @@ main(argc, argv)
        argv=tmp_argv;
        argc=tmp_argc;
 
-#define ACCEPTOPTS     "Bd:vVob:c:eg:f:hlGp:qt:Q:PSUT:D:CORw:X:x:nF:E:"
+#define ACCEPTOPTS     "Bd:vVob:c:eg:f:hlGp:qt:Q:PsSUT:D:CORw:X:x:nF:E:"
        while ((opt = getopt(argc, argv, ACCEPTOPTS)) != -1) {
 #undef ACCEPTOPTS
                switch (opt) {
@@ -342,6 +344,10 @@ main(argc, argv)
                        parse_debug++;
                        break;
 
+               case 's':
+                       smooth_scaling = !smooth_scaling;
+                       break;
+
                case 'S':
                        mgp_flag |= FL_NOFORK;
                        break;
@@ -750,6 +756,7 @@ mgp_usage(name)
        fprintf(stderr, "\t-U: Do process directives that forks process\n\t    
or allow to use non-ASCII filenames (unsecure mode)\n");
        fprintf(stderr, "\t-T <timestampfile>: Update timestampfile on page 
refresh\n");
        fprintf(stderr, "\t-P: print stderr from image conversion tools (by 
default it's discarded)\n");
+       fprintf(stderr, "\t-s: Toggle smooth image scaling\n");
        fprintf(stderr, "\t-V: Be verbose\n");
        fprintf(stderr, "\t-X <gsdevice>: ghostscript device to use\n");
        fprintf(stderr, "\t--title <title>: Set window title\n");
--- a/mgp.man
+++ b/mgp.man
@@ -259,6 +259,8 @@ every time it updates the presentation w
 This option is useful for external process to understand when
 .Nm
 modifies the window.
+.It Fl s
+Toggle the smooth image rendering by bilinear interpolation.
 .It Fl V
 Be verbose.
 Generate debugging output to standard output.
++++++ mgp-imlib2-segfault-fix.diff ++++++
---
 image/imlib_loader.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

--- a/image/imlib_loader.c
+++ b/image/imlib_loader.c
@@ -9,7 +9,8 @@
 #include <Imlib2.h>
 
 #define IMFILENUM 500
-static char imfile[IMFILENUM][1024];
+#define MAXPATHLEN 1024
+static char imfile[IMFILENUM][MAXPATHLEN];
 static Imlib_Image *imdata[IMFILENUM];
 static Image *imagedata[IMFILENUM];
 static int imnum;
@@ -42,6 +43,7 @@ Image *imLoad(char *fullname, char *name
                imlib_context_set_display(disp);
                imlib_context_set_visual(DefaultVisual(disp, 
DefaultScreen(disp)));
                imlib_context_set_colormap(DefaultColormap(disp, 
DefaultScreen(disp)));
+               imlib_context_set_drawable(DefaultRootWindow(disp));
        }
        if ((im = search_imdata(fullname), image) == NULL) {
                /* im = Imlib_load_image(id, fullname); */
@@ -126,7 +128,10 @@ void regist_imdata(fullname, im, image)
        Imlib_Image *im;
        Image *image;
 {
-       strcpy(imfile[imnum], fullname);        
+       if (imnum >= IMFILENUM)
+               return;
+       strncpy(imfile[imnum], fullname, MAXPATHLEN - 1);
+       imfile[imnum][MAXPATHLEN - 1] = 0;
        imdata[imnum] = im;
        imagedata[imnum] = image;
        imnum ++;
@@ -136,11 +141,12 @@ Pixmap pixmap_fromimimage(imimage, width
        Imlib_Image *imimage;
        int width, height;
 {
-       static Pixmap pixmap;
+       Pixmap pixmap;
 #if 0
        Imlib_render(id, imimage, width, height);
        pixmap = Imlib_move_image(id, imimage);
 #else
+       imlib_context_set_image(imimage);
        imlib_render_pixmaps_for_whole_image_at_size(&pixmap, NULL, width, 
height);
 #endif
 
-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to