diff options
author | Michael Natterer <mitch@imendio.com> | 2007-01-17 14:07:01 +0000 |
---|---|---|
committer | Michael Natterer <mitch@src.gnome.org> | 2007-01-17 14:07:01 +0000 |
commit | 852e8c172957294a22d8ac6cc8d545c3e6ced5ec (patch) | |
tree | 237fbabbd1e695b1a6fe67ec72ca17d3d8d394bc /gdk-pixbuf | |
parent | 3ce873629868a65b5887e46d05893458cb7149f6 (diff) | |
download | gtk+-852e8c172957294a22d8ac6cc8d545c3e6ced5ec.tar.gz |
Patch taken from maemo-gtk:
2007-01-17 Michael Natterer <mitch@imendio.com>
Patch taken from maemo-gtk:
* io-png.c (png_text_to_pixbuf_option): don't call g_convert() on
ASCII strings.
(png_info_callback): set an error when the size_func would scale
the pixbuf away completely.
svn path=/trunk/; revision=17179
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r-- | gdk-pixbuf/ChangeLog | 10 | ||||
-rw-r--r-- | gdk-pixbuf/io-png.c | 28 |
2 files changed, 32 insertions, 6 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 9f617d1cd1..9722d53afe 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,13 @@ +2007-01-17 Michael Natterer <mitch@imendio.com> + + Patch taken from maemo-gtk: + + * io-png.c (png_text_to_pixbuf_option): don't call g_convert() on + ASCII strings. + + (png_info_callback): set an error when the size_func would scale + the pixbuf away completely. + 2007-01-16 Matthias Clasen <mclasen@redhat.com> * gdk-pixbuf-loader.c (gdk_pixbuf_loader_write): Just diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c index 19a35251f7..2c98d63c4a 100644 --- a/gdk-pixbuf/io-png.c +++ b/gdk-pixbuf/io-png.c @@ -204,14 +204,24 @@ png_text_to_pixbuf_option (png_text text_ptr, gchar **key, gchar **value) { - if (text_ptr.text_length > 0) { - *value = g_convert (text_ptr.text, -1, - "UTF-8", "ISO-8859-1", - NULL, NULL, NULL); - } - else { + gboolean is_ascii = TRUE; + int i; + + /* Avoid loading iconv if the text is plain ASCII */ + for (i = 0; i < text_ptr.text_length; i++) + if (text_ptr.text[i] & 0x80) { + is_ascii = FALSE; + break; + } + + if (is_ascii) { *value = g_strdup (text_ptr.text); + } else { + *value = g_convert (text_ptr.text, -1, + "UTF-8", "ISO-8859-1", + NULL, NULL, NULL); } + if (*value) { *key = g_strconcat ("tEXt::", text_ptr.key, NULL); return TRUE; @@ -602,6 +612,12 @@ png_info_callback (png_structp png_read_ptr, if (w == 0 || h == 0) { lc->fatal_error_occurred = TRUE; + if (lc->error && *lc->error == NULL) { + g_set_error (lc->error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_FAILED, + _("Transformed PNG has zero width or height.")); + } return; } } |