<> <> 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.STREAM _ FS.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.