Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 131648a

Browse files
committed
Refactor bug fixes in the calculation of the weight array
1 parent 7b59187 commit 131648a

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

extern/agg24-svn/include/agg_image_filters.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,21 @@ namespace agg
5656
#ifndef MPL_FIX_AGG_IMAGE_FILTER_LUT_BUGS
5757
unsigned pivot = diameter() << (image_subpixel_shift - 1);
5858
for(i = 0; i < pivot; i++)
59+
#else
60+
unsigned pivot = (diameter() << (image_subpixel_shift - 1)) - 1;
61+
for(i = 0; i < pivot + 1; i++)
62+
#endif
5963
{
6064
double x = double(i) / double(image_subpixel_scale);
6165
double y = filter.calc_weight(x);
6266
m_weight_array[pivot + i] =
6367
m_weight_array[pivot - i] = (int16)iround(y * image_filter_scale);
6468
}
6569
unsigned end = (diameter() << image_subpixel_shift) - 1;
70+
#ifndef MPL_FIX_AGG_IMAGE_FILTER_LUT_BUGS
6671
m_weight_array[0] = m_weight_array[end];
6772
#else
68-
unsigned pivot = (diameter() << (image_subpixel_shift - 1)) - 1;
69-
for(i = 0; i <= pivot + 1; i++)
70-
{
71-
double x = double(i) / double(image_subpixel_scale);
72-
double y = filter.calc_weight(x);
73-
int16 value = iround(y * image_filter_scale);
74-
m_weight_array[pivot + i] = value;
75-
if(i <= pivot) m_weight_array[pivot - i] = value;
76-
}
73+
m_weight_array[end] = (int16)iround(filter.calc_weight(diameter() / 2) * image_filter_scale);
7774
#endif
7875
if(normalization)
7976
{

0 commit comments

Comments
 (0)