Re: xpm colormap... (long)

Anthony Thyssen (anthony@cit.gu.edu.au)
Tue, 22 Oct 1996 11:43:47 +1000 (EST)

| I have a bunch of color xpm files, which are the faces of people who
| I'm in contact with. (The xpm files contain a big number of colours).
| When xfaces is showing the xpm files, the program steals all the
| colors in the color-map, causing other applications to fail in
| allocating colours.
|
| Now,
|
| - Is there a way to tell xfaces to install/not-install it's own colormap?
| (in the same way netscape does with the -install/-no-install flag?)
|
| - How can I reduce the number of colours in xpm files?. (Any X-Windows
| program that does this?, I was using 'xv', but it seems to produce a
| corrupted xpm file if I save it with a reduced color set.)
|

I am not sure of the first but the second I can definately help with.

I am the coordinator for Anthony's X Windows Icon library (started 1991)
and had a simular problem with colors for icons. If you just use them
as contributed, each used a a set of colors and every icon used a
different set.

Anthony's X Windows Icon Library (AIcons)
http://www.sct.gu.edu.au/~anthony/icons/

My solution was to pick a set of 30 colors and recolor all the icons to
this set.

For the color picking process what was wanted etc. see..
http://www.sct.gu.edu.au/~anthony/icons/docs/colortable.html
For the final color selections
http://www.sct.gu.edu.au/~anthony/icons/docs/colors.html
or in a X pixmap file
http://www.sct.gu.edu.au/~anthony/icons/desc/cl-misc/colortable.xpm

Now for your solution.

The core program I used to recolor icons (X pixmaps) was the PbmPlus
filter ``ppmquant'' This can take a `ppm' file of colors and
either dither images into this map (your need) or replace the colors
(my need). It can also just reduce the colors used, but the colors
picked may not be the same across all images in that case (unless all
images are concatanated in to image to give to the program). As such
I recommend creating a ppm colormap.

`ppmquant' is part of the pbmplus (netpbm) filter package
ftp://ftp.cit.gu.edu.au/pub/users/A.Thyssen/netpbm-1mar94.p1.tgz

The Colormap I use is available at
http://www.sct.gu.edu.au/~anthony/icons/local/colormap.ppm
or in X pixmap format (not directly usable by `ppmquant'
http://www.sct.gu.edu.au/~anthony/icons/desc/cl-misc/colormap.xpm

ASIDE: A colormap is just a ppm image with the colors wanted in it.
Often just one pixel for each color wanted to make it minimal.

The `ppmquant' can only be run on one image, also I wanted to recolor
whole directories of X Pixmap images, so I wrote quite a number of
scripts to convert the X Pixmaps to ppmplus, recolor them, convert them
back AND fix the color names which ppmplus filters delete.

All these scripts can be found in the AIcons support script area
http://www.sct.gu.edu.au/~anthony/icons/support/scripts/
or download this support files from
ftp://ftp.cit.gu.edu.au/pub/AIcons/support.tar.gz

The specific script to recolor icons is called (suprise) `recolor'

EG: recolor *.xpm
or recolor -fs *.xpm # dithered recolor
or recolor -fs -f colormap.ppm *.xpm # with this colormap

This will recolor all X Pixmaps in the corrent directory renaming them
from
name.xpm
to
name_recol.xpm
or is the number of colors was reduced
name_recol_bad.xpm

WARNING: recolor depends on other scripts in the support scripts
directory a couple of which also depend of perl being installed
(to create and use a pixel->colorname database for the ppm image
to X pixmap conversion)

USAGE:

I will make only one more suggestion...

When I start my X windows session I want to ensure that programs like
netscape do not grab the 30 `standard' colors I use. As such I
want to assign those colors before netscape and others are run.

To do this I have a line like the following in my .xsession or .xinitrc
X windows startup file.

=======8<--------CUT HERE----------axes/crowbars permitted---------------
#/bin/sh
#...

# ----- Get Server information ---------
# set variables : WIDTH HEIGHT SERVERHOST CLIENTHOST HOST X/Y_RESOLUTION ....
eval `xrdb -symbols | sed -n '/=/{s/-D\([^= ]*\)=*/\1=/gp;}'`
HOST=`hostname` # correct this xrdb setting

#...

if [ $PLANES != 1 ]; then # color display
# Load standard colortable to insure these color are present.
sxpm -geometry 6x5-40-40 $HOME/icons/local/colormap.xpm &
sleep 1 # pause a moment
fi

#...
=======8<--------CUT HERE----------axes/crowbars permitted---------------

The -geometry places the image underneth my xclock which is started later
in the sequence.

I also recomend ctwm for seting the icons various programs use.

I think that is enough for now. Use the above as you see fit and I hope
all this helps.

I will be placing a copy of this in my ``Tower of Computation Sorcery''
X windows floor, which is part of my ``Web Castle''.

X Windows Hints and Tip Floor
http://www.sct.gu.edu.au/~anthony/info/X/
Tower of Computation Sorcery
http://www.sct.gu.edu.au/~anthony/info/
Anthony's Home is his Castle
http://www.sct.gu.edu.au/~anthony/

Anthony Thyssen ( System Programmer ) http://www.sct.gu.edu.au/~anthony/
-------------------------------------------------------------------------------
We are designated, Pentium 90 of the Borg....
Division is futile! You will be approximated!
-------------------------------------------------------------------------------
PGP Public Key available -- finger -l anthony@lyrch.cit.gu.edu.au