home
ICOReader:
this class is capable of reading the Microsoft ICO format
It is ImageIO compatible and supports transparency (including the alpha channels in 32bit windows xp icons)

the library is available using the LGPL licence


download: Release 1.04 binary    source
download: Release 1.02
download: Release 1.01
download: Release 1.0
download: Release 0.06.064
download: Release 0.06.001


sample application: sample_application.zip (129 KB)

   Usage:
      add the jar file to your classpath to add support for .ico files to the ImageIO api.
      
      alternatively you can try to use the lib from the commandline
        either use 
          "java -jar ICOReader.jar c:\test.ico"   (tries to decode the specified file/dir with this library)
          or
          "java -jar ICOReader.jar -imageio c:\test.ico" (tries to decode the specified file/dir with the ImageIO api)
      
   Optional Settings:   
      if you set the System property "nl.ikarus.nxt.priv.imageio.icoreader.autoselect.icon" to "true" 
      (-D.... at the commandline or System.setProperty(...) from inside your application)
      this lib will return an icon independend of the index nr you supply
      the selection is made based upon the following criteria:
       1. the icon with the most colors
       2. the largest icon.

   
   Requirements:
     Java Runtime Engine 1.4 or higher
      1.5 / 5.0 is preferred since it ships with a BMPReader (JDK 1.5 or an ImageIO library capable 
        of reading BMP files is only needed if you want to read compressed ico files)
   
   Known problems:
     - 16bit icon support is experimental and never tested
     
   Todo: 
     - add a writer 
     
   changelog:
      1.04 (28 nov 2005)
        - version 1.04 fixes a bug, the 32bit version of the  www.geenstijl.nl favicon should now be decoded properly
      x.xx (11 oct. 2005)
        - I removed release 1.03,  All black pixels were made transparent for 24bit images.
          Now I have to figure out the correct way to allow transparent backgrounds in 24bit images. (8bit & 32bit images with transparency still work fine though)
   		1.03 (06 oct. 2005)
   			- fixed a bug (transparency in 16 & 24 bit ico files did not work) :
   			  set the alpha mask for pixels with a value of 0 in  16bit or 24bit ico files to 0 (transparent) in stead of to 255 (fully visible)
   			 I'm not sure if this is the correct sollution... I'll need to test it with more images (preferably black ones)
      1.02 (10 sept.2005)
        - removed a System.out.println() statement
      1.01 (29 aug. 2005)
        - fixed a bug wich caused the 8bit icons to lose the bottom row of pixels.
          (the whole image was drawn 1 pixel too low)
      1.00 (4 july 2005)
        - added metadata, It is now possible to use the getImageMetadata(int) in the ImageReader class
          an example how to use it is available here
        - changed the version number to 1.0 because I think the library is working pretty good.   
      0.06.064  (10 May 2005)
        - fixed: when using the autoselect property the first icon with the highest bitcount was used instead
                 of the largest or the one closest to the specified size
        - removed some console output (you can enable the console output again by setting the system property
          "nl.ikarus.nxt.priv.imageio.icoreader.debug" to "true"
      0.06.001  (8 april 2005)
        - fixed some minor bugs
      0.06 (1 april 2005)
        - Added a second decoder
          if the first decoder fails, this lib tries to convert the image to a BMP file and use the ImageIO api to 
          convert that to a BufferedImage (this means that you need either JRE 1.5/5.0 or an ImageIO library that is
          capable of decoding bmp files)
      0.05.065
        - now checking the first four bytes to see if this lib can read the data
          instead of finding out while parsing the data
        - added some systemproperties, when set the lib tries to select the best resource in the ico file
          (selection is based upon colors (the highest bpp is preferred)
          and optionally a specified width/height or if omitted the largest image is preferred
      0.05
        - fixed problems with 24bit & 32bit icons
           

if you are intrested in the source send a mail with youre request to "ICOReader (at) vdburgh.tmfweb.nl"





example extracting metadata

    
      ImageReader r = ....
      ...
      IIOMetadata meta = r.getImageMetadata(imageNr);
      IIOMetadataNode n = (IIOMetadataNode)meta.getAsTree(meta.getNativeMetadataFormatName());
      if (n.hasChildNodes()) {
        org.w3c.dom.NodeList nl = n.getChildNodes();
        for (int childNr=0;childNr<nl.getLength();childNr++) {
          IIOMetadataNode child =(IIOMetadataNode) nl.item(childNr);
          String key = child.getAttribute("keyword");
          String value = child.getAttribute("value");
          System.out.println(key + "=" + value);          
        }
      }