aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/ScaleFilters.h
diff options
context:
space:
mode:
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>2006-10-26 15:34:10 +0000
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>2006-10-26 15:34:10 +0000
commit2a4076b3f75980c3ef54bad576bb1db002deee54 (patch)
tree93b491467e341940d03d663e90aa13d0ace4d44b /common/rfb/ScaleFilters.h
parentaab5bc0ee241f387d4bc3d5f97498267be6c87f4 (diff)
downloadtigervnc-2a4076b3f75980c3ef54bad576bb1db002deee54.tar.gz
tigervnc-2a4076b3f75980c3ef54bad576bb1db002deee54.zip
Added definitions of the 1-D filters and routines using
for the image scaling. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2108 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb/ScaleFilters.h')
-rw-r--r--common/rfb/ScaleFilters.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/common/rfb/ScaleFilters.h b/common/rfb/ScaleFilters.h
new file mode 100644
index 00000000..950838a2
--- /dev/null
+++ b/common/rfb/ScaleFilters.h
@@ -0,0 +1,79 @@
+/* Copyright (C) 2006 TightVNC Team. All Rights Reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+// -=- ScaleFilters.h
+//
+// Definitions of the 1-D filters and routines using for the image scaling.
+//
+//
+
+#include <math.h>
+
+namespace rfb {
+
+ typedef double (*filter_func)(double x);
+
+ const double pi = 3.14159265358979;
+
+ const unsigned int scaleFilterNearestNeighbor = 0;
+ const unsigned int scaleFilterBilinear = 1;
+ const unsigned int scaleFilterBicubic = 2;
+ const unsigned int scaleFilterSinc = 3;
+
+ const unsigned int scaleFiltersMax = 10;
+
+ // Nearest neighbor filter function
+ double nearest_neighbor(double x) {
+ if (x < -0.5) return 0.0;
+ if (x < 0.5) return 1.0;
+ return 0.0;
+ }
+
+ // Linear filter function
+ double linear(double x) {
+ if (x < -1.0) return 0.0;
+ if (x < 0.0) return 1.0+x;
+ if (x < 1.0) return 1.0-x;
+ return 0.0;
+ }
+
+ // Cubic filter functions
+ double cubic(double x) {
+ double t;
+ if (x < -2.0) return 0.0;
+ if (x < -1.0) {t = 2.0+x; return t*t*t/6.0;}
+ if (x < 0.0) return (4.0+x*x*(-6.0+x*-3.0))/6.0;
+ if (x < 1.0) return (4.0+x*x*(-6.0+x*3.0))/6.0;
+ if (x < 2.0) {t = 2.0-x; return t*t*t/6.0;}
+ return 0.0;
+ }
+
+ // Sinc filter function
+ double sinc(double x) {
+ if (x == 0.0) return 1.0;
+ else return sin(pi*x)/(pi*x);
+ }
+
+ class ScaleFilter {
+ public:
+ char name[30];
+ int radius;
+ filter_func func;
+ };
+
+};