Avoided truncation error when downscaling,

which reduces the MSE distortion of 2010-12-20T22:38:37Z!guillaume.melquiond@gmail.com by 20% more.
This commit is contained in:
Guillaume Melquiond 2010-12-22 18:11:32 +00:00
parent 51f38f9d7e
commit 3dc96eea83

View file

@ -515,10 +515,10 @@ surface scale_surface(const surface &surf, int w, int h, bool optimize)
if (alpha != 0.0) {
double factor = 1 / alpha;
alpha /= summation;
red *= factor;
green *= factor;
blue *= factor;
alpha = alpha / summation + 0.5;
red = red * factor + 0.5;
green = green * factor + 0.5;
blue = blue * factor + 0.5;
}
dst_pixels[ydst*dst->w + xdst] = SDL_MapRGBA(dst->format,Uint8(red),Uint8(green),Uint8(blue),Uint8(alpha));