From: george82 Date: Tue, 14 Nov 2006 15:59:25 +0000 (+0000) Subject: Added the new method makeWeightTabs to the ScaleFilters X-Git-Tag: v0.0.90~384^2~197 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=67e3f57ed23a4530536c44f45ee1bd0d8eab3e3a;p=tigervnc.git 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 --- 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 #include +#include #include 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();