This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, generate has been updated via 8de6ee02d1d25d761c590a1bdaeb142fd04191e3 (commit) from 7765fb749d234f875480769baba4b8c3c4919a0d (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/8de6ee02d1d25d761c590a1bdaeb142fd0419...
commit 8de6ee02d1d25d761c590a1bdaeb142fd04191e3 Author: Cyril Hrubis metan@ucw.cz Date: Sat Oct 1 02:06:24 2011 +0200
First simple linear blur.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index 78d33d7..803570d 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -291,6 +291,28 @@ static GP_RetCode invert(GP_Context **c, const char *params) return GP_ESUCCESS; }
+static struct param blur_params[] = { + {NULL, 0, NULL, NULL, NULL} +}; + +static GP_RetCode blur(GP_Context **c, const char *params) +{ + if (param_parse(params, blur_params, "blur", param_err)) + return GP_EINVAL; + + GP_Context *res = NULL; + + res = GP_FilterBlur(*c); + + if (res == NULL) + return GP_EINVAL; + + GP_ContextFree(*c); + *c = res; + + return GP_ESUCCESS; +} + /* filters */
struct filter { @@ -307,6 +329,7 @@ static struct filter filter_table[] = { {"bright", "alter image brightness", bright_params, bright}, {"contrast", "alter image contrast", contrast_params, contrast}, {"invert", "inverts image", invert_params, invert}, + {"blur", "gaussian blur", blur_params, blur}, {NULL, NULL, NULL, NULL} };
diff --git a/include/filters/GP_Filters.h b/include/filters/GP_Filters.h index 4c1304d..fc498b0 100644 --- a/include/filters/GP_Filters.h +++ b/include/filters/GP_Filters.h @@ -36,6 +36,7 @@ #include "filters/GP_Rotate.h"
#include "filters/GP_Point.h" +#include "filters/GP_Linear.h"
/* Image down and up scaling */ #include "filters/GP_Scale.h" diff --git a/include/filters/GP_Filters.h b/include/filters/GP_Linear.h similarity index 76% copy from include/filters/GP_Filters.h copy to include/filters/GP_Linear.h index 4c1304d..2ef5a0e 100644 --- a/include/filters/GP_Filters.h +++ b/include/filters/GP_Linear.h @@ -16,28 +16,21 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/*
- GP_Context filters. + Linear filters.
*/
-#ifndef GP_FILTERS_H -#define GP_FILTERS_H - -/* Image rotations (90 180 270 grads) and mirroring */ -#include "filters/GP_Rotate.h" +#ifndef GP_LINEAR_H +#define GP_LINEAR_H
-#include "filters/GP_Point.h" +#include <GP_Context.h>
-/* Image down and up scaling */ -#include "filters/GP_Scale.h" +GP_Context *GP_FilterBlur(GP_Context *src);
-#endif /* GP_FILTERS_H */ +#endif /* GP_LINEAR_H */ diff --git a/libs/filters/GP_Linear.c b/libs/filters/GP_Linear.c new file mode 100644 index 0000000..66c0db6 --- /dev/null +++ b/libs/filters/GP_Linear.c @@ -0,0 +1,150 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <GP_Context.h> +#include <GP_GetPutPixel.h> + +#include <GP_Debug.h> + +#include <GP_Linear.h> + +static float HX[] = {0.17, 0.66, 0.17}; +static float HY[] = {0.17, 0.66, 0.17}; + +GP_Context *GP_FilterBlur(GP_Context *src) +{ + GP_Context *dst; + + if (src->pixel_type != GP_PIXEL_RGB888) + return NULL; + + dst = GP_ContextCopy(src, 0); + + if (dst == NULL) + return NULL; + + GP_DEBUG(1, "Linear blur filter (3x3 kernel) %ux%u", src->w, src->h); + + GP_Coord x, y; + + for (y = 0; y < (GP_Coord)dst->h; y++) { + GP_Pixel pix; + uint32_t R1, R2, R3; + uint32_t G1, G2, G3; + uint32_t B1, B2, B3; + + pix = GP_GetPixel_Raw_24BPP(src, 0, y); + + R1 = GP_Pixel_GET_R_RGB888(pix); + G1 = GP_Pixel_GET_G_RGB888(pix); + B1 = GP_Pixel_GET_B_RGB888(pix); + + R2 = R1; + G2 = G1; + B2 = B1; + + for (x = 0; x < (GP_Coord)dst->w; x++) { + float r, g, b; + + pix = GP_GetPixel_Raw_24BPP(src, x, y); + + R3 = GP_Pixel_GET_R_RGB888(pix); + G3 = GP_Pixel_GET_G_RGB888(pix); + B3 = GP_Pixel_GET_B_RGB888(pix); + + r = R1 * HX[0] + R2 * HX[1] + R3 * HX[2]; + g = G1 * HX[0] + G2 * HX[1] + G3 * HX[2]; + b = B1 * HX[0] + B2 * HX[1] + B3 * HX[2]; + + if (r > 255) + r = 255; + if (g > 255) + g = 255; + if (b > 255) + b = 255; + + pix = GP_Pixel_CREATE_RGB888((uint32_t)r, (uint32_t)g, (uint32_t)b); + + GP_PutPixel_Raw_24BPP(dst, x, y, pix); + + R1 = R2; + G1 = G2; + B1 = B2; + + R2 = R3; + G2 = G3; + B2 = B3; + } + } + + for (x = 0; x < (GP_Coord)dst->w; x++) { + GP_Pixel pix; + uint32_t R1, R2, R3; + uint32_t G1, G2, G3; + uint32_t B1, B2, B3; + + pix = GP_GetPixel_Raw_24BPP(src, x, 0); + + R1 = GP_Pixel_GET_R_RGB888(pix); + G1 = GP_Pixel_GET_G_RGB888(pix); + B1 = GP_Pixel_GET_B_RGB888(pix); + + R2 = R1; + G2 = G1; + B2 = B1; + + for (y = 0; y < (GP_Coord)dst->h; y++) { + float r, g, b; + + pix = GP_GetPixel_Raw_24BPP(src, x, y); + + R3 = GP_Pixel_GET_R_RGB888(pix); + G3 = GP_Pixel_GET_G_RGB888(pix); + B3 = GP_Pixel_GET_B_RGB888(pix); + + r = R1 * HY[0] + R2 * HY[1] + R3 * HY[2]; + g = G1 * HY[0] + G2 * HY[1] + G3 * HY[2]; + b = B1 * HY[0] + B2 * HY[1] + B3 * HY[2]; + + if (r > 255) + r = 255; + if (g > 255) + g = 255; + if (b > 255) + b = 255; + + pix = GP_Pixel_CREATE_RGB888((uint32_t)r, (uint32_t)g, (uint32_t)b); + + GP_PutPixel_Raw_24BPP(dst, x, y, pix); + + R1 = R2; + G1 = G2; + B1 = B2; + + R2 = R3; + G2 = G3; + B2 = B3; + } + } + + return dst; +}
-----------------------------------------------------------------------
Summary of changes: demos/grinder/grinder.c | 23 +++ include/filters/GP_Filters.h | 1 + .../core/GP_Debug.c => include/filters/GP_Linear.h | 21 ++-- libs/filters/GP_Linear.c | 150 ++++++++++++++++++++ 4 files changed, 185 insertions(+), 10 deletions(-) copy libs/core/GP_Debug.c => include/filters/GP_Linear.h (88%) create mode 100644 libs/filters/GP_Linear.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.