1 %% extends "filter.c.t"
3 %% macro filter_stats_include()
9 * Filter per pixel type, used for images with more than one channel per pixel
11 %% macro filter_point_per_channel(name, opts="", filter_op)
12 %% for pt in pixeltypes
13 %% if not pt.is_unknown() and len(pt.chanslist) > 1
14 static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src,
15 {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback)
20 for (y = 0; y < src->h; y++) {
21 for (x = 0; x < src->w; x++) {
22 GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x, y);
23 %% for c in pt.chanslist
24 int32_t {{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix);
27 %% for c in pt.chanslist
28 {{ filter_op(c[0], c[2]) }}
32 if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
36 GP_ProgressCallbackDone(callback);
45 * Point filter per bpp (used for 1 channel pixels to save space).
47 %% macro filter_point_per_bpp(name, opts="", filter_op)
48 %% for ps in pixelsizes
50 static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src,
51 {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback)
56 for (y = 0; y < src->h; y++) {
57 for (x = 0; x < src->w; x++) {
58 int32_t pix = GP_GetPixel_Raw_{{ ps.suffix }}(src, x, y);
59 {{ filter_op('pix', ps.size) }}
62 if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
66 GP_ProgressCallbackDone(callback);
75 * Switch per pixel sizes or pixel types.
77 %% macro filter_functions(name, opts="", params="", fmt="")
78 int GP_Filter{{ name }}_Raw(const GP_Context *src{{ maybe_opts_l(opts) }},
79 GP_ProgressCallback *callback)
81 GP_DEBUG(1, "Running filter {{ name }}");
83 switch (src->pixel_type) {
84 %% for pt in pixeltypes
85 case GP_PIXEL_{{ pt.name }}:
86 %% if pt.is_unknown() or pt.pixelsize.size < 2
88 %% elif len(pt.chanslist) == 1:
90 return GP_Filter{{ name }}_{{ pt.pixelsize.suffix }}(src{{ maybe_opts_l(params) }}, callback);
92 return GP_Filter{{ name }}_{{ pt.name }}(src{{ maybe_opts_l(params) }}, callback);