Fix subpixel resize on bottom and right borders and near transparent pixels, speed-up the calculations (#10885)