bruns added a comment.
qreal distance(int width, int height, int desiredWidth, int desiredHeight) { auto targetSamples = desiredWidth * desiredHeight; auto xscale = (1.0 * desiredWidth) / width; auto yscale = (1.0 * desiredHeight) / height; // clamp to the lower of the two scales // also clamp to one, as scaling up adds no effective // samples, only interpolated samples auto sampleScale = std::min(1.0, std::min(xscale, yscale)); // number of effective source samles in the target auto effectiveSamples = width * height * sampleScale * sampleScale; // scale down another time, to account for loss of fidelity when // using a downscaled image, biases towards smaller downscaling ratios effectiveSamples *= sampleScale; return targetSamples - effectiveSamples; } REPOSITORY R320 KIO Extras REVISION DETAIL https://phabricator.kde.org/D14308 To: broulik, #frameworks, dfaure, ngraham, pali, vonreth, antlarr Cc: anthonyfieroni, bruns