D14308: [Exe Thumbnailer] Improve icon selection algorithm

Stefan BrĂ¼ns noreply at phabricator.kde.org
Mon Jul 30 23:57:57 BST 2018


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180730/a1be2e86/attachment.html>


More information about the Kde-frameworks-devel mailing list