--- /dev/null
+/* Copyright (C) 2006 TightVNC Team. All Rights Reserved.\r
+ * \r
+ * This is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * This software is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this software; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\r
+ * USA.\r
+ */\r
+\r
+// -=- ScaleFilters.h\r
+//\r
+// Definitions of the 1-D filters and routines using for the image scaling.\r
+// \r
+// \r
+\r
+#include <math.h>\r
+\r
+namespace rfb {\r
+\r
+ typedef double (*filter_func)(double x);\r
+\r
+ const double pi = 3.14159265358979;\r
+\r
+ const unsigned int scaleFilterNearestNeighbor = 0;\r
+ const unsigned int scaleFilterBilinear = 1;\r
+ const unsigned int scaleFilterBicubic = 2;\r
+ const unsigned int scaleFilterSinc = 3;\r
+\r
+ const unsigned int scaleFiltersMax = 10;\r
+\r
+ // Nearest neighbor filter function\r
+ double nearest_neighbor(double x) {\r
+ if (x < -0.5) return 0.0;\r
+ if (x < 0.5) return 1.0;\r
+ return 0.0;\r
+ }\r
+\r
+ // Linear filter function\r
+ double linear(double x) {\r
+ if (x < -1.0) return 0.0;\r
+ if (x < 0.0) return 1.0+x;\r
+ if (x < 1.0) return 1.0-x;\r
+ return 0.0;\r
+ }\r
+\r
+ // Cubic filter functions\r
+ double cubic(double x) {\r
+ double t;\r
+ if (x < -2.0) return 0.0;\r
+ if (x < -1.0) {t = 2.0+x; return t*t*t/6.0;}\r
+ if (x < 0.0) return (4.0+x*x*(-6.0+x*-3.0))/6.0;\r
+ if (x < 1.0) return (4.0+x*x*(-6.0+x*3.0))/6.0;\r
+ if (x < 2.0) {t = 2.0-x; return t*t*t/6.0;}\r
+ return 0.0;\r
+ }\r
+\r
+ // Sinc filter function\r
+ double sinc(double x) {\r
+ if (x == 0.0) return 1.0;\r
+ else return sin(pi*x)/(pi*x);\r
+ }\r
+\r
+ class ScaleFilter {\r
+ public:\r
+ char name[30];\r
+ int radius;\r
+ filter_func func;\r
+ };\r
+\r
+};\r