[gegl] operations/external/save-pixbuf: Don't waste memory
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operations/external/save-pixbuf: Don't waste memory
- Date: Sun, 26 Feb 2017 12:08:44 +0000 (UTC)
commit 9153be299f1c6cc6ee545ef1dad428fe1ced018e
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Feb 23 15:35:23 2017 +0100
operations/external/save-pixbuf: Don't waste memory
A GdkPixbuf takes 8 bits per channel, but only 3 or 4 bytes per pixel.
The later value should be used to allocate the buffer.
https://bugzilla.gnome.org/show_bug.cgi?id=779136
operations/external/save-pixbuf.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/operations/external/save-pixbuf.c b/operations/external/save-pixbuf.c
index 4ff44cd..7fdcfdf 100644
--- a/operations/external/save-pixbuf.c
+++ b/operations/external/save-pixbuf.c
@@ -54,6 +54,7 @@ process (GeglOperation *operation,
GeglRectangle *rect = gegl_operation_source_get_bounding_box (operation, "input");
gchar *name;
gboolean has_alpha;
+ gint bpp;
gint bps;
g_object_get (input, "format", &format, NULL);
@@ -67,7 +68,8 @@ process (GeglOperation *operation,
bps);
babl = babl_format (name);
- temp = g_malloc (rect->width * rect->height * bps);
+ bpp = babl_format_get_bytes_per_pixel (babl);
+ temp = g_malloc (rect->width * rect->height * bpp);
gegl_buffer_get (input, rect, 1.0, babl, temp, GEGL_AUTO_ROWSTRIDE,
GEGL_ABYSS_NONE);
if (temp) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]