janssen@titan.sw.mcc.com (Bill Janssen) (02/24/89)
This is a nice idea, but hard to read from Lisp. I would prefer something
closer to the BDF format, with fewer formatting characters that are
language dependent.
In our DELI system, we support a similar file format.
Any line beginning with a semi-colon (well... you have to pick some
character!) is ignored. The first non-ignored line contains a single
integer, which is the format of the rest of the file, so that we can
change formats later. There are two formats defined currently, a standard
easy-to-convert-to format (1), and a run-length-encoded
easy-to-read-write-from-CommonLisp format (2).
Format 1 is quite similar to the PAX Format.
The second line contains the width, height, and number of colors in the
rectangle of pixels. The next N lines each contain 3 values in the range
[0..1], which are RGB color specs (N is equal to the color count found on
the second line). The remaining HEIGHT lines each contain a string of ascii
hex digits, with one digit per pixel for 1 to 16 colors, 2 digits per pixel
for 17 to 256 colors, and so forth. Each pixel value is an index into the
color table.
Here's an example:
; 2x2 checkerboard
;------- version --------------------------------------------
1
;------- width height number-of-colors ----------------------
6 6 2
;------- color-table: RGB [0.0 to 1.0] values, one per line -
0 0 0
1 1 1
;------- data -----------------------------------------------
111000
111000
111000
000111
000111
000111
I do like the PAX trick of binding particular characters to colors so
that the density is increased and the contents made more accessible
to the human eye.
A format that is closer to BDF would presumably look like
STARTPIXMAP 1
COMMENT 2x2 checkerboard
WIDTH 6
HEIGHT 6
NCOLORS 2
STARTCOLORS 2
0
0
0
1
1
1
ENDCOLORS
STARTBITS
38
38
38
7
7
7
ENDBITS
ENDPIXMAP
On the other hand, the PAX format has the advantage of being able to be
included directly into a C source file, and used. Not that that helps us
much with Lisp, and in fact for C I'd prefer something of the form
#define pixmap_file_format 1
static pixmap_colors foo_pixmap_colors = {
{ ' ', "DarkSlateGrey" },
{ '.', "#A8A8A8" },
{ 'X', "White" },
{ 'o', "#540054005400" }};
static pixmap_pixels foo_pixmap_pixels = {
"XX. ",
"ooX. " };
static struct pixmap foo =
{ 6, 2, 4, foo_pixmap_colors, foo_pixmap_pixels };
And for Lisp something of the form
;; pixmap-file-format 1
(require 'pixmap)
(defpixmap foo 6 2 4
'("DarkSlateGrey" "#A8A8A8" "#A8A8A8" "#540054005400")
#2a((2 3) (2 3) (1 2) (0 1) (0 0) (0 0))
)
would be nice.
Bill