After a month long hiatus from coding I decided to jump back in and finish a project I started a few years ago. Java has always lacked a proper icon format such as Window's
ICO and OS X's
ICNS. A modern icon format and API should support: 1. 32 bit color (ARGB) 2. Vector and bitmap images (multiple sizes for bitmaps) 3. Bundling of icon variants in a single file (active, inactive, rollover, etc.) 4. A simple to use API that supports smooth scaling, simple filters, and layering 5. Metadata Attached are the the source and binaries for a first crack API and format brilliantly named JavaIcon :-) The icon format is called JIC. A group of icons are stored in a JIC icon archive. Icon archives are zip archives with the extension ".jic" containing multiple physical icons as PNG, JPEG or SVG images. Each PNG or JPEG image has the name "image_(size).(png|jpg)" where (size) is the image size. SVG images are simply called image.svg. All images have square dimensions. Variants such as icons with drop shadows are stored within the archive in a folder named after the variant. For example, an icon variant having a drop shadow with a size of 24 should be stored as "shadow/image_24.png". Variant names are all lowercase by convention. Example internal layout of a JIC bitmap icon: image_16.png image_24.png rollover/image_16.png rollover/image_24.png disabled/image_16.png disabled/image_24.png Example internal layout of a JIC vector icon: image.svg shadow/image.svg pressed/image.svg The API is dead simple. Here are some examples: // Fetch an icon of size 24 (the icon will be automatically resized from the closest larger neighbor for bitmaps) JIconFile file = new JIconFile(iconURL); ImageIcon icon = file.getIcon(24); // Fetch an rollover version of the same icon ImageIcon icon = file.getIcon("rollover", 24); // Colorize the icon red ImageIcon redIcon = new ImageIcon(IconUtils.colorize(icon.getImage(), Color.red)); The library also includes support for compositing, layering, and padding icons. // Composite the icons side by side (other layouts are available) Icon icon = new CompoundIcon(leftIcon, rightIcon); Finally, the library supports drawing simple icons using Java2D. The constructor for ShapeIcon: public ShapeIcon(Shape shape, Paint paint) {...} ShapeIcon has helper methods for basic shapes: Icon rightArrow = ShapeIcon.arrow(10, 10, ShapeIcon.RIGHT); Resizing of bitmap icons is done using bicubic interpolation for the highest quality results. The vector drawing is done using a great little library called
Salamander. I originally planned to use
Batik but its very heavy and I wanted to keep the library light. The source is distributed under the LGPL. Feel free to pull it down and take a look. As always, comments, questions and creative insults are welcome. Enjoy!
Binaries (JAR)
Source (ZIP)
Ikayzo - Design • Build • Localize | Web • Desktop • Mobile
You need to be a member of TechHui to add comments!
Join TechHui