[comp.text] graphics in TeX/LaTeX

mars@duteca (mars@tudelft.nl) (07/14/89)

                         
                               PICTURES IN LATEX
                               
In one of the articles to this newsgroup someone discussed several
methods he tried, to get bit mapped images in his Tex documents.
I have been working on the same problem and found the
following solution. (the idea is not mine, I stole it from a PD program
called SIGPIC that uses this method.  SIGPIC makes it possible to 
include pictures in SIGNUM 1, a WYSIWYG word processing program
for the ATARI ST):

            1. create a font of 64 characters all 1 pixel high and
               6 pixels wide. Each character is an unique six bit 
               pattern.
            2. make a program that converts picture files from
               your favorite drawing program to a TeX file with
               characters from the above font.

I implemented this solution by creating the following font with
MetaFont (a 0 is an empty pixel square, an X is a black pixel 
square):       
                '0' :000000
                '1' :00000X
                '2' :0000X0
                     .
                     .
                '9' :00X00X
                '@' :00X0X0
                'A' :00X0XX
                'B' :00XX00
                     .
                     .
                'Z' :X00X00
                ''' :X00X0X
                'a' :X00XX0
                     .
                     .
                'z' :XXXXXX
('3' to '8', 'C' to 'Y' and 'c' to 'y' are straightforward)
The other characters in the font are not used yet. The font was 
generated by a small program in C and the width and hight of a pixel 
can be specified.

Secondly I wrote another small program in C that converted uncompressed
monochrome bit map files from my ATARI ST (640*400 pixels = 32000 bytes)
to a LaTeX file. The resulting file will be >40K because the
font has only 64 characters and because of the additional LaTeX commands.
This was the first version with the following problems: 

1: Our version of TeX has a main memory size of 64K, this limits 
the number of characters that can betypeset on one page, so only 
a part of my 640*400 pixels can be put on one page (640*250 gave 
no problem). I heard somewhere that there are versions of TeX with
a larger main memory size; when someone has a version, or knows
where I can get one, please email to me.
2: For some reason TeX won't typeset empty characters ('0' in my font),
when running TeX this doesn't show, but prdvi and look will both crash.

The conversion program was modified, so that now:
1: you can specify the width and the hight to cut out from the
bit map file (starting in the upper left corner). A friend of mine,
Paul van de Arend, wrote a program for the ATARI ST that shows the
picture on the screen and in which you can cut out any rectangle by
drawing a bounding box with the mouse.  

2: a single empty characters is replaced by a ~ (interword space is
set to six pixels), a sequence of empty characters is replaced by a
\hspace{Xpt) command (X is the number of empty characters times the
width of a character in pt).

The results look very good, I tried different pixel widths (height is
equal to the width), 1pt, 1/2pt and 1/3pt and it seems like the quality
of the printing is determined by the printer (that was the intention 
of course), although I should mention that I have not used it
intensively.

An advantage of this method is that when there is some standard 
for the fonts, a whole document with pictures can easily be printed 
out or looked at on different machines, as long as the fonts are 
present. Therefore I look forward to get any comments on this method
that would improve it. I think that the I gave enough information
for someone with some knowledge of programming and TeX/Metafont to
write the programs himself (It took me a week and I didn't know
Metafont, but the Metafont book was a great help). When someone 
wants the sources of the programs I can email them or post them
to alt.sources. 

***********************************************************************
*  'Life's a bith and then you die       *  Gert-Jan Tromp,           *
*   nothing you can do about it          *  Faculty of EE, TUD Holland*
*   anything you steal or buy            *  Section Comp.Architecture *
*   you gonna be leaving here without it'*  ..!dutrun!duteca!mars     *
*   Survival, Joe Jackson                *                            *
***********************************************************************