]> source.dussan.org Git - tigervnc.git/commitdiff
Moved ScaleFilters class methods and 1-d filter functions
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sun, 29 Oct 2006 11:09:43 +0000 (11:09 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sun, 29 Oct 2006 11:09:43 +0000 (11:09 +0000)
to ScaleFilters.cxx file.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2113 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/rfb/ScaleFilters.cxx [new file with mode: 0644]
common/rfb/ScaleFilters.h
common/rfb/rfb.dsp

diff --git a/common/rfb/ScaleFilters.cxx b/common/rfb/ScaleFilters.cxx
new file mode 100644 (file)
index 0000000..d5530b7
--- /dev/null
@@ -0,0 +1,87 @@
+/* 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
+#include <string.h>\r
+#include <assert.h>\r
+#include <math.h>\r
+\r
+#include <rfb/ScaleFilters.h>\r
+\r
+using namespace rfb;\r
+\r
+//\r
+// -=- 1-D filters functions\r
+//\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
+\r
+//\r
+// -=- ScaleFilters class\r
+//\r
+\r
+SFilter &ScaleFilters::operator[](unsigned int filter_id) {\r
+  assert(filter_id < scaleFilterMaxNumber);\r
+  return filters[filter_id];\r
+}\r
+\r
+void ScaleFilters::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 ScaleFilters::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
+}
\ No newline at end of file
index d4da3652cc6d53d601afaafd3c152afad8da5fb3..0ec0730db00b232397e7e799cf1fc6db822aa99b 100644 (file)
@@ -22,9 +22,6 @@
 //  \r
 // \r
 \r
-#include <assert.h>\r
-#include <math.h>\r
-\r
 namespace rfb {\r
 \r
   typedef double (*filter_func)(double x);\r
@@ -38,42 +35,6 @@ namespace rfb {
 \r
   const unsigned int scaleFilterMaxNumber = 3;\r
 \r
-  //\r
-  // -=- 1-D filters functions\r
-  //\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
   //\r
   // -=- Scale filters structures and routines\r
   //\r
@@ -97,27 +58,12 @@ namespace rfb {
   public:\r
     ScaleFilters() { initFilters(); };\r
 \r
-    SFilter &operator[](unsigned int filter_id) {\r
-      assert(filter_id < scaleFilterMaxNumber);\r
-      return filters[filter_id];\r
-    }\r
+    SFilter &operator[](unsigned int filter_id);\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
+    void initFilters();\r
+\r
+    SFilter create(char *name_, double radius_, filter_func func_);\r
 \r
     SFilter filters[scaleFilterMaxNumber+1];\r
   };\r
index b8f6e47baade13d17d0b249ff92e088787a5d9fb..cfabeba0ae977f42d67ebf4cca4e1d05ee4fd2aa 100644 (file)
@@ -275,6 +275,10 @@ SOURCE=.\ScaledPixelBuffer.cxx
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\ScaleFilters.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\SConnection.cxx\r
 # End Source File\r
 # Begin Source File\r