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.
Download
bmpsvg version 0.5 [GPL v3]
Installation
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.
Usage
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.
Example
With the following input in the file System--Bomb-content.1br:
.....@@......... ..@.@..@........ ........@....... .@..@....@...... ...@...@@@@@.... .......@@@@@.... .....@@@@@@@@@.. ....@@@@@@@@@@@. ....@@@@@@@@@@@. ...@@@@@@@@@@@@@ ...@@@@@@@@.@@@@ ....@@@@@@@.@@@. ....@@@@@@.@@@@. .....@@@@@@@@@.. ......@@@@@@@... ........@@@.....
bmpsvg System--Bomb-content.1br
Configuration
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) |
---|---|
image | whether to display the image part |
image.color | colour for the image background |
image.content | whether to render image content |
image.content.color | colour for the image content |
image.mask | whether to render image mask |
image.mask.color | colour for the image mask |
image.unmask.color | colour for bits set in the image but not the mask |
image.marks | whether to mark out the coordinates |
image.marks.length | length for the marks |
image.marks.color | colour for the marks |
image.marks.xmajor | how many marks to go before drawing a longer mark |
image.marks.ymajor | how many marks to go before drawing a longer mark |
image.hotspot | whether to render the hotspot |
image.hotspot.color | colour for the hotspot |
image.scale.x | width of a bit in the image |
image.scale.y | height of a bit in the image |
hex | whether to display the hex view of the data |
hex.columnwidth | width of the hex view |
font | main font |
font.size | size of the main font |
font.weight | weight of the main font |
font.color | colour of the main font |
title.font | title font |
title.font.size | size of the title font |
title.font.weight | weight of the title font |
title.font.color | colour of the title font |
padding.image-labels | how far from the image to position the coordinate labels |
padding.image-marks | how far from the image to position the coordinate marks |
padding.image-hex | how 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
bmpsvg -config example-config System--Bomb-content.1br