]> git.decadent.org.uk Git - videolink.git/blobdiff - pixbufs.cpp
Release versions 1.2.11 and 1.2.11-1
[videolink.git] / pixbufs.cpp
index d6936de31abcfeb918af1358e9c8091d913cc6ad..2cef5d3eebd1d0f1f5129465065b3f4a7a1e14c5 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2005 Ben Hutchings <ben@decadent.org.uk>.
+// Copyright 2005-6 Ben Hutchings <ben@decadent.org.uk>.
 // See the file "COPYING" for licence details.
 
 #include "pixbufs.hpp"
@@ -14,9 +14,9 @@
 // (or RGBA, but the alpha component will be ignored) and copy the
 // differing pixels from the new one to a third RGBA Pixbuf at the
 // specified offset with full opacity.
-// The width and height of the old and new Pixbufs must be equal
-// and match the specified dimensions.  The width and height of
-// the third Pixbuf must be large enough to store a rectangle of
+// The width and height of the new Pixbufs must be equal and match
+// the specified dimensions.  The width and height of the old and
+// third Pixbuf must be large enough to store a rectangle of
 // those dimensions at the specified offset.
 void diff_rgb_pixbufs(Glib::RefPtr<Gdk::Pixbuf> old_buf,
                      Glib::RefPtr<Gdk::Pixbuf> new_buf,
@@ -31,8 +31,8 @@ void diff_rgb_pixbufs(Glib::RefPtr<Gdk::Pixbuf> old_buf,
     int old_bpr = old_buf->get_rowstride();
     int old_bpp = old_buf->get_n_channels();
     assert(old_bpp >= 3);
-    assert(old_buf->get_width() == width);
-    assert(old_buf->get_height() == height);
+    assert(old_buf->get_width() >= offset_x + width);
+    assert(old_buf->get_height() >= offset_y + height);
     int new_bpr = new_buf->get_rowstride();
     int new_bpp = new_buf->get_n_channels();
     assert(new_bpp >= 3);
@@ -44,7 +44,9 @@ void diff_rgb_pixbufs(Glib::RefPtr<Gdk::Pixbuf> old_buf,
     assert(diff_buf->get_width() >= offset_x + width);
     assert(diff_buf->get_height() >= offset_y + height);
 
-    const guint8 * old_p = old_buf->get_pixels();
+    const guint8 * old_p = (old_buf->get_pixels()
+                           + old_bpr * offset_y
+                           + old_bpp * offset_x);
     const guint8 * new_p = new_buf->get_pixels();
     guint8 * diff_p = (diff_buf->get_pixels()
                       + diff_bpr * offset_y