Skip to content Skip to sidebar Skip to footer

Is There A Way To Decode A .ico File To A Resolution Bigger Than 16x16?

I'm working on android and trying to download and display a favicon(.ICO) from a website on an ImageView. So far I've manage to read the .ico from a website using an HTTP connecti

Solution 1:

I know the question was asked 3 years ago, but I have faced the very same problem and adapted a portion of image4j into ico4a, which you can find here: https://github.com/divStar/ico4a (I wrote it myself because I wanted to load the biggest image from a favicon; since image4j uses AWT-classes, which are not easily available for android, I made it so ico4a mostly uses native android classes).

It can decode most valid ICO-files into a List of Bitmap-objects. I believe either the library itself or the sample application has also a method to retrieve the biggest Bitmap-object.

However, my library is not able to write ICO-files; it can only read them. You can save the individual images as PNG or JPEG graphics easily though using some built-in android functionality.

Solution 2:

The favicon file may contains mutliple icons, usually one in 16x16 and one in 32x32. This is discussed in the following thread : How to have multiple favicon sizes, yet serve only a 16x16 by default?

It is the case with the Google's favico. If you try to download the file www.google.com/favicon.ico and open it with an application like IrfanView, you can see that there are two icons (16x16 and 32x32).

To answer your question, you should use a proper library to extract multiple icons, like image4j, and choose the one you need.

http://image4j.sourceforge.net/

Post a Comment for "Is There A Way To Decode A .ico File To A Resolution Bigger Than 16x16?"