I needed a way to create SVG content that documents bitmaps, mainly for things like standard mouse pointer shapes. This is what I came up with - it isn't really complete, but it's doing enough for now.


bmpsvg version 0.5 [GPL v3]


Copy to a directory on your PATH e.g. /usr/local/bin (or $HOME/bin if preferred, although this might not be set up by default). Make sure the file is executable with chmod u+x bmpsvg.


bmpsvg relies on filename conventions to specify the details of the data to be drawn:

Single bitmap bmpsvg [-config configfile] [-chars charlist] class-index-name-content.ext
Content and mask bitmaps bmpsvg [-config configfile] [-chars charlist] class-index-name-content.[(x,y).]ext class-index-name-mask.ext
2-plane bitmap bmpsvg [-config configfile] [-chars charlist] class-index-name.[(x,y).]ext

The charlist is used with the 1br extension, which is currently the only supported input file format. The 1br file contains an ASCII representation of the bitmap data, one character per bit, line for line. The charlist specifies which character to interpret as which bit setting. For a single bitplane, the default characters are . for a reset bit and @ for a set bit. For an image with two bitplanes together, the characters are . for neither mask nor content, @ for both mask and content, = for mask but no content and ^ for the rare case where there is content with no mask behind it.

The class, index and name entries in the filename are rendered as part of the content, with underscores in the name replaced by spaces. Similarly, if the (x,y) addition is used, it specifies the coordinate of the hotspot for a mouse pointer.


With the following input in the file System--Bomb-content.1br:

and the following commandline:
bmpsvg System--Bomb-content.1br
the svg output is as follows:



The configuration file given on the commandline can be used to override the defaults used in constructing the svg output. Its format is a single configuration entry per line, with blank lines and comment lines (starting with a #) ignored. Each configuration entry is a key, then a colon (:) and then a value. The set of keys is:

Key Purpose (all lengths in pixels)
imagewhether to display the image part
image.colorcolour for the image background
image.contentwhether to render image content
image.content.colorcolour for the image content
image.maskwhether to render image mask
image.mask.colorcolour for the image mask
image.unmask.colorcolour for bits set in the image but not the mask
image.markswhether to mark out the coordinates
image.marks.lengthlength for the marks
image.marks.colorcolour for the marks
image.marks.xmajorhow many marks to go before drawing a longer mark
image.marks.ymajorhow many marks to go before drawing a longer mark
image.hotspotwhether to render the hotspot
image.hotspot.colorcolour for the hotspot
image.scale.xwidth of a bit in the image
image.scale.yheight of a bit in the image
hexwhether to display the hex view of the data
hex.columnwidthwidth of the hex view
fontmain font
font.sizesize of the main font
font.weightweight of the main font
font.colorcolour of the main font
title.fonttitle font
title.font.sizesize of the title font
title.font.weightweight of the title font
title.font.colorcolour of the title font
padding.image-labelshow far from the image to position the coordinate labels
padding.image-markshow far from the image to position the coordinate marks
padding.image-hexhow far from the image to position the hex view

This can be illustrated with the configuration in example-config:

# an example configuration that overrides some details

hex: false
image.marks.color: #804090
image.scale.x: 20.0
image.scale.y: 40.0
and the following commandline:
bmpsvg -config example-config System--Bomb-content.1br
giving svg output as follows instead:

Example with config