From a695510ee8752fee48b98f7b4177115876a0a3a6 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 23 Jan 2013 22:18:32 +0100 Subject: fix Memory leak in bitmap trace (Bug #996695) (bzr r12057) --- src/trace/imagemap-gdk.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/trace/imagemap-gdk.cpp') diff --git a/src/trace/imagemap-gdk.cpp b/src/trace/imagemap-gdk.cpp index e5ff23ad0..06f355de7 100644 --- a/src/trace/imagemap-gdk.cpp +++ b/src/trace/imagemap-gdk.cpp @@ -58,7 +58,7 @@ GdkPixbuf *grayMapToGdkPixbuf(GrayMap *grayMap) GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, 0, 8, grayMap->width, grayMap->height, - rowstride, NULL, NULL); + rowstride, (GdkPixbufDestroyNotify)g_free, NULL); //### Fill in the odd cells with RGB values int x,y; @@ -122,7 +122,7 @@ PackedPixelMap *gdkPixbufToPackedPixelMap(GdkPixbuf *buf) return ppMap; } -GdkPixbuf *packedPixelMapToGdkPixbuf(PackedPixelMap *ppMap) +/*GdkPixbuf *packedPixelMapToGdkPixbuf(PackedPixelMap *ppMap) { if (!ppMap) return NULL; @@ -137,7 +137,7 @@ GdkPixbuf *packedPixelMapToGdkPixbuf(PackedPixelMap *ppMap) GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, 0, 8, ppMap->width, ppMap->height, - rowstride, NULL, NULL); + rowstride, NULL, NULL); //first NULL: replace by (GdkPixbufDestroyNotify)g_free ?? //### Fill in the cells with RGB values int x,y; @@ -158,7 +158,7 @@ GdkPixbuf *packedPixelMapToGdkPixbuf(PackedPixelMap *ppMap) return buf; } - +*/ /*######################################################################### @@ -203,6 +203,7 @@ RgbMap *gdkPixbufToRgbMap(GdkPixbuf *buf) return rgbMap; } +/* GdkPixbuf *rgbMapToGdkPixbuf(RgbMap *rgbMap) { if (!rgbMap) @@ -218,7 +219,7 @@ GdkPixbuf *rgbMapToGdkPixbuf(RgbMap *rgbMap) GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, 0, 8, rgbMap->width, rgbMap->height, - rowstride, NULL, NULL); + rowstride, NULL, NULL); //first NULL: replace by (GdkPixbufDestroyNotify)g_free ?? //### Fill in the cells with RGB values int x,y; @@ -239,6 +240,7 @@ GdkPixbuf *rgbMapToGdkPixbuf(RgbMap *rgbMap) return buf; } +*/ /*######################################################################### ## I N D E X E D M A P @@ -260,7 +262,7 @@ GdkPixbuf *indexedMapToGdkPixbuf(IndexedMap *iMap) GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, 0, 8, iMap->width, iMap->height, - rowstride, NULL, NULL); + rowstride, (GdkPixbufDestroyNotify)g_free, NULL); //### Fill in the cells with RGB values int x,y; -- cgit v1.2.3 From 1d66df63a0263476b774fe9fe4854afea60489f2 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 30 Jan 2013 18:24:39 +0100 Subject: removing some more unused functions (bzr r12076) --- src/trace/imagemap-gdk.cpp | 75 ---------------------------------------------- 1 file changed, 75 deletions(-) (limited to 'src/trace/imagemap-gdk.cpp') diff --git a/src/trace/imagemap-gdk.cpp b/src/trace/imagemap-gdk.cpp index 06f355de7..7c7139002 100644 --- a/src/trace/imagemap-gdk.cpp +++ b/src/trace/imagemap-gdk.cpp @@ -122,44 +122,6 @@ PackedPixelMap *gdkPixbufToPackedPixelMap(GdkPixbuf *buf) return ppMap; } -/*GdkPixbuf *packedPixelMapToGdkPixbuf(PackedPixelMap *ppMap) -{ - if (!ppMap) - return NULL; - - guchar *pixdata = (guchar *) - malloc(sizeof(guchar) * ppMap->width * ppMap->height * 3); - if (!pixdata) - return NULL; - - int n_channels = 3; - int rowstride = ppMap->width * 3; - - GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, - 0, 8, ppMap->width, ppMap->height, - rowstride, NULL, NULL); //first NULL: replace by (GdkPixbufDestroyNotify)g_free ?? - - //### Fill in the cells with RGB values - int x,y; - int row = 0; - for (y=0 ; yheight ; y++) - { - guchar *p = pixdata + row; - for (x=0 ; xwidth ; x++) - { - unsigned long rgb = ppMap->getPixel(ppMap, x, y); - p[0] = (rgb >> 16) & 0xff; - p[1] = (rgb >> 8) & 0xff; - p[2] = (rgb ) & 0xff; - p += n_channels; - } - row += rowstride; - } - - return buf; -} -*/ - /*######################################################################### ## R G B M A P @@ -203,44 +165,7 @@ RgbMap *gdkPixbufToRgbMap(GdkPixbuf *buf) return rgbMap; } -/* -GdkPixbuf *rgbMapToGdkPixbuf(RgbMap *rgbMap) -{ - if (!rgbMap) - return NULL; - - guchar *pixdata = (guchar *) - malloc(sizeof(guchar) * rgbMap->width * rgbMap->height * 3); - if (!pixdata) - return NULL; - - int n_channels = 3; - int rowstride = rgbMap->width * 3; - - GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB, - 0, 8, rgbMap->width, rgbMap->height, - rowstride, NULL, NULL); //first NULL: replace by (GdkPixbufDestroyNotify)g_free ?? - - //### Fill in the cells with RGB values - int x,y; - int row = 0; - for (y=0 ; yheight ; y++) - { - guchar *p = pixdata + row; - for (x=0 ; xwidth ; x++) - { - RGB rgb = rgbMap->getPixel(rgbMap, x, y); - p[0] = rgb.r & 0xff; - p[1] = rgb.g & 0xff; - p[2] = rgb.b & 0xff; - p += n_channels; - } - row += rowstride; - } - return buf; -} -*/ /*######################################################################### ## I N D E X E D M A P -- cgit v1.2.3 From 26e21f069d05a0ba22ec97a54bb541ff7346196d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 19 Sep 2013 17:52:21 +0200 Subject: Fix colors when tracing (bzr r12541) --- src/trace/imagemap-gdk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/trace/imagemap-gdk.cpp') diff --git a/src/trace/imagemap-gdk.cpp b/src/trace/imagemap-gdk.cpp index 7c7139002..298414074 100644 --- a/src/trace/imagemap-gdk.cpp +++ b/src/trace/imagemap-gdk.cpp @@ -152,9 +152,9 @@ RgbMap *gdkPixbufToRgbMap(GdkPixbuf *buf) { int alpha = (int)p[3]; int white = 255 - alpha; - int r = (int)p[2]; r = r * alpha / 256 + white; + int r = (int)p[0]; r = r * alpha / 256 + white; int g = (int)p[1]; g = g * alpha / 256 + white; - int b = (int)p[0]; b = b * alpha / 256 + white; + int b = (int)p[2]; b = b * alpha / 256 + white; rgbMap->setPixel(rgbMap, x, y, r, g, b); p += n_channels; -- cgit v1.2.3