On my badly broken Linux desktop, the Gimp is missing its file-saving plug-ins, so it cannot save files except in a format I cannot use. XPaint does not exist, for some reason. The venerable bitmap program does work, but can only produce X11 bitmap files (which are black and white only). How then to produce colour icons for my Picky Picky Game mock-ups?

The answer is, of course, to use Jef Poskanzer’s PBMPlus Toolkit (as extended over the years by other people to make NetPBM). I used this in the distant past to get around the lack of graphics editors on Unix in the olden days (we are talking circa 1992, here). Using bitmap, you make masks for the colours you want, and combine them using pnmarith. There was a slight hiccup when I discovered that pgmtoppm seems to go strange when presented with a PBM: it generates a depth-1 pixmap, therefore losing the very colours you have just used it to add. No doubt my decrepit compuer has out-of-date PBMPlus software, just like everything else...

Anyway, the PBMPlus method for colour graphics is as follows. For each colour (including the white background), you create a bitmap that is the mask for that colour:

(white mask) (red mask)

The first one is the white mask. The second is white where I want the picture to be red, and black otherwise. If there were several colours there would be several of these. In bitmap producing these masks is relatively easy—start with the white mask, press Invert, and then Flood Fill the parts you don’t want. Convert these to PBM files using xbmtopbm.

Now we start creating the image, one colour at a time. The first layer, white, is easy: just copy warning-white.pbm to warning.ppm. For other colours, you use ppmmake to create a block of the colour, pnmarith -m to mask out the area you want, and pnmarith -a to combine this with the main image:

mv warning.ppm tmp.ppm && ppmmake '#990000' 32 32 |
      pnmarith -m - warning-red.pbm |
      pnmarith -a - tmp.ppm > warning.ppm

The result is a picture with several colours in it, created using only a bitmap editor:

(warning icon)

All in all this is a lot more bother than using a proper WYSIWYG graphics editor. (You also cannot sensibly create images with a large number of colours, since each colour needs its own mask.) When Jeremy’s not using her NT box I might borrow that to produce nicer graphics.

25 November 2002

Article Archive by Year