else return sin(pi*x)/(pi*x);\r
}\r
\r
- class ScaleFilter {\r
- public:\r
+ typedef struct {\r
char name[30];\r
- int radius;\r
+ double radius;\r
filter_func func;\r
+ } SFilter;\r
+\r
+ class ScaleFilters {\r
+ public:\r
+ ScaleFilters() { initFilters(); };\r
+\r
+ SFilter &operator[](unsigned int filter_id) {\r
+ return filters[filter_id];\r
+ }\r
+\r
+ protected:\r
+ void initFilters() {\r
+ filters[scaleFilterNearestNeighbor] = create("Nearest neighbor", 0.5, nearest_neighbor);\r
+ filters[scaleFilterBilinear] = create("Bilinear", 1, linear);\r
+ filters[scaleFilterBicubic] = create("Bicubic", 2, cubic);\r
+ filters[scaleFilterSinc] = create("Sinc", 4, sinc);\r
+ }\r
+\r
+ SFilter create(char *name_, double radius_, filter_func func_) {\r
+ SFilter filter;\r
+ strncpy(filter.name, name_, sizeof(filter.name)-1); \r
+ filter.name[sizeof(filter.name)-1] = '\0';\r
+ filter.radius = radius_;\r
+ filter.func = func_;\r
+ return filter;\r
+ }\r
+\r
+ SFilter filters[scaleFiltersMax];\r
};\r
\r
};\r