This is a library to decode ICO files into a list of Bitmap-objects - based on image4j project (I took the liberty to use a similar structure, classes and methods, so credits go to the authors of image4j as well!). There is a demo android application included, which shows off the library's functionality. This app is not bullet-proofed so take everything with caution.
The easiest way to include ico4a in your project, is to include the jcenter repository in your project's build.gradle and the following line in your module's build.gradle's dependencies-section:
compile 'divstar:ico4a:v1.0'
Alternatively you may download the AAR from ico4a's gitHub releases site, create a new module (chose "import AAR" in the following dialog) and add the dependency to your app's project manually.
After having done so, use the following line anywhere to decode an ICO-InputStream into a List of Bitmap-objects:
List<Bitmap> images = ICODecoder.read(SOME_INPUTSTREAM);
I suggest creating an AsyncTask to download and read the file, because while reading the file is a rather quick task, it still might result in UI thread blocking.
See the sample app included in the gitHub repository to get an idea of how to use it.
ico4a cannot write ICO files, because I did not need it myself. Some methods for writing an ICO file are already present, others are not. In particular I have avoided coding BMPEncoder and ICOEncoder, which you will find in the image4j project. Thus you will have to implement them yourself if you need them. You can however save each of the resulting Bitmap-objects easily using Android's built-in mechanisms. Here is an example:
File file = new File(dir, "output.png");
FileOutputStream fOut = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
ico4a has been tested with various single- and multi-image ICO files. It has been tested to support 1-, 4-, 8-, 24- and 32-bit uncompressed images with and without alpha transparency. In addition 24- and 32-bit PNG-compressed images with and without alpha transparency have been tested. All of them loaded without any problems.
Please report any problems if you encounter them and I will see if I can help solve them.