CtEncode.mesa
Copyright Ó 1988, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, July 3, 1992 1:26 pm PDT
Procedures for reading/writing run-length encoded files to/from the sampleMaps.
DIRECTORY CtBasic, Rope;
CtEncode: CEDAR DEFINITIONS
~ BEGIN
ROPE:   TYPE ~ Rope.ROPE;
SampleMaps: TYPE ~ CtBasic.SampleMaps;
Format of Run Encoded Files
Each file consists of:
1 byte: 0 = bw image, 1 = rgb image
2 bytes: x-origin
2 bytes: y-origin
2 bytes: width of image
2 bytes: height of image
the run-encoding:
1 byte: length of run
IF rgb:
1 byte: red value
1 byte: green value
1 byte: blue value
IF bw:
1 byte: bw value
Run Length Encoding Operations
Error: ERROR [reason: ROPE];
WriteEncoded: PROC [maps: SampleMaps, fileName: ROPE];
Write the sampleMaps to the file using run-length encoding.
ReadEncoded: PROC [fileName: ROPE, maps: SampleMaps ¬ NIL] RETURNS [SampleMaps];
Read the file into sampleMaps using run-length encoding.
END.