Favicon files are a microsoft invention which causes an
icon to be placed alongside a page bookmark in the browser.
I was recently trying to generate one, and found it
unexpectedly hard - there are a few free tools around,
but most seem to want to charge $$$ if you want to
generate a favicon by importing an existing image.
Paintshop Pro won't write them. JDraw was actually the
closest I could get, but the images it generates arrear
corrupted when you save in the base-standard 16x16 4bpp
format.
I thought I'd investigate, but there is remarkably
little "spec" on this file format. One of the
industry's well-kept semi-secrets?! Below is my test
code which correctly writes out 16x16, 4bpp favicon
files. The code is well commented with URLs to the
specs I found. At one stage I had it writing the files
with exactly the same corruption as I'd seen when using
JDraw - the problem was in the size of the AND mask,
the spec was a bit misleading.
Anyhow, if you could incorporate the "favicon" format
into JDraw it would be a nice enhancement IMHO!
To really do this really well might need a "reduce to
16 colours" menu option. It'd be nice if the "sort
colours" menu sorted them a bit better, I'm not sure
what basis they're sorted at present but they seem
pretty random - maybe a conversion into HSL colourspace
and sorting by H then L might work better?
There are 2 files, "IconOutputStream.java" and
"Test.java", my handling of the BufferedOutputStream is
probably a bit klunky because I'm not well up on that
area, but I hope it demonstrates how to write a correct
"favicon" file sufficiently.
View the outputted icon in Windows to check it's OK.
IconOutputStream + Test main