diff options
| author | Jasper van de Gronde <jasper.vandegronde@gmail.com> | 2008-12-28 12:36:13 +0000 |
|---|---|---|
| committer | jaspervdg <jaspervdg@users.sourceforge.net> | 2008-12-28 12:36:13 +0000 |
| commit | d1097f76c834b9eeb4036e97b3c214550ed23706 (patch) | |
| tree | a13a131d2389ba1c2e44dd24af1684973444c73d /src/libnr/nr-pixblock.cpp | |
| parent | Eliminate unnecessary premultiplied boolean from nr-filter-colormatrix (diff) | |
| download | inkscape-d1097f76c834b9eeb4036e97b3c214550ed23706.tar.gz inkscape-d1097f76c834b9eeb4036e97b3c214550ed23706.zip | |
Makes sure a Gaussian filter is applied to premultiplied data.
(bzr r7028)
Diffstat (limited to 'src/libnr/nr-pixblock.cpp')
| -rw-r--r-- | src/libnr/nr-pixblock.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
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 <lauris@kaplinski.com> + * 2008, Jasper van de Gronde <th.v.d.gonde@hccnet.nl> * * 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,13 +222,41 @@ 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. * * \return NULL |
