diff options
author | Matthias Clasen <mclasen@redhat.com> | 2004-08-24 13:54:26 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2004-08-24 13:54:26 +0000 |
commit | 037d233ceaa1cdede2defcb572e5ac6e6e0d09f9 (patch) | |
tree | e7f38b913e97530ccc06dca8cdf0f4dc754bf5d6 /gdk-pixbuf/gdk-pixdata.c | |
parent | 684aaa4b7142246f57a6fcddaedd07c1c9d7e291 (diff) | |
download | gtk+-037d233ceaa1cdede2defcb572e5ac6e6e0d09f9.tar.gz |
Work around bugs in the runlength encoder by forcing rowstride * height to
2004-08-24 Matthias Clasen <mclasen@redhat.com>
* gdk-pixdata.c (gdk_pixdata_from_pixbuf): Work around bugs in
the runlength encoder by forcing rowstride * height to be
divisible by bpp. (#150882)
Diffstat (limited to 'gdk-pixbuf/gdk-pixdata.c')
-rw-r--r-- | gdk-pixbuf/gdk-pixdata.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gdk-pixbuf/gdk-pixdata.c b/gdk-pixbuf/gdk-pixdata.c index 66f665877f..e027ed659d 100644 --- a/gdk-pixbuf/gdk-pixdata.c +++ b/gdk-pixbuf/gdk-pixdata.c @@ -328,16 +328,36 @@ gdk_pixdata_from_pixbuf (GdkPixdata *pixdata, { guint pad, n_bytes = rowstride * height; guint8 *img_buffer_end, *data; + GdkPixbuf *buf = NULL; + if (n_bytes % bpp != 0) + { + rowstride = pixbuf->width * bpp; + n_bytes = rowstride * height; + data = g_malloc (n_bytes); + buf = gdk_pixbuf_new_from_data (data, + GDK_COLORSPACE_RGB, + pixbuf->has_alpha, 8, + pixbuf->width, + pixbuf->height, + rowstride, + NULL, NULL); + gdk_pixbuf_copy_area (pixbuf, 0, 0, pixbuf->width, pixbuf->height, + buf, 0, 0); + } + else + buf = pixbuf; pad = rowstride; pad = MAX (pad, 130 + n_bytes / 127); data = g_new (guint8, pad + n_bytes); free_me = data; img_buffer = data; img_buffer_end = rl_encode_rgbx (img_buffer, - pixbuf->pixels, pixbuf->pixels + n_bytes, + buf->pixels, buf->pixels + n_bytes, bpp); length = img_buffer_end - img_buffer; + if (buf != pixbuf) + g_object_unref (buf); } else { |