RawEye.Mesa
Last Edited by: Spreitzer, May 9, 1985 5:12:26 pm PDT
DIRECTORY Basics, FS, ImagerPixelMap, IO, Rope;
RawEye: CEDAR PROGRAM
IMPORTS FS, ImagerPixelMap, IO =
BEGIN
ROPE: TYPE = Rope.ROPE;
PixelMap: TYPE = ImagerPixelMap.PixelMap;
ReadBitmap: PROC [fileName: ROPE, byteLength, wordWidth: NAT] RETURNS [pm: PixelMap] =
BEGIN
file: IO.STREAMFS.StreamOpen[fileName: fileName, streamOptions: bmStreamOptions];
bitWidth: NAT ← wordWidth*16;
bitHeight: NAT ← byteLength*8/bitWidth;
gotBytes: INT;
pm ← ImagerPixelMap.Create[lgBitsPerPixel: 0, bounds: [0, 0, bitHeight, bitWidth]];
TRUSTED {
ub: Basics.UnsafeBlock ← [
base: LOOPHOLE[pm.refRep.pointer],
startIndex: 0,
count: byteLength];
gotBytes ← file.UnsafeGetBlock[ub];
};
IF gotBytes # byteLength THEN ERROR;
file.Close[];
END;
bmStreamOptions: FS.StreamOptions ← FS.defaultStreamOptions;
bmStreamOptions[tiogaRead] ← FALSE;
END.