The following delineation of ".RLE" Graphics Standards is courtesy of CompuServe (c) Information Service, (originator of the process): Standard for RLE Files 1 Oct 86 Chris Hopkins 71026,1407 INTRODUCTION This file is designed to help programmers and artists understand the construction of the Run Length Encoded (RLE) graphics file as used on Compuserve. It is presented not to limit flexibility but to increase understanding of the RLE system to facilitate its use. Given a standard, the flexibility of the programmer will be increased since he/she can predict how every file is structured, and the artist can create graphics that will be reliably reproduced on differing computers because they can rely on the standard structure. I am indebted to the many people who contributed toward preparation of this file, particularly those officials from CompuServe who took the time to help make it authoritative. Any omissions or errors are mine alone; please leave me EasyPlex mail if you discover any problems. BACKGROUND: There are currently four graphics modes in use on CompuServe: Semigraphics 4, NAPLPS (Sceptre, etc.), Telidon Terminal (Electrohome, Norpak, etc.), and Run Length Encoded. Semigraphics 4 was designed with the TRS-80 line of computers in mind -- graphics that even non-bit-mapped machines could perform. It is little used today, no longer supported by CompuServe, and unrelated to RLE. NAPLPS and Telidon Terminal are graphics modes not related to RLE and thus beyond the scope of this discussion. RLE is a method of transmitting encoded graphics information to your computer. It is composed of a header sequence that tells the program whether a medium resolution or high resolution file follows, and then a series of ASCII character pairs, each pair representing the number of pixels to be background (turned off) and foreground (turned on). The number of pixels to be turned off or on are the "run length". The end of the file is concluded by another sequence which notifies the program to exit the graphics mode of the computer. RLE FILE THEORY 1. Opening sequence. The opening sequence asserts Graphics Mode Control. Graphics control is initiated when the program intercepts a three character sequence composed of ESC, an ASCII letter G, and a third character (ASCII H or M) which determines the resolution. a. High Resolution Graphics: The program clears the screen and high resolution graphics mode (256 x 192 pixels) is entered. b. Medium Resolution Graphics: The program clears the screen and medium resolution graphics mode (128 x 96 pixels) is entered. 2. Data sequence. Data is sent as pairs of run length encoded ASCII characters. The first character of the pair indicates the number of background (off) pixels and the second character indicates the number of foreground (on) pixels. Each byte of a pair is the actual pixel count plus 32 decimal. The parity bit is ignored; thus, the maximum count that can be transmitted by one character is 127-32, or 95 decimal. For example, the ASCII sequence indicates 44 decimal background (off) pixels and 55 decimal foreground (on) pixels. Since several terminals interpret ASCII 127 (07F hex) as , it is good practice to use ASCII 126 (07E hex) as the highest permitted value in the RLE pair. 3. Data wrap. The line drawn by the computer's graphics driver must wrap from the last position on the current line to the first position on the next line. Assuming high resolution, if the last pixel set on a line was in position 250, and a data sequence of 0 background and 9 foreground pixels is read by the program, then the first five pixels are "set" (turned on) on the current line and the last four pixels are set on the next line. Remember, the pixels are numbered 0-255 on a 256 pixel line. 4. Data count. a. High Resolution RLE Graphics: The screen is 256 x 192 pixels, for a total of 49,152 (*) pixels, numbered 0 to 49,151. (* See addenda.) b. Medium Resolution RLE Graphics: The screen is 128 x 96 pixels, for a total of 12,288 (*) pixels, numbered 0 to 12,287. (* See addenda.) 5. Ending sequence. The program checks for the end of graphics display by trapping each character in the file which is less than ASCII character 32, then checking to see if it is followed by the terminating sequence. In the standard RLE format this is . The basic convention is that any control character seen by a decoder should NOT AFFECT the display. The software should check these control characters and ignore all of them except and . The bell character can be processed as a bell but this is a special case and optional. Strange RLE output may result on some terminals from not ignoring control characters other than and . In order that RLE pictures can be reliably displayed by as many terminals as possible, this standard should be observed. a. Due to lack of standardization in the file closing sequence, some programmers have created routines that allow any control character to initiate end of file display. This should be avoided and corrected wherever it has been used. b. To ensure proper display, the program should end display when the defined pixel count is reached. c. code is ASCII character 07 (07 hex). Common practice is to sound the bell on completion of file display. CompuServe software transmits a upon completion of transmission when a file is Read. d. Normal Mode. The sequence is used to tell Vidtex-standard programs to exit the graphics mode, and should be the last three characters of the RLE file. This is important when the program transitions from graphics to character mode following display of the RLE file. The video mode is reset to "normal" mode (text only). The screen should not be changed until the display of the next character. In this mode the parity bit is unpredictable. Upon entering normal mode the previous state of the graphics screen is unknown. No graphic character or image can be presumed to propagate to normal mode. The return to normal mode is typically followed by a clear screen to remove any graphic residues. e. Pixel count. The total pixel count for an RLE file is exactly 49,152 * pixels for high resolution file and 12,288* pixels for medium resolution files. This allows the programmer to provide a double check method of ending a file. When the allotted number of pixels have been displayed, the program ends display whether or not the artist has created a longer file. The pixel count in the RLE file will help locate problem files and the fixing of incorrectly encoded images. STANDARD RLE FILE The standard RLE file format: 1BH 47H 'G' 48H 'H' if high resolution ('M' if medium resolution) nnH,nnH ASCII pair where nnH is one byte numeric value equal to or greater than 20H and equal to or less than 7EH. First value of pair minus 20H (32 decimal) equals background (off) pixel and second value minus 20H equals foreground (on) pixels nnH,nnH nnH,nnH nnH,nnH ...,... Continue until total sum of nnH-20H values equal 49,152 * ...,... decimal (0C000H) for high resolution, or 12,288 * (3000H) ...,... for medium resolution 07H (optional) 1BH 47H 'G' 4EH 'N' REFERENCES 1. "CompuServe Information Service Graphics Transmission Protocol," CompuServe Incorporated, Columbus, Ohio, October, 1983. 2. "VIDTEX 4.0 Standards for Terminal Emulator Programs," CompuServe Incorporated, Columbus, Ohio, April, 1985. 3. Message on CompuServe Picture Support SIG, 26 Sep 86, from Rob Vitolins 70003,2272, Graphics Product Manager, CompuServe to all software developers of RLE decoders. * ADDENDA 1. Please note that the figures 49,152 and 12,288 refer to PIXELS in an RLE screen, and NOT to bytes in an RLE file. 2. Some computers (including Apple, Macintosh, and others) have special soft- ware (such as "READMAC" for the Macintosh) that display picture graphics on the specific computer. These programs DO NOT make ".RLE" files and are NOT in RLE format (although other programs exist which CAN be run on these compu- ters to encode and decode graphic pictures in the RLE format.) 3. There are no "medium-resolution" files currently on this BBS. All ".RLE" files in section D5: are of the "high-resolution" type.