--- a/src/foreign/vigra/diff2d.hxx
+++ b/src/foreign/vigra/diff2d.hxx
@@ -4,19 +4,34 @@
 /*       Cognitive Systems Group, University of Hamburg, Germany        */
 /*                                                                      */
 /*    This file is part of the VIGRA computer vision library.           */
-/*    ( Version 1.2.0, Aug 07 2003 )                                    */
-/*    You may use, modify, and distribute this software according       */
-/*    to the terms stated in the LICENSE file included in               */
-/*    the VIGRA distribution.                                           */
-/*                                                                      */
+/*    ( Version 1.4.0, Dec 21 2005 )                                    */
 /*    The VIGRA Website is                                              */
 /*        http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/      */
 /*    Please direct questions, bug reports, and contributions to        */
-/*        koethe@informatik.uni-hamburg.de                              */
+/*        koethe@informatik.uni-hamburg.de          or                  */
+/*        vigra@kogs1.informatik.uni-hamburg.de                         */
 /*                                                                      */
-/*  THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR          */
-/*  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED      */
-/*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/*    Permission is hereby granted, free of charge, to any person       */
+/*    obtaining a copy of this software and associated documentation    */
+/*    files (the "Software"), to deal in the Software without           */
+/*    restriction, including without limitation the rights to use,      */
+/*    copy, modify, merge, publish, distribute, sublicense, and/or      */
+/*    sell copies of the Software, and to permit persons to whom the    */
+/*    Software is furnished to do so, subject to the following          */
+/*    conditions:                                                       */
+/*                                                                      */
+/*    The above copyright notice and this permission notice shall be    */
+/*    included in all copies or substantial portions of the             */
+/*    Software.                                                         */
+/*                                                                      */
+/*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND    */
+/*    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES   */
+/*    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND          */
+/*    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT       */
+/*    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,      */
+/*    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      */
+/*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR     */
+/*    OTHER DEALINGS IN THE SOFTWARE.                                   */
 /*                                                                      */
 /************************************************************************/
 
@@ -24,7 +39,7 @@
 #define VIGRA_DIFF2D_HXX
 
 #include <cmath> // for sqrt()
-#include <iostream>  //  ??? <iosfwd> doesn't work on MSVC
+#include <iosfwd>
 #include "vigra/config.hxx"
 #include "vigra/iteratortags.hxx"
 #include "vigra/iteratortraits.hxx"
@@ -45,7 +60,7 @@
     typedef Diff const *                    pointer;
     typedef std::random_access_iterator_tag iterator_category;
 
-    static void initialize(BaseType & d) {}
+    static void initialize(BaseType &) {}
 
     static reference dereference(BaseType const & d)
         { return d; }
@@ -87,7 +102,7 @@
     typedef Diff const *                    pointer;
     typedef std::random_access_iterator_tag iterator_category;
 
-    static void initialize(BaseType & d) {}
+    static void initialize(BaseType & /*d*/) {}
 
     static reference dereference(BaseType const & d)
         { return d; }
@@ -335,9 +350,16 @@
 
         /** Calculate length of difference vector.
         */
+    int squaredMagnitude() const
+    {
+        return x*x + y*y;
+    }
+
+        /** Calculate length of difference vector.
+        */
     double magnitude() const
     {
-        return VIGRA_CSTD::sqrt((double)(x*x + y*y));
+        return VIGRA_CSTD::sqrt((double)squaredMagnitude());
     }
 
         /** Equality.
@@ -421,6 +443,8 @@
 {
     typedef Diff2D                               Iterator;
     typedef Iterator                             iterator;
+    typedef Iterator                             const_iterator;
+    // typedef                                   multable_iterator; undefined
     typedef iterator::iterator_category          iterator_category;
     typedef iterator::value_type                 value_type;
     typedef iterator::reference                  reference;
@@ -431,6 +455,7 @@
     typedef iterator::column_iterator            column_iterator;
     typedef StandardConstValueAccessor<Diff2D>   DefaultAccessor;
     typedef StandardConstValueAccessor<Diff2D>   default_accessor;
+    typedef VigraTrueType                        hasConstantStrides;
 
 };
 
@@ -481,18 +506,25 @@
     : Diff2D(v)
     {}
 
-        /** Query the width
+        /** Query the width.
          */
     int width() const
     {
         return x;
     }
 
-        /** Query the height
+        /** Query the height.
          */
     int height() const
     {
         return y;
+    }
+
+        /** Returns width()*height(), the area of a rectangle of this size.
+         */
+    int area() const
+    {
+        return width()*height();
     }
 
         /** Copy Assigment.
@@ -716,6 +748,79 @@
 {
     return Point2D(s.x + p.x, s.y + p.y);
 }
+
+inline Point2D operator*(Point2D l, double r)
+{
+    l *= r;
+    return l;
+}
+
+inline Point2D operator*(double l, Point2D r)
+{
+    r *= l;
+    return r;
+}
+
+inline Size2D operator*(Size2D l, double r)
+{
+    l *= r;
+    return l;
+}
+
+inline Size2D operator*(double l, Size2D r)
+{
+    r *= l;
+    return r;
+}
+
+inline Point2D operator/(Point2D l, double r)
+{
+    l /= r;
+    return l;
+}
+
+inline Size2D operator/(Size2D l, double r)
+{
+    l /= r;
+    return l;
+}
+
+inline Point2D operator*(Point2D l, int r)
+{
+    l *= r;
+    return l;
+}
+
+inline Point2D operator*(int l, Point2D r)
+{
+    r *= l;
+    return r;
+}
+
+inline Size2D operator*(Size2D l, int r)
+{
+    l *= r;
+    return l;
+}
+
+inline Size2D operator*(int l, Size2D r)
+{
+    r *= l;
+    return r;
+}
+
+inline Point2D operator/(Point2D l, int r)
+{
+    l /= r;
+    return l;
+}
+
+inline Size2D operator/(Size2D l, int r)
+{
+    l /= r;
+    return l;
+}
+
 
 /********************************************************/
 /*                                                      */
@@ -1060,7 +1165,7 @@
          * rectangle and the point. If isEmpty returns true, the union
          * will be a rectangle containing only the given point.
          */
-    Rect2D operator|(Point2D const &p)
+    Rect2D operator|(Point2D const &p) const
     {
         Rect2D result(*this);
         result |= p;
@@ -1223,8 +1328,10 @@
 
 //@}
 
-} // namespace vigra
-
+/**
+ * Output a \ref vigra::Diff2D as a tuple.
+ * Example Diff2D(-12, 13) -> "(-12, 13)"
+ */
 inline
 std::ostream & operator<<(std::ostream & o, vigra::Diff2D const & d)
 {
@@ -1232,6 +1339,10 @@
     return o;
 }
 
+/**
+ * Output a \ref vigra::Size2D.
+ * Example Size2D(100, 200) -> "(100x200)"
+ */
 inline
 std::ostream &operator <<(std::ostream &s, vigra::Size2D const &d)
 {
@@ -1239,6 +1350,10 @@
     return s;
 }
 
+/**
+ * Output a description of a \ref vigra::Rect2D.
+ * Example Rect2D(10, 10, 30, 20) -> "[(10, 10) to (30, 20) = (20x10)]"
+ */
 inline
 std::ostream &operator <<(std::ostream &s, vigra::Rect2D const &r)
 {
@@ -1247,4 +1362,6 @@
     return s;
 }
 
+} // namespace vigra
+
 #endif // VIGRA_DIFF2D_HXX