-// 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"
// (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,
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);
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