[net.graphics] Utah RLE format.

jwp@utah-cs.UUCP (Peterson) (02/16/84)

Since several (usenet) sites missed the posting of the RLE format info, here it
is again.  This format does a pretty good job of compressing 512x512x24 or 8
bit frame buffers down to a managable size.  As to actual software, the code 
in use here is tied fairly closely with the hardware we're using (Grinnell 
framebuffer on a Vax 750) but neither of the programs (compression or 
expansion) are very complex.

Also, this format was designed primarily for "Image Synthesis" work (i.e,
lots of nice, single color backgrounds).  They may not work as well for
"Image Processing" work.

.TH RLE 5 9/14/82 5
.UC 4 
.SH NAME
rle \- Run length encoded file format produced by svfb
.SH DESCRIPTION
The output file format is (note: all words are 16 bits):
.TP
.B Word 0
A "magic" number.  The top byte of the word contains the letter 'R' or the
letter 'W'.  'W' indicates that only black and white information was saved.
The bottom byte is one of the following:  
.TP
.B ' '
Means a straight "box" save, -S flag was given.  
.TP
.B 'B'
Image saved with background color, clear screen to background before restoring
image.  
.TP
.B 'O'
Image saved in overlay mode.  I.e., pixels of background color were not
saved, and screen should NOT be cleared before restoring.  However,
background color information is still saved, so the image may be
restored with background if desired.

.TP
.B Words 1-6
The structure (chars saved in PDP-11 order)

.nf
{
    short   xpos,                       /* Lower left corner
            ypos,
            xsize,                      /* Size of saved box
            ysize;
    char    rgb[3];                     /* Background color
    char    map;                        /* flag for map presence
}

.fi
\&
.PP 
If the map flag is non-zero, then the color map will follow as 3*256 16 bit
words, first the red map, then the green map, and finally the blue map.
Note: for an 8 bit color map, the bottom 8 bits of each word will be
significant, the top 8 bits can be ignored.
.PP 
Following the setup information is the Run Length Encoded image.  Each
instruction consists of a 4-bit opcode, a 12-bit datum and possibly one or more
following words (all words are 16 bits).  The instruction opcodes are:
.TP
.B SkipLines (1)
The bottom 10 bits are an unsigned number to be added to current Y position.

.TP
.B SetColor (2)
The datum indicates which color is to be loaded with the data described by the
following ByteData and RunData instructions.  0->red, 1->green, 2->blue.  The
operation also resets the X position to the initial X (i.e. a carriage return
operation is performed).

.TP
.B SkipPixels (3)
The bottom 10 bits are an unsigned number to be added to the current X
position.

.TP
.B ByteData (5)
The datum is one less than the number of bytes of color data following.  If the
number of bytes is odd, a filler byte will be appended to the end of the byte
string to make an integral number of 16-bit words.  The bytes are in PDP-11
order.  The X position is incremented to follow the last byte of data.

.TP
.B RunData (6)
The datum is one less than the run length.  The following word contains (in its
lower 8 bits) the color of the run.  The X position is incremented to follow
the last byte in the run.
.SH AUTHOR
.PP 
Spencer W. Thomas
.SH SEE ALSO
.PP 
.I svfb(1)
\&, 
.I getfb(1)
\&