bruns added a comment.
I think the following yields quite good results: 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 = min(1, min(xscale, yscale)); // number of effective source samles in the target auto effectiveSamples = width * height * scale * scale; // scale down another time, to account for loss of fidelity when // using a downscaled image, biases towards smaller downscaling ratios effectiveSamples *= scale; 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