Flamingo resizable icons from .ICO format

July 4th, 2008

Jeff Friesen is a prolific Java desktop author on such sites as JavaWorld.com and InformIT.com, and his article on parsing .ico files and exposing the icon planes as BufferedImages. One of the areas mentioned in our JavaOne presentation on high-resolution monitors is scaling the application icons, and the org.jvnet.flamingo.common.icon.ResizableIcon interface aims to provide this support.

It was relatively easy to adapt Jeff’s code and create an implementation of ResizableIcon interface that loads .ico files and chooses the best icon plane for the specific size. The org.jvnet.flamingo.common.icon.IcoWrapperResizableIcon is the implementation and you can see how it is used in the test.imageviewer.IcoViewer.

Here is a screenshot of this application showing file icons from the Jordan Michael‘s portfolio under 128*128 size (click for the full view):

and here is the same application with the icon size changed to 256*256 (click for the full view):

The code for parsing the .ico format has been contributed by Jeff under the BSD license. The following must be referenced if you reuse this code in your application: