5 * Copyright (C) 2009-2014 Cyril Hrubis <metan@ucw.cz>
10 #include "core/GP_Pixmap.h"
11 #include "core/GP_GetPutPixel.h"
12 #include "core/GP_Debug.h"
14 #include "filters/GP_ApplyTables.h"
16 @ for pt in pixeltypes:
17 @ if not pt.is_unknown() and not pt.is_palette():
18 static int apply_tables_{{ pt.name }}(const gp_pixmap *const src,
19 gp_coord x_src, gp_coord y_src,
20 gp_size w_src, gp_size h_src,
22 gp_coord x_dst, gp_coord y_dst,
23 const gp_filter_tables *const tables,
24 gp_progress_cb *callback)
26 GP_DEBUG(1, "Point filter %ux%u", w_src, h_src);
30 @ for c in pt.chanslist:
31 gp_pixel {{ c.name }};
34 for (y = 0; y < h_src; y++) {
35 for (x = 0; x < w_src; x++) {
36 unsigned int src_x = x_src + x;
37 unsigned int src_y = y_src + y;
38 unsigned int dst_x = x_dst + x;
39 unsigned int dst_y = y_dst + y;
41 gp_pixel pix = gp_getpixel_raw_{{ pt.pixelsize.suffix }}(src, src_x, src_y);
43 @ for c in pt.chanslist:
44 {{ c.name }} = GP_PIXEL_GET_{{ c[0] }}_{{ pt.name }}(pix);
45 {{ c.name }} = tables->table[{{ c.idx }}][{{ c.name }}];
48 pix = GP_PIXEL_CREATE_{{ pt.name }}({{ arr_to_params(pt.chan_names) }});
49 gp_putpixel_raw_{{ pt.pixelsize.suffix }}(dst, dst_x, dst_y, pix);
52 if (gp_progress_cb_report(callback, y, h_src, w_src)) {
58 gp_progress_cb_done(callback);
65 int gp_filter_tables_apply(const gp_pixmap *const src,
66 gp_coord x_src, gp_coord y_src,
67 gp_size w_src, gp_size h_src,
69 gp_coord x_dst, gp_coord y_dst,
70 const gp_filter_tables *const tables,
71 gp_progress_cb *callback)
73 GP_ASSERT(src->pixel_type == dst->pixel_type);
76 switch (src->pixel_type) {
77 @ for pt in pixeltypes:
78 @ if not pt.is_unknown() and not pt.is_palette():
79 case GP_PIXEL_{{ pt.name }}:
80 return apply_tables_{{ pt.name }}(src, x_src, y_src,