diff options
author | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2006-11-14 15:59:25 +0000 |
---|---|---|
committer | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2006-11-14 15:59:25 +0000 |
commit | 67e3f57ed23a4530536c44f45ee1bd0d8eab3e3a (patch) | |
tree | 6a99a1cda6e838e26c27a488c80ee9ef7b0454fe /common | |
parent | 378f32ff9a935e2404e466ca70734c67a2419004 (diff) | |
download | tigervnc-67e3f57ed23a4530536c44f45ee1bd0d8eab3e3a.tar.gz tigervnc-67e3f57ed23a4530536c44f45ee1bd0d8eab3e3a.zip |
Added the new method makeWeightTabs to the ScaleFilters
class. It's used to calculate weight coeffs on the scale
filter interval.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2114 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common')
-rw-r--r-- | common/rfb/ScaleFilters.cxx | 27 | ||||
-rw-r--r-- | common/rfb/ScaleFilters.h | 2 |
2 files changed, 28 insertions, 1 deletions
diff --git a/common/rfb/ScaleFilters.cxx b/common/rfb/ScaleFilters.cxx index d5530b72..28fa24f9 100644 --- a/common/rfb/ScaleFilters.cxx +++ b/common/rfb/ScaleFilters.cxx @@ -20,6 +20,7 @@ #include <assert.h>
#include <math.h>
+#include <rfb/Rect.h>
#include <rfb/ScaleFilters.h>
using namespace rfb;
@@ -84,4 +85,28 @@ SFilter ScaleFilters::create(char *name_, double radius_, filter_func func_) { filter.radius = radius_;
filter.func = func_;
return filter;
-}
\ No newline at end of file +}
+
+void ScaleFilters::makeWeightTabs(int filter_id, int src_x, int dst_x, SFilterWeightTab *weightTabs) {
+ double sx;
+ double ratio = dst_x / src_x;
+ SFilter sFilter = filters[filter_id];
+
+ weightTabs = new SFilterWeightTab[dst_x];
+
+ // Make the weight tab for the each dest x position
+ for (int x = 0; x < dst_x; x++) {
+ sx = double(x) / ratio;
+
+ // Calculate the scale filter interval, [i0, i1)
+ int i0 = int(__rfbmin(ceil(sx-sFilter.radius), 0));
+ int i1 = int(__rfbmax(ceil(sx+sFilter.radius), src_x));
+ weightTabs[x].i0 = i0; weightTabs[x].i1 = i1;
+ weightTabs[x].weight = new float[i1-i0];
+
+ // Calculate the weight coeffs on the scale filter interval
+ for (int ci = 0, i = i0; i < i1; i++) {
+ weightTabs[x].weight[ci++] = (float)sFilter.func(float(i)-sx);
+ }
+ }
+}
diff --git a/common/rfb/ScaleFilters.h b/common/rfb/ScaleFilters.h index 0ec0730d..317d0b41 100644 --- a/common/rfb/ScaleFilters.h +++ b/common/rfb/ScaleFilters.h @@ -60,6 +60,8 @@ namespace rfb { SFilter &operator[](unsigned int filter_id);
+ void makeWeightTabs(int filter, int src_x, int dst_x, SFilterWeightTab *weightTabs);
+
protected:
void initFilters();
|