From 1528b0ad857757cdb0fd711663192a898501ebc8 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 22 May 2002 18:13:44 +0000 Subject: [PATCH] Ahem, take the rowstride into account!!! Fixes #82515. 2002-05-22 Federico Mena Quintero * io-xpm.c (pixbuf_create_from_xpm): Ahem, take the rowstride into account!!! Fixes #82515. [This bug is not present in the GNOME 1.4 branch as its XPM loader does not use gdk_pixbuf_new(); rather it malloc()s a buffer with no row padding and then uses gdk_pixbuf_new_from_data() on it.] [IMPORTANT: The comment above is to make my life easier when merging stuff across branches. If you make changes to gdk-pixbuf in either branch, please include a comment in the ChangeLog that indicates whether this should be merged into the other branch. Thanks!] --- gdk-pixbuf/ChangeLog | 15 +++++++++++++++ gdk-pixbuf/io-xpm.c | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index cc1aabe501..0e77158f53 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,18 @@ +2002-05-22 Federico Mena Quintero + + * io-xpm.c (pixbuf_create_from_xpm): Ahem, take the rowstride into + account!!! Fixes #82515. + + [This bug is not present in the GNOME 1.4 branch as its XPM loader + does not use gdk_pixbuf_new(); rather it malloc()s a buffer with + no row padding and then uses gdk_pixbuf_new_from_data() on it.] + + [IMPORTANT: The comment above is to make my life easier when + merging stuff across branches. If you make changes to gdk-pixbuf + in either branch, please include a comment in the ChangeLog that + indicates whether this should be merged into the other branch. + Thanks!] + 2002-05-18 Matthias Clasen * io-tiff.c (tiff_image_parse): fix packing order on bigendian diff --git a/gdk-pixbuf/io-xpm.c b/gdk-pixbuf/io-xpm.c index 3f04729896..6f47766768 100644 --- a/gdk-pixbuf/io-xpm.c +++ b/gdk-pixbuf/io-xpm.c @@ -1209,7 +1209,7 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl GError **error) { gint w, h, n_col, cpp; - gint cnt, xcnt, ycnt, wbytes, n, ns; + gint cnt, xcnt, ycnt, wbytes, n; gint is_trans = FALSE; const gchar *buffer; gchar *name_buf; @@ -1322,9 +1322,10 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl } wbytes = w * cpp; - pixtmp = pixbuf->pixels; for (ycnt = 0; ycnt < h; ycnt++) { + pixtmp = pixbuf->pixels + ycnt * pixbuf->rowstride; + buffer = (*get_buf) (op_body, handle); if ((!buffer) || (strlen (buffer) < wbytes)) continue; @@ -1332,7 +1333,6 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl for (n = 0, cnt = 0, xcnt = 0; n < wbytes; n += cpp, xcnt++) { strncpy (pixel_str, &buffer[n], cpp); pixel_str[cpp] = 0; - ns = 0; color = g_hash_table_lookup (color_hash, pixel_str);