Calculate accurate weighted average in YdownXdown
When iterating through the destination image while scaling down, we know the fractional source area that should in theory cover a destination pixel. In practice a pixel has size 1 and the averaging box and number of source pixels must be integral. We can correct the resulting error by assigning weights into the averaging box. The former implementation weighted "only a bit" with the d0 / d1 variables, but it didn't take x fractions into account and also missed to pad up the weight to 1 for consecutive y rows. That seems to be the main reason why the outcome of the former YdownXdown looked "coarse" and "jagged". This commit implements the wighted average almost exactly as Tim Kientzle suggested it in "Scaling Bitmaps with Bresenham" (C/C++ User's Journal, October 1995), just extended for 2 dimensions and adapted to the exiting Splash.cc code.
Status | Job ID | Name | Coverage | ||||||
---|---|---|---|---|---|---|---|---|---|
Build | |||||||||
passed |
#4520232
|
build |
00:04:33
|
|
|||||
passed |
#4520237
|
build_android |
00:00:56
|
|
|||||
passed |
#4520233
|
build_clang_libcpp |
00:04:38
|
|
|||||
passed |
#4520236
|
build_clazy |
00:03:13
|
|
|||||
passed |
#4520235
|
build_mingw64_fedora |
00:03:06
|
|
|||||
passed |
#4520234
|
build_ubuntu_16_04 |
00:02:15
|
|
|||||
passed |
#4520231
|
clang_format |
00:01:11
|
|
|||||