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_FilterTables *const tables,
24 GP_ProgressCallback *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_ProgressCallbackReport(callback, y, h_src, w_src)) {
58 GP_ProgressCallbackDone(callback);
65 int GP_FilterTablesApply(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_FilterTables *const tables,
71 GP_ProgressCallback *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,