Image Decoding

The image-decoding library takes mouse offsets into an image (generated by browsers that support <IMG ISMAP> like NCSA Mosaic 1.1 or later) and translates them to a document specified in the map.conf config file. Currently, the library only supports bitmasks and rectangles for specifying the coordinate mappings.

For rectangles, you just need to know the bounding boxes of the various objects. Bitmasks require that you edit bitmaps (XBM style) and set the pixels in each bitmask corresponding to each object (one bitmask per object). I use xv to convert the image to an X11 bitmap (using B&W dithering) then edit each file with bitmap setting the bits in the image that corrispond to the object. Then you must convert the xbm files to raw data (by writing the resulting filename_bits[] array to a file).

The image-decoding library reads the configuration file specified by the decode_config variable in local.conf. It consists of lines like:

decode-walk config-file server/walk/walk.map
...
decode-walk default server/walk/default.html
decode-walk bitmask server/walk/astronaut.mask 106 110 server/walk/astronaut.html
decode-walk bitmask server/walk/camera.mask 106 110 server/walk/camera.html
decode-walk bitmask server/walk/earth.mask 106 110 server/walk/earth.html
decode-walk bitmask server/walk/pack.mask 106 110 server/walk/pack.html
decode-walk rect 0 0 106 110 server/walk/space.html
The first item on the line is the thing that is being mapped. This is the logical name you assign when you map the decoder in the local.conf configuration file (e.g., map decode-walk decode.pl &do_decode($path, $query)). The second item (default, bitmask, rect, config-file) determines the action taken for each line. 'default' is the action used if there was no $query. 'bitmask' tests for the bit in the mask file, if it's set it returns the specified file (Note the width and height must currently be specified for mask files). 'rect' tests to see if the selection occured in the rectangle specifed by the x, y, width, height data specifed, if so the it returns the document. 'config-file' loads the specified file as another map configuration file and searches it again. Notice that the last line ("decode-walk rect...") is used as a catch all, but differs from 'default'. 'default' is used if there was no query sent from the browser which is the case with old browsers that don't support the ISMAP flag. See the walk example source and the demo that uses it.

Thanks to Chris McRae <mcrae@ckm.ucsf.edu> who made configuration files for the image decoding stuff and added the rectangle decoding, his efforts have made it a lot easier to configure.


Tony Sanders