THEN {
WriteRGBRun: PROC ~ INLINE {
IO.PutByte[out, run];
IO.PutByte[out, rgb.r];
IO.PutByte[out, rgb.g];
IO.PutByte[out, rgb.b];
};
run: NAT ← 1;
rgb: RGB;
ImagerSample.GetSamples[redGrn, [y, 2*maps.x], [0, 2], r, 0, maps.w];
ImagerSample.GetSamples[redGrn, [y, 2*maps.x+1], [0, 2], g, 0, maps.w];
ImagerSample.GetSamples[maps[1].map, [y, maps.x], [0, 1], b, 0, maps.w];
rgb ← [r[0], g[0], b[0]];
FOR x: NAT IN (0..maps.w) DO
temp: RGB ← [r[x], g[x], b[x]];
IF temp = rgb AND run # 255 THEN {run ← run+1; LOOP};
WriteRGBRun[];
rgb ← temp;
run ← 1;
REPEAT
FINISHED => WriteRGBRun[];
ENDLOOP;
}
ELSE {
WriteBWRun: PROC ~ INLINE {
IO.PutByte[out, run];
IO.PutByte[out, val];
};
run: NAT ← 1;
val: CARDINAL;
ImagerSample.GetSamples[maps[0].map, [y, maps.x], [0, 1], bw, 0, maps.w];
val ← bw[0];
FOR x: NAT IN (0..maps.w) DO
temp: CARDINAL ← bw[x];
IF temp = val AND run # 255 THEN {run ← run+1; LOOP};
WriteBWRun[];
val ← temp;
run ← 1;
REPEAT
FINISHED => WriteBWRun[];
ENDLOOP;
};