diff --git a/src/mred/wxs/wxs_dc.cxx b/src/mred/wxs/wxs_dc.cxx index bd5b577319..34ee5b5d0d 100644 --- a/src/mred/wxs/wxs_dc.cxx +++ b/src/mred/wxs/wxs_dc.cxx @@ -557,6 +557,19 @@ static inline double approx_dist(double x, double y) return ((x < y) ? y : x); } +static double my_round(double f) +/* doesn't have to deal with negtive numbers */ +{ + double d, frac; + + frac = modf(f, &d); + + if (frac >= 0.5) + d += 1.0; + + return d; +} + static void ScaleSection(wxMemoryDC *dest, wxBitmap *src, double tx, double ty, double ww2, double hh2, double fx, double fy, double ww, double hh, @@ -698,9 +711,9 @@ static void ScaleSection(wxMemoryDC *dest, wxBitmap *src, b = (b * (1 - a)) + ((double)s2[p+3] * a); } - s2[p+1] = (int)round(r); - s2[p+2] = (int)round(g); - s2[p+3] = (int)round(b); + s2[p+1] = (int)my_round(r); + s2[p+2] = (int)my_round(g); + s2[p+3] = (int)my_round(b); } } diff --git a/src/mred/wxs/wxs_dc.xc b/src/mred/wxs/wxs_dc.xc index 4c4db3df24..9b2abf8414 100644 --- a/src/mred/wxs/wxs_dc.xc +++ b/src/mred/wxs/wxs_dc.xc @@ -423,6 +423,19 @@ static inline double approx_dist(double x, double y) return ((x < y) ? y : x); } +static double my_round(double f) +/* doesn't have to deal with negtive numbers */ +{ + double d, frac; + + frac = modf(f, &d); + + if (frac >= 0.5) + d += 1.0; + + return d; +} + static void ScaleSection(wxMemoryDC *dest, wxBitmap *src, double tx, double ty, double ww2, double hh2, double fx, double fy, double ww, double hh, @@ -564,9 +577,9 @@ static void ScaleSection(wxMemoryDC *dest, wxBitmap *src, b = (b * (1 - a)) + ((double)s2[p+3] * a); } - s2[p+1] = (int)round(r); - s2[p+2] = (int)round(g); - s2[p+3] = (int)round(b); + s2[p+1] = (int)my_round(r); + s2[p+2] = (int)my_round(g); + s2[p+3] = (int)my_round(b); } }