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, master has been updated via cb3020fdd8ac170c98633ace520842f3c7d72896 (commit) via 46abc0f23eeb1e9eb0b437a801ef0faf829e4fdd (commit) via 6eba23eed3866d61f6416fe090b7df420b015c9c (commit) via 4094a3e9d20c3bb436c89af9ca80a2d3d232e335 (commit) via fbeb1a090772e74c6b8fefa7d46a80be03914aab (commit) from 59508f340d3fd1d02e11371c913d4e7656f8ce4f (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/cb3020fdd8ac170c98633ace520842f3c7d72...
commit cb3020fdd8ac170c98633ace520842f3c7d72896 Author: Cyril Hrubis metan@ucw.cz Date: Tue Aug 27 00:14:04 2013 +0200
loaders: JPG: Fix cinfo init for GP_SaveJPG()
Set correctly color space and number of components.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c index 097308b..e48c864 100644 --- a/libs/loaders/GP_JPG.c +++ b/libs/loaders/GP_JPG.c @@ -439,8 +439,20 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
cinfo.image_width = src->w; cinfo.image_height = src->h; - cinfo.input_components = src->pixel_type == GP_PIXEL_RGB888 ? 3 : 1; - cinfo.in_color_space = JCS_RGB; + + switch (src->pixel_type) { + case GP_PIXEL_RGB888: + case GP_PIXEL_BGR888: + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; + break; + case GP_PIXEL_G8: + cinfo.input_components = 1; + cinfo.in_color_space = JCS_GRAYSCALE; + break; + default: + GP_BUG("Don't know how to set color_space and compoments"); + }
jpeg_set_defaults(&cinfo);
http://repo.or.cz/w/gfxprim.git/commit/46abc0f23eeb1e9eb0b437a801ef0faf829e4...
commit 46abc0f23eeb1e9eb0b437a801ef0faf829e4fdd Author: Cyril Hrubis metan@ucw.cz Date: Mon Aug 26 23:57:50 2013 +0200
filters: ResizeCubicFloat: Set errno.
Set errno to ENOSYS on currently unimplemented GP_PixelType.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/filters/GP_ResizeCubicFloat.c b/libs/filters/GP_ResizeCubicFloat.c index f16ab7a..908e328 100644 --- a/libs/filters/GP_ResizeCubicFloat.c +++ b/libs/filters/GP_ResizeCubicFloat.c @@ -21,6 +21,7 @@ *****************************************************************************/
#include <math.h> +#include <errno.h>
#include "core/GP_Context.h" #include "core/GP_GetPutPixel.h" @@ -81,8 +82,10 @@ int GP_FilterResizeCubic(const GP_Context *src, GP_Context *dst, float col_r[src->h], col_g[src->h], col_b[src->h]; uint32_t i, j;
- if (src->pixel_type != GP_PIXEL_RGB888 || dst->pixel_type != GP_PIXEL_RGB888) + if (src->pixel_type != GP_PIXEL_RGB888 || dst->pixel_type != GP_PIXEL_RGB888) { + errno = ENOSYS; return 1; + }
GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f", src->w, src->h, dst->w, dst->h,
http://repo.or.cz/w/gfxprim.git/commit/6eba23eed3866d61f6416fe090b7df420b015...
commit 6eba23eed3866d61f6416fe090b7df420b015c9c Author: Cyril Hrubis metan@ucw.cz Date: Sun Aug 25 16:18:02 2013 +0200
pywrap: filters: Update filters wrappings.
* Add the wrongly removed core import back (fixes GP_Size map to int in swig)
* Add exceptions on filter failure
* Add filter submodule
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/py_simple/blur.py b/demos/py_simple/blur.py index 478af96..3735346 100755 --- a/demos/py_simple/blur.py +++ b/demos/py_simple/blur.py @@ -15,7 +15,7 @@ def main(): # Load Image img = loaders.Load(sys.argv[2]) # Do in-place gaussian blur - filters.FilterGaussianBlur(img, img, radii, radii, None) + filters.GaussianBlur(img, img, radii, radii, None) # Save result loaders.SaveJPG(img, "out.jpg", None)
diff --git a/demos/py_simple/dither.py b/demos/py_simple/dither.py index e40221e..d7ca1b8 100755 --- a/demos/py_simple/dither.py +++ b/demos/py_simple/dither.py @@ -13,7 +13,7 @@ def main(): # Load Image img = loaders.Load(sys.argv[1]) # Use Floyd-Steinberg dithering - res = filters.FilterFloydSteinberg_RGB888_Alloc(img, core.C.PIXEL_G1, None) + res = filters.FloydSteinberg_RGB888_Alloc(img, core.C.PIXEL_G1, None) # Save result into grayscale png res.loaders.SavePNG("out.png")
diff --git a/demos/py_simple/progress_callback.py b/demos/py_simple/progress_callback.py index f712faf..b4b0b3e 100755 --- a/demos/py_simple/progress_callback.py +++ b/demos/py_simple/progress_callback.py @@ -26,7 +26,7 @@ def main(): exit(1)
try: - img = filters.FilterGaussianBlurAlloc(img, 50, 50, callback) + img = img.filters.GaussianBlurAlloc(50, 50, callback) print('') except OSError: print("Filter Aborted") diff --git a/demos/py_simple/rotate90.py b/demos/py_simple/resize.py similarity index 80% copy from demos/py_simple/rotate90.py copy to demos/py_simple/resize.py index 099fb51..b9e65c1 100755 --- a/demos/py_simple/rotate90.py +++ b/demos/py_simple/resize.py @@ -15,8 +15,8 @@ def main():
# Load Image src = loaders.Load(sys.argv[1]) - # Rotate by 90 degrees - res = filters.FilterRotate90Alloc(src, None) + # Resize image to the half of the original + res = src.filters.ResizeAlloc(src.w//2, src.h//2, 2, None) # Save Image res.loaders.Save(sys.argv[2])
diff --git a/demos/py_simple/rotate90.py b/demos/py_simple/rotate90.py index 099fb51..2dcb3f5 100755 --- a/demos/py_simple/rotate90.py +++ b/demos/py_simple/rotate90.py @@ -16,7 +16,7 @@ def main(): # Load Image src = loaders.Load(sys.argv[1]) # Rotate by 90 degrees - res = filters.FilterRotate90Alloc(src, None) + res = src.filters.Rotate90Alloc(None) # Save Image res.loaders.Save(sys.argv[2])
diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py index f847331..4ce1880 100644 --- a/pylib/gfxprim/filters/__init__.py +++ b/pylib/gfxprim/filters/__init__.py @@ -1,16 +1,50 @@ +""" +Module extending the Context class with .filter submodule. + +Use as in "import gfxprim.filters; context_foo.filter.Resize(...)" +""" + +# Import the SWIG wrapper from . import c_filters
def _init(module): "Extend Context with filters submodule"
+ from ..utils import extend_submodule + from ..core import Context as _context + + # New Context submodule + class FiltersSubmodule(object): + def __init__(self, ctx): + self.ctx = ctx + + _context._submodules['filters'] = FiltersSubmodule + + for name in ['Resize', 'ResizeAlloc', + 'Rotate90', 'Rotate90Alloc', + 'Rotate180', 'Rotate180Alloc', + 'Rotate270', 'Rotate270Alloc', + 'MirrorH', 'MirrorHAlloc', + 'MirrorV', 'MirrorVAlloc', + 'Addition', 'Multiply', 'Difference', 'Max', 'Min', + 'GaussianBlur', 'GaussianBlurAlloc', + 'GaussianBlurEx', 'GaussianBlurExAlloc', + 'GaussianNoiseAdd', 'GaussianNoiseAddAlloc', + 'GaussianNoiseAddEx', 'GaussianNoiseAddExAlloc', + 'Laplace', 'LaplaceAlloc', + 'EdgeSharpening', 'EdgeSharpeningAlloc', + 'Median', 'MedianAlloc', 'MedianEx', 'MedianExAlloc', + 'Sigma', 'SigmaAlloc', 'SigmaEx', 'SigmaExAlloc']: + extend_submodule(FiltersSubmodule, name, c_filters.__getattribute__('GP_Filter' + name)) + # Imports from the SWIG module import re - def strip_GP(s): - return re.sub('^GP_', '', s) + def strip_GP_Filter(s): + return re.sub('^GP_Filter', '', s)
# Import functions from the SWIG module from ..utils import import_members - import_members(c_filters, module, sub=strip_GP, + import_members(c_filters, module, sub=strip_GP_Filter, include=[ '^GP_Filter.*Alloc', '^GP_Filter[A-Za-z0-9]*$', diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i index d803993..9610342 100644 --- a/pylib/gfxprim/filters/filters.i +++ b/pylib/gfxprim/filters/filters.i @@ -6,31 +6,18 @@ #include "core/GP_Debug.h" %}
-/* Listed in GP_Filters.h: */ -%include "GP_Point.h" -%ignore GP_Histogram::hist; -%include "GP_Stats.h" -%include "GP_Linear.h" - -/* Resize filters */ -ERROR_ON_NONZERO(GP_FilterResize); -%newobject GP_FilterResizeAlloc; -ERROR_ON_NULL(GP_FilterResizeAlloc); -%include "GP_Resize.h" +%import ../core/core.i
-ERROR_ON_NONZERO(GP_FilterResizeNN); -%newobject GP_FilterResizeNNAlloc; -ERROR_ON_NULL(GP_FilterResizeNNAlloc); -%include "GP_ResizeNN.h" - -ERROR_ON_NONZERO(GP_FilterResizeLinearInt); -%newobject GP_FilterResizeLinearIntAlloc; -ERROR_ON_NULL(GP_FilterResizeLinearIntAlloc); -ERROR_ON_NONZERO(GP_FilterResizeLinearLFInt); -%newobject GP_FilterResizeLinearLFIntAlloc; -ERROR_ON_NULL(GP_FilterResizeLinearLFIntAlloc); -%include "GP_ResizeLinear.h" +/* + * Creates allocating and non-allocating filter definitions + */ +%define FILTER_FUNC(funcname) +%newobject GP_Filter ## funcname ## Alloc; +ERROR_ON_NULL(GP_Filter ## funcname ## Alloc); +ERROR_ON_NONZERO(GP_Filter ## funcname); +%enddef
+/* Listed in GP_Filters.h: */ %extend GP_FilterParam { ~GP_FilterParam() { GP_DEBUG(2, "[wrapper] GP_FilterParamFree"); @@ -41,40 +28,79 @@ ERROR_ON_NULL(GP_FilterResizeLinearLFIntAlloc); %newobject GP_FilterParamCreate; %include "GP_FilterParam.h"
-/* Functions returning new allocated context */ -%immutable GP_FilterSymmetryNames; +/* TODO: Point filters, once fixed */
-%newobject GP_FilterMirrorH_Alloc; -%newobject GP_FilterMirrorV_Alloc; -%newobject GP_FilterRotate90_Alloc; -%newobject GP_FilterRotate180_Alloc; -%newobject GP_FilterRotate270_Alloc; -%newobject GP_FilterSymmetry_Alloc; -%include "GP_Rotate.h" +/* Arithmetic filters */ +FILTER_FUNC(Addition); +FILTER_FUNC(Multiply); +FILTER_FUNC(Difference); +FILTER_FUNC(Max); +FILTER_FUNC(Min); +%include "GP_Arithmetic.h"
-%newobject GP_FilterFloydSteinberg_RGB888_Alloc; -%newobject GP_FilterHilbertPeano_RGB888_Alloc; -%include "GP_Dither.h" +/* TODO: Stats filters */
-%newobject GP_FilterAdditionAlloc; -%newobject GP_FilterMultiplyAlloc; -%newobject GP_FilterDifferenceAlloc; -%newobject GP_FilterMaxAlloc; -%newobject GP_FilterMinAlloc; -%include "GP_Arithmetic.h" +/* Rotations filters */ +FILTER_FUNC(MirrorH); +FILTER_FUNC(MirrorV); +FILTER_FUNC(Rotate90); +FILTER_FUNC(Rotate180); +FILTER_FUNC(Rotate270); +FILTER_FUNC(Symmetry); +%immutable GP_FilterSymmetryNames; +%include "GP_Rotate.h"
-%newobject GP_FilterConvolutionAlloc; -%newobject GP_FilterConvolutionExAlloc; +/* Convolutions */ +FILTER_FUNC(Convolution); +FILTER_FUNC(ConvolutionEx); %include "GP_Convolution.h"
-%newobject GP_FilterBlurAlloc; -%newobject GP_FilterBlurExAlloc; +/* Blur */ +FILTER_FUNC(GaussianBlurEx); +FILTER_FUNC(GaussianBlur); %include "GP_Blur.h"
-%newobject GP_FilterMedianAlloc; -%newobject GP_FilterMedianExAlloc; +/* Resize filters */ +FILTER_FUNC(Resize); +%include "GP_Resize.h" + +FILTER_FUNC(ResizeNN); +%include "GP_ResizeNN.h" + +FILTER_FUNC(ResizeLinearInt); +FILTER_FUNC(ResizeLinearLFInt); +%include "GP_ResizeLinear.h" + +/* TODO: Ditherings */ +%newobject GP_FilterFloydSteinberg_RGB888_Alloc; +ERROR_ON_NULL(GP_FilterFloydSteinberg_RGB888_Alloc); +%newobject GP_FilterHilbertPeano_RGB888_Alloc; +ERROR_ON_NULL(GP_FilterHilbertPeano_RGB888_Alloc); +ERROR_ON_NONZERO(GP_FilterFloydSteinberg_RGB888); +ERROR_ON_NONZERO(GP_FilterHilbertPeano_RGB888); +%include "GP_Dither.h" + +/* Laplace and Laplace Edge Sharpening */ +FILTER_FUNC(Laplace); +FILTER_FUNC(EdgeSharpening); +%include "GP_Laplace.h" + +/* Median */ +FILTER_FUNC(MedianEx); +FILTER_FUNC(Median); %include "GP_Median.h"
-%newobject GP_FilterSigmaAlloc; -%newobject GP_FilterSigmaExAlloc; +/* Weighted Median */ +FILTER_FUNC(WeightedMedianEx); +FILTER_FUNC(WeightedMedian); +%include "GP_WeightedMedian.h" + +/* Sigma filter */ +FILTER_FUNC(GP_FilterSigmaEx); +FILTER_FUNC(GP_FilterSigma); %include "GP_Sigma.h" + +/* Gaussian Noise */ +FILTER_FUNC(GaussianNoiseAddEx); +FILTER_FUNC(GaussianNoiseAdd); +%include "GP_GaussianNoise.h"
http://repo.or.cz/w/gfxprim.git/commit/4094a3e9d20c3bb436c89af9ca80a2d3d232e...
commit 4094a3e9d20c3bb436c89af9ca80a2d3d232e335 Author: Cyril Hrubis metan@ucw.cz Date: Sun Aug 25 15:41:16 2013 +0200
spiv: Skip number of images in dir if not in dir
This fixes spiv to skip info line with current dir position and number of images if the current argument is not directory.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/spiv/image_list.c b/demos/spiv/image_list.c index cef9c8e..9d7a3ff 100644 --- a/demos/spiv/image_list.c +++ b/demos/spiv/image_list.c @@ -366,7 +366,7 @@ unsigned int image_list_pos(struct image_list *self) unsigned int image_list_dir_count(struct image_list *self) { if (!self->in_dir) - return 1; + return 0;
return self->max_file; } @@ -374,7 +374,7 @@ unsigned int image_list_dir_count(struct image_list *self) unsigned int image_list_dir_pos(struct image_list *self) { if (!self->in_dir) - return 1; + return 0;
return self->cur_file; } diff --git a/demos/spiv/image_list.h b/demos/spiv/image_list.h index e2263d0..7835526 100644 --- a/demos/spiv/image_list.h +++ b/demos/spiv/image_list.h @@ -80,12 +80,12 @@ unsigned int image_list_count(struct image_list *self); unsigned int image_list_pos(struct image_list *self);
/* - * Returns numbe of images in current dir or 1 if current arg is file. + * Returns numbe of images in current dir or 0 if current arg is file. */ unsigned int image_list_dir_count(struct image_list *self);
/* - * Returns current position in current dir or 1 if current arg is file. + * Returns current position in current dir or 0 if current arg is file. */ unsigned int image_list_dir_pos(struct image_list *self);
http://repo.or.cz/w/gfxprim.git/commit/fbeb1a090772e74c6b8fefa7d46a80be03914...
commit fbeb1a090772e74c6b8fefa7d46a80be03914aab Author: Cyril Hrubis metan@ucw.cz Date: Thu Aug 22 17:52:57 2013 +0200
filters: Resize: Two fixes.
Two fixes for the resize cleanup:
* Remove now nonexistent GP_FilterResize_Raw from the header
* Fix the order or paramters in demos (it's w, h, interp_type now not the other way)
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index d81cf9f..c406ef5 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -124,7 +124,7 @@ static int resize(GP_Context **c, const char *params) GP_Size h = ratio * (*c)->h; GP_Context *res = NULL;
- res = GP_FilterResizeAlloc(*c, alg, w, h, progress_callback); + res = GP_FilterResizeAlloc(*c, w, h, alg, progress_callback);
if (res == NULL) return EINVAL; @@ -187,7 +187,7 @@ static int scale(GP_Context **c, const char *params)
GP_Context *res = NULL;
- res = GP_FilterResizeAlloc(*c, alg, w, h, progress_callback); + res = GP_FilterResizeAlloc(*c, w, h, alg, progress_callback);
if (res == NULL) return EINVAL; diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 1736b4d..2d4e4ef 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -452,9 +452,9 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
cpu_timer_start(&timer, "Resampling"); callback.priv = "Resampling Image"; - GP_Context *i1 = GP_FilterResizeAlloc(img, params->resampling_method, w, h, &callback); + GP_Context *i1 = GP_FilterResizeAlloc(img, w, h, params->resampling_method, &callback); // img->gamma = NULL; -// GP_Context *i2 = GP_FilterResizeAlloc(img, params->resampling_method, w, h, &callback); +// GP_Context *i2 = GP_FilterResizeAlloc(img, w, h, params->resampling_method, &callback); // img = GP_FilterDifferenceAlloc(i2, i1, NULL); // img = GP_FilterInvert(img, NULL, NULL); img = i1; diff --git a/include/filters/GP_Resize.h b/include/filters/GP_Resize.h index 179d88c..18f4958 100644 --- a/include/filters/GP_Resize.h +++ b/include/filters/GP_Resize.h @@ -68,13 +68,6 @@ typedef enum GP_InterpolationType { const char *GP_InterpolationTypeName(enum GP_InterpolationType interp_type);
/* - * Just interpolate the source context into destination context. - */ -int GP_FilterResize_Raw(const GP_Context *src, GP_Context *dst, - GP_InterpolationType type, - GP_ProgressCallback *callback); - -/* * Resize src to fit the dst, both src and dst must have the same pixel_type. * * Returns non-zero on error (interrupted from callback), zero on success.
-----------------------------------------------------------------------
Summary of changes: demos/grinder/grinder.c | 4 +- demos/py_simple/blur.py | 2 +- demos/py_simple/dither.py | 2 +- demos/py_simple/progress_callback.py | 2 +- demos/py_simple/{rotate90.py => resize.py} | 4 +- demos/py_simple/rotate90.py | 2 +- demos/spiv/image_list.c | 4 +- demos/spiv/image_list.h | 4 +- demos/spiv/spiv.c | 4 +- include/filters/GP_Resize.h | 7 -- libs/filters/GP_ResizeCubicFloat.c | 5 +- libs/loaders/GP_JPG.c | 16 +++- pylib/gfxprim/filters/__init__.py | 40 ++++++++- pylib/gfxprim/filters/filters.i | 124 +++++++++++++++++----------- 14 files changed, 144 insertions(+), 76 deletions(-) copy demos/py_simple/{rotate90.py => resize.py} (80%)
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.