[GRASSLIST:2404] Re: symbols

Glynn Clements glynn.clements at virgin.net
Fri Sep 7 11:06:45 EDT 2001


anne-claire serres wrote:

> I am using the d.icons command without problem if  icons are designed
> with the p.icons command by 'cross' in a Unix file. If, still using
> p.icons, I answer at the question 'which editor do you want to use?' :
> gimp and that I draw a circle with it, when I use d.icons, instead of a
> circle, kind of histogramm are drawned. If I use some vector file as
> icon, it is the same problem. Is there a way to import symbols as icons
> in grass ?

The easiest image format to manually convert to the d.icons format is
XPM, which is actually C source code. You can "trim" the edges
manually with a text editor.

If you have the netpbm/pbmplus tools (ppmtoxpm etc), the attached
script will automate the process of converting a PBM image to an icon
(starting with a PBM image is easier than using an XPM image directly,
as the output from ppmtoxpm is more predictable than an arbitrary XPM
image).

You will still need to set the icon "centre" in a text editor.

-- 
Glynn Clements <glynn.clements at virgin.net>

-------------- next part --------------
#!/bin/bash

# pbmtoicon
# convert a PBM file to an icon suitable for d.icons
# Usage: pbmtoicon <file name> <icon name>

filename="$1"
name="$2"

if [ -z "$filename" -o -z "$name" ] ; then
	echo "Usage: $0 <file name> <icon name>" >&2
	exit 1
fi

if [ -z "$LOCATION" ] ; then
	echo 'Error: $LOCATION not set' >&2
	exit 1
fi

pnmfile "$filename" | fgrep PBM &>/dev/null

if [ $? != 0 ] ; then
	echo "'$filename' is not a PBM file" >&2
	exit 1
fi

exec ppmtoxpm "$filename" \
 | grep '^"' \
 | sed -e '1,3d' -e 's/^"//' -e 's/",\?$//' \
 | tr ' .' 'x ' > "$LOCATION/icons/$name"


More information about the grass-user mailing list