One application for this that comes immediately to mind is client-side generation of sparklines-type images, possibly from an AJAX source.
To make an image WxH pixels big, first create a properly sized array: var pixels = new Array(W*H);. Then, for each pixel X,Y that should be opaque, store a 1 at the proper location: pixels[X+Y*W] = 1;. Finally, create the image: var my_glif = make_glif(W, H, pixels [,red, green, blue]);. If they are specified, red, green and blue should be byte values from 0 to 255. If they are not specified, the foreground of the image will be black. "0" pixels are transparent.
Now, you can specify this image as the SRC attribute of an IMG tag: document.write("<IMG SRC=\"" + my_glif + "\">");
The generated images are monochrome, with one foreground color and one transparent color. The created GIF file is bloated, because it's created using libungif-style noncompression. (mostly for easier coding, since the patent on LZW encoding has expired)
This implementation is licensed under LGPL.
Files currently attached to this page:
Entry first conceived on 11 September 2005, 18:15 UTC, last modified on 15 January 2012, 3:46 UTC
Website Copyright © 2004-2021 Jeff Epler