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 9be6758838682bf96a52cf189f94b81f18441e80 (commit) via 5309636e9487a4547fe4fe1f4bf798c0174ab575 (commit) from aa8f80b7334e88d72171f325bb37cfc4b2245d0e (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/9be6758838682bf96a52cf189f94b81f18441...
commit 9be6758838682bf96a52cf189f94b81f18441e80 Author: Cyril Hrubis metan@ucw.cz Date: Mon Oct 31 15:15:31 2011 +0100
More docs for filters.
diff --git a/doc/filters.txt b/doc/filters.txt index 0f54e7a..d806786 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -84,9 +84,48 @@ void GP_FilterFoo_Raw(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback); -------------------------------------------------------------------------------
-Rotation and Symmetries +Point operation filters ~~~~~~~~~~~~~~~~~~~~~~~
+Point operations are filters that works with pixels as with independent values +(the value of destination pixel depends only on the pixel on the same +coodrdinates in source image). All of these filters works 'in-place' and the +result has always the same size as the source. + +[source,c] +------------------------------------------------------------------------------- +#include <GP_Filters.h> + +GP_Context *GP_FilterBrightness(const GP_Context *src, GP_Context *dst, + int32_t inc, GP_ProgressCallback *callback); +------------------------------------------------------------------------------- + +Brightness filter, increments all pixel channels by a fixed value. + +[source,c] +------------------------------------------------------------------------------- +#include <GP_Filters.h> + +GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst, + float mul, GP_ProgressCallback *callback); +------------------------------------------------------------------------------- + +Constrast filter, multiplies all pixel channels by a fixed value. + +[source,c] +------------------------------------------------------------------------------- +#include <GP_Filters.h> + +GP_Context *GP_FilterInvert(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback); +------------------------------------------------------------------------------- + +Inverts the image, for each channel the result value is computed as "chan_max +- val". + +Rotation and Symmetry filters +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + [source,c] ------------------------------------------------------------------------------- #include <GP_Filters.h> @@ -200,3 +239,49 @@ Works 'in-place'.
'TODO:' this filter is implemented for RGB888 only.
+ +Interpolation filters +~~~~~~~~~~~~~~~~~~~~~ + +[source,c] +------------------------------------------------------------------------------- +#include <GP_Filters.h> + +typedef enum GP_InterpolationType { + GP_INTERP_NN, /* Nearest Neighbour */ + GP_INTERP_CUBIC, /* Bicubic */ +} GP_InterpolationType; + +GP_Context *GP_FilterResize(const GP_Context *src, GP_Context *dst, + GP_InterpolationType type, + GP_Size w, GP_Size h, + GP_ProgressCallback *callback); +------------------------------------------------------------------------------- + +Interpolate (resize) the context. + +Doesn't work 'in-place' (this is quite impossible as the size of the bitmap is +changed by the filter). + +If the filter destination is non 'NULL' and the 'w' and 'h' is smaller than the +destination size the source image is interpolated into subcontext of +destination defined by 'w' and 'h'. + +'TODO:' this filter is implemented for RGB888 only. + +Nearest Neighbour Interpolation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Fast, but produces "pixelated" images may however work better for images with +sharp edges mostly consisting of big one colour regions (eg. doesn't blur the +result on upscaling). + +Bicubic Interpolation +^^^^^^^^^^^^^^^^^^^^^ + +Works well as is on image upscaling. To get decent result on downscaling +low-pass filter (gaussian blur) must be used on original image before actuall +downscaling. To do this reasonably fast we could cheat a little first resize +big images a little without the low-past filter, then apply low-pass filter and +finally downscale it to desired size. +
http://repo.or.cz/w/gfxprim.git/commit/5309636e9487a4547fe4fe1f4bf798c0174ab...
commit 5309636e9487a4547fe4fe1f4bf798c0174ab575 Author: Cyril Hrubis metan@ucw.cz Date: Mon Oct 31 15:06:55 2011 +0100
Fixed the point filters API.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index 3582c38..51c362b 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -279,7 +279,7 @@ static GP_RetCode bright(GP_Context **c, const char *params) return GP_EINVAL; }
- GP_FilterBrightness_Raw(*c, *c, bright); + GP_FilterBrightness(*c, *c, bright, progress_callback);
return GP_ESUCCESS; } @@ -303,7 +303,7 @@ static GP_RetCode contrast(GP_Context **c, const char *params) return GP_EINVAL; }
- GP_FilterContrast_Raw(*c, *c, mul); + GP_FilterContrast(*c, *c, mul, progress_callback);
return GP_ESUCCESS; } @@ -319,7 +319,7 @@ static GP_RetCode invert(GP_Context **c, const char *params) if (param_parse(params, invert_params, "invert", param_err)) return GP_EINVAL;
- GP_FilterInvert_Raw(*c, *c); + GP_FilterInvert(*c, *c, progress_callback);
return GP_ESUCCESS; } diff --git a/include/SDL/GP_SDL.h b/include/SDL/GP_SDL.h index a5967c2..d01bd1e 100644 --- a/include/SDL/GP_SDL.h +++ b/include/SDL/GP_SDL.h @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -28,7 +28,6 @@
#include <SDL/SDL.h>
-#include "GP.h" #include "GP_SDL_Context.h" #include "GP_SDL_VideoInit.h"
diff --git a/include/filters/GP_Filter.h b/include/filters/GP_Filter.h index cc9918d..20d323c 100644 --- a/include/filters/GP_Filter.h +++ b/include/filters/GP_Filter.h @@ -26,8 +26,8 @@
*/
-#ifndef GP_FILTER_H -#define GP_FILTER_H +#ifndef GP_FILTERS_FILTER_H +#define GP_FILTERS_FILTER_H
#include "core/GP_Context.h"
@@ -55,4 +55,4 @@ static inline void GP_ProgressCallbackDone(GP_ProgressCallback *callback) GP_ProgressCallbackReport(callback, 100); }
-#endif /* GP_FILTER_H */ +#endif /* FILTERS_GP_FILTER_H */ diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h index b5e7d50..c5b53a8 100644 --- a/include/filters/GP_Point.h +++ b/include/filters/GP_Point.h @@ -26,32 +26,42 @@
*/
-#ifndef GP_POINT_H -#define GP_POINT_H +#ifndef FILTERS_GP_POINT_H +#define FILTERS_GP_POINT_H
-#include "core/GP_Context.h" +#include "GP_Filter.h"
/* * Brightness filter. + * + * Increments each pixel channel by a given value. */ -void GP_FilterBrightness_Raw(const GP_Context *src, GP_Context *res, - int32_t inc); +void GP_FilterBrightness_Raw(const GP_Context *src, GP_Context *dst, + int32_t inc, GP_ProgressCallback *callback);
-GP_Context *GP_FilterBrightness(const GP_Context *src, int32_t inc); +GP_Context *GP_FilterBrightness(const GP_Context *src, GP_Context *dst, + int32_t inc, GP_ProgressCallback *callback);
/* * Contrast filter. + * + * Multiplies each pixel channel by a given value. */ -GP_Context *GP_FilterContrast_Raw(const GP_Context *src, GP_Context *res, - float mul); +GP_Context *GP_FilterContrast_Raw(const GP_Context *src, GP_Context *dst, + float mul, GP_ProgressCallback *callback);
-GP_Context *GP_FilterContrast(const GP_Context *src, float mul); +GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst, + float mul, GP_ProgressCallback *callback);
/* * Invert filter. + * + * Inverts each pixel channel (eg. val = max - val) */ -GP_Context *GP_FilterInvert_Raw(const GP_Context *src, GP_Context *res); +GP_Context *GP_FilterInvert_Raw(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback);
-GP_Context *GP_FilterInvert(const GP_Context *src); +GP_Context *GP_FilterInvert(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback);
-#endif /* GP_POINT_H */ +#endif /* FILTERS_GP_POINT_H */ diff --git a/pylib/templates/filter.point.c.t b/pylib/templates/filter.point.c.t index 271418c..4c3bdaa 100644 --- a/pylib/templates/filter.point.c.t +++ b/pylib/templates/filter.point.c.t @@ -3,10 +3,11 @@ {% macro maybe_opts(opts) %}{% if opts %}, {{ opts }}{% endif %}{% endmacro %}
%% macro filter_include() -#include <GP_Context.h> -#include <GP_Pixel.h> -#include <GP_GetPutPixel.h> -#include <GP_Debug.h> +#include "core/GP_Context.h" +#include "core/GP_Pixel.h" +#include "core/GP_GetPutPixel.h" +#include "core/GP_Debug.h" +#include "GP_Filter.h" %% endmacro
/* @@ -15,7 +16,8 @@ %% macro filter_per_pixel_size(name, opts="") %% for ps in pixelsizes %% if ps.size <= 8 and ps.size > 1 -void GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src, GP_Context *res{{ maybe_opts(opts) }}) +void GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst{{ maybe_opts(opts) }}, + GP_ProgressCallback *callback) { uint32_t x, y;
@@ -23,9 +25,14 @@ void GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src, GP_Context *res{ for (x = 0; x < src->w; x++) { int32_t pix = GP_GetPixel_Raw_{{ ps.suffix }}(src, x, y); {{ caller(ps) }} - GP_PutPixel_Raw_{{ ps.suffix }}(res, x, y, pix); + GP_PutPixel_Raw_{{ ps.suffix }}(dst, x, y, pix); } + + if (callback != NULL && y % 100 == 0) + GP_ProgressCallbackReport(callback, 100.00 * y/src->h); } + + GP_ProgressCallbackDone(callback); } %% endif %% endfor @@ -37,11 +44,12 @@ void GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src, GP_Context *res{ %% macro filter_per_pixel_type(name, opts="") %% for pt in pixeltypes %% if not pt.is_unknown() and len(pt.chanslist) > 1 -void GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src, GP_Context *res{{ maybe_opts(opts) }}) +void GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src, GP_Context *dst{{ maybe_opts(opts) }}, + GP_ProgressCallback *callback) { uint32_t x, y;
- for (y = 0; y < src->h; y++) + for (y = 0; y < src->h; y++) { for (x = 0; x < src->w; x++) { GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x, y); %% for c in pt.chanslist @@ -54,8 +62,14 @@ void GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src, GP_Context *res{{
pix = GP_Pixel_CREATE_{{ pt.name }}({{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, {{ c[0] }}{% endfor %}); - GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(res, x, y, pix); + GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, pix); } + + if (callback != NULL && y % 100 == 0) + GP_ProgressCallbackReport(callback, 100.00 * y/src->h); + } + + GP_ProgressCallbackDone(callback); }
%% endif @@ -77,7 +91,8 @@ void GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src, GP_Context *res{{ * Switch per pixel sizes or pixel types. */ %% macro filter_functions(name, opts="", params="", fmt="") -void GP_Filter{{ name }}_Raw(const GP_Context *src, GP_Context *res{{ maybe_opts(opts) }}) +void GP_Filter{{ name }}_Raw(const GP_Context *src, GP_Context *dst{{ maybe_opts(opts) }}, + GP_ProgressCallback *callback) { GP_DEBUG(1, "Running filter {{ name }} {{ fmt }}"{{ maybe_opts(params) }});
@@ -87,9 +102,9 @@ void GP_Filter{{ name }}_Raw(const GP_Context *src, GP_Context *res{{ maybe_opts %% if pt.is_unknown() or pt.pixelsize.size < 2 return; %% elif len(pt.chanslist) == 1: - GP_Filter{{ name }}_{{ pt.pixelsize.suffix }}(src, res{{ maybe_opts(params) }}); + GP_Filter{{ name }}_{{ pt.pixelsize.suffix }}(src, dst{{ maybe_opts(params) }}, callback); %% else - GP_Filter{{ name }}_{{ pt.name }}(src, res{{ maybe_opts(params) }}); + GP_Filter{{ name }}_{{ pt.name }}(src, dst{{ maybe_opts(params) }}, callback); %% endif break; %% endfor @@ -98,18 +113,25 @@ void GP_Filter{{ name }}_Raw(const GP_Context *src, GP_Context *res{{ maybe_opts } }
-GP_Context *GP_Filter{{ name }}(const GP_Context *src{{ maybe_opts(opts) }}) +GP_Context *GP_Filter{{ name }}(const GP_Context *src, GP_Context *dst{{ maybe_opts(opts) }}, + GP_ProgressCallback *callback) { - GP_Context *res;
- res = GP_ContextCopy(src, 0); + if (dst == NULL) { + dst = GP_ContextCopy(src, 0);
- if (res == NULL) - return NULL; + if (dst == NULL) + return NULL; + } else { + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + GP_ASSERT(src->w <= dst->w && src->h <= dst->h, + "Destination is not big enough"); + }
- GP_Filter{{ name }}_Raw(src, res{{ maybe_opts(params) }}); + GP_Filter{{ name }}_Raw(src, dst{{ maybe_opts(params) }}, callback);
- return res; + return dst; } %% endmacro
diff --git a/tests/SDL/showimage.c b/tests/SDL/showimage.c index b043b72..134f8f9 100644 --- a/tests/SDL/showimage.c +++ b/tests/SDL/showimage.c @@ -50,7 +50,7 @@ void event_loop(void) case SDLK_DOWN: brightness-=1;
- res = GP_FilterBrightness(bitmap, brightness); + res = GP_FilterBrightness(bitmap, NULL, brightness, NULL); printf("brightness = %i %ux%un", brightness, res->w, res->h);
-----------------------------------------------------------------------
Summary of changes: demos/grinder/grinder.c | 6 +- doc/filters.txt | 87 +++++++++++++++++++++++++++++++++++++- include/SDL/GP_SDL.h | 3 +- include/filters/GP_Filter.h | 6 +- include/filters/GP_Point.h | 34 ++++++++++----- pylib/templates/filter.point.c.t | 60 ++++++++++++++++++-------- tests/SDL/showimage.c | 2 +- 7 files changed, 157 insertions(+), 41 deletions(-)
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.