diff options
author | Michael Natterer <mitch@gimp.org> | 2001-12-11 17:30:53 +0000 |
---|---|---|
committer | Michael Natterer <mitch@src.gnome.org> | 2001-12-11 17:30:53 +0000 |
commit | 3339931f8f7de86143d9e3eb30ea1012a979bd5b (patch) | |
tree | e30409982a1075e30a57e0985ac52063958f2a26 /gdk-pixbuf | |
parent | 8157885492c0d4da47de4799ab2da588e7e5cf16 (diff) | |
download | gtk+-3339931f8f7de86143d9e3eb30ea1012a979bd5b.tar.gz |
gdk_pixbuf__png_image_save: removed wrong endian conversion stuff; don't
2001-12-11 Michael Natterer <mitch@gimp.org>
* io-png.c: gdk_pixbuf__png_image_save: removed wrong endian
conversion stuff; don't copy RGB pixbufs' lines around before
saving them.
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r-- | gdk-pixbuf/ChangeLog | 6 | ||||
-rw-r--r-- | gdk-pixbuf/io-png.c | 39 |
2 files changed, 9 insertions, 36 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index fa14ebbd09..c464eb7845 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,9 @@ +2001-12-11 Michael Natterer <mitch@gimp.org> + + * io-png.c: gdk_pixbuf__png_image_save: removed wrong endian + conversion stuff; don't copy RGB pixbufs' lines around before + saving them. + 2001-12-05 Matthias Clasen <matthiasc@poet.de> * gdk-pixbuf.h (gdk_pixbuf_ref, gdk_pixbuf_unref, diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c index b531a75d28..8d102d94a1 100644 --- a/gdk-pixbuf/io-png.c +++ b/gdk-pixbuf/io-png.c @@ -720,10 +720,9 @@ gdk_pixbuf__png_image_save (FILE *f, png_textp text_ptr = NULL; guchar *ptr; guchar *pixels; - int x, y; - int i, j; + int y; + int i; png_bytep row_ptr; - png_bytep data; png_color_8 sig_bit; int w, h, rowstride; int has_alpha; @@ -787,8 +786,6 @@ gdk_pixbuf__png_image_save (FILE *f, } } - data = NULL; - bpc = gdk_pixbuf_get_bits_per_sample (pixbuf); w = gdk_pixbuf_get_width (pixbuf); h = gdk_pixbuf_get_height (pixbuf); @@ -823,30 +820,10 @@ gdk_pixbuf__png_image_save (FILE *f, png_set_IHDR (png_ptr, info_ptr, w, h, bpc, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); -#ifdef WORDS_BIGENDIAN - png_set_swap_alpha (png_ptr); -#else - png_set_bgr (png_ptr); -#endif } else { png_set_IHDR (png_ptr, info_ptr, w, h, bpc, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - data = g_try_malloc (w * 3 * sizeof (char)); - - if (data == NULL) { - /* Check error NULL, normally this would be broken, - * but libpng makes me want to code defensively. - */ - if (error && *error == NULL) { - g_set_error (error, - GDK_PIXBUF_ERROR, - GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, - _("Insufficient memory to save PNG file")); - } - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; - } } sig_bit.red = bpc; sig_bit.green = bpc; @@ -859,21 +836,11 @@ gdk_pixbuf__png_image_save (FILE *f, ptr = pixels; for (y = 0; y < h; y++) { - if (has_alpha) - row_ptr = (png_bytep)ptr; - else { - for (j = 0, x = 0; x < w; x++) - memcpy (&(data[x*3]), &(ptr[x*3]), 3); - - row_ptr = (png_bytep)data; - } + row_ptr = (png_bytep)ptr; png_write_rows (png_ptr, &row_ptr, 1); ptr += rowstride; } - if (data) - g_free (data); - png_write_end (png_ptr, info_ptr); png_destroy_write_struct (&png_ptr, (png_infopp) NULL); |