From ba9299d327aa223b2452c9c58ce1e62b4026217c Mon Sep 17 00:00:00 2001 From: george82 Date: Mon, 20 Nov 2006 15:37:33 +0000 Subject: [PATCH] Fixed the small bugs with the makeWeightTabs function. makeWeightTabs must work with the pointer to weightTabs. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2117 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/ScaleFilters.cxx | 13 +++++++------ common/rfb/ScaleFilters.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/common/rfb/ScaleFilters.cxx b/common/rfb/ScaleFilters.cxx index 4782adde..e90e1e38 100644 --- a/common/rfb/ScaleFilters.cxx +++ b/common/rfb/ScaleFilters.cxx @@ -87,20 +87,21 @@ SFilter ScaleFilters::create(char *name_, double radius_, filter_func func_) { return filter; } -void ScaleFilters::makeWeightTabs(int filter_id, int src_x, int dst_x, SFilterWeightTab *weightTabs) { +void ScaleFilters::makeWeightTabs(int filter_id, int src_x, int dst_x, SFilterWeightTab **pWeightTabs) { double sx; - double ratio = dst_x / src_x; + double ratio = double(dst_x) / src_x; SFilter sFilter = filters[filter_id]; - - weightTabs = new SFilterWeightTab[dst_x]; + + *pWeightTabs = new SFilterWeightTab[dst_x]; + SFilterWeightTab *weightTabs = *pWeightTabs; // 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)); + int i0 = int(__rfbmax(ceil(sx-sFilter.radius), 0)); + int i1 = int(__rfbmin(ceil(sx+sFilter.radius), src_x)); weightTabs[x].i0 = i0; weightTabs[x].i1 = i1; weightTabs[x].weight = new float[i1-i0]; diff --git a/common/rfb/ScaleFilters.h b/common/rfb/ScaleFilters.h index 317d0b41..c2555a74 100644 --- a/common/rfb/ScaleFilters.h +++ b/common/rfb/ScaleFilters.h @@ -60,7 +60,7 @@ namespace rfb { SFilter &operator[](unsigned int filter_id); - void makeWeightTabs(int filter, int src_x, int dst_x, SFilterWeightTab *weightTabs); + void makeWeightTabs(int filter, int src_x, int dst_x, SFilterWeightTab **weightTabs); protected: void initFilters(); -- 2.39.5