From d1097f76c834b9eeb4036e97b3c214550ed23706 Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde Date: Sun, 28 Dec 2008 12:36:13 +0000 Subject: Makes sure a Gaussian filter is applied to premultiplied data. (bzr r7028) --- src/libnr/nr-pixblock.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/libnr/nr-pixblock.cpp') diff --git a/src/libnr/nr-pixblock.cpp b/src/libnr/nr-pixblock.cpp index 8d2e930ef..6b2b12b7b 100644 --- a/src/libnr/nr-pixblock.cpp +++ b/src/libnr/nr-pixblock.cpp @@ -5,6 +5,7 @@ * * Authors: * (C) 1999-2002 Lauris Kaplinski + * 2008, Jasper van de Gronde * * This code is in the Public Domain */ @@ -213,7 +214,7 @@ nr_pixblock_release (NRPixBlock *pb) * * \return Pointer to fresh pixblock. * Calls g_new() and nr_pixblock_setup(). -FIXME: currently unused, delete? +FIXME: currently unused, delete? JG: Should be used more often! (To simplify memory management.) */ NRPixBlock * nr_pixblock_new (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear) @@ -221,12 +222,40 @@ nr_pixblock_new (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool cle NRPixBlock *pb; pb = g_new (NRPixBlock, 1); + if (!pb) return 0; nr_pixblock_setup (pb, mode, x0, y0, x1, y1, clear); + if (pb->size!=NR_PIXBLOCK_SIZE_TINY && !pb->data.px) { + g_free(pb); + return 0; + } return pb; } +/** + * Allocates NRPixBlock and sets it up. + * + * \return Pointer to fresh pixblock. + * Calls g_new() and nr_pixblock_setup(). + */ +NRPixBlock * +nr_pixblock_new_fast (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear) +{ + NRPixBlock *pb; + + pb = g_new (NRPixBlock, 1); + if (!pb) return 0; + + nr_pixblock_setup_fast (pb, mode, x0, y0, x1, y1, clear); + if (pb->size!=NR_PIXBLOCK_SIZE_TINY && !pb->data.px) { + g_free(pb); + return 0; + } + + return pb; +} + /** * Frees all memory taken by pixblock. * -- cgit v1.2.3