KIconLoader implementation details

Rafael Fernández López ereslibre at kde.org
Mon Oct 15 00:22:21 BST 2007


Hi all,

I noticed when using KIconLoader that for non standard sizes, loaded icons 
were not pretty in any way.

That, in fact, was because there was a small issue with the code in 
KIconTheme, meaning that it was stopping on an icon directory that was 
inmediatly smaller than the requested (for example, it stopped on 16x16 for a 
19x19 requested icon, instead of stopping at 22x22). That is fixed with:

-          if ((abs(dw) >= abs(delta)) ||
-              (delta > 0 && dw < 0))
+          if ((abs(dw) >= abs(delta)) || dw < 0)

It assures that when we stop, we are downscaling, and never upscaling,that 
would result on a very bad resolution.

After thinking a bit more about it, I think that the implementation could be 
improved for giving more quality for non standard sizes. That means, if we 
find that the size requested is a standard one, we have png's, so, give it 
preference to them when searching:

+    const char * ext1[4] = { ".png", ".svgz", ".svg", ".xpm" };

if not, give preference to svgz's and svg's:

+    const char * ext2[4] = { ".svgz", ".svg", ".png", ".xpm" };

This let us to give a better implementation, resulting in a quality 
improvement of the icon loader.

I really know that SVG's are very much slower than loading plain PNG's 
pictures, but icons are normally asked with normal sizes, so this shouldn't 
really affect performance, since it would go for the PNG anyway.

Should this be committed ?


Bye and thanks,
Rafael Fernández López.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071015/592f93ee/attachment.sig>


More information about the kde-core-devel mailing list