DIRECTORY CGArea USING [Empty, Ref], CGContext USING [GenBox, Rep], CGDevice USING [Ref], CGMatrix USING [Assign, Concat, ConcatTransformation, Make, New, Ref, SetTrans], CGSource USING [Ref, Rep], CGStorage USING [qZone], Environment USING [bitsPerWord], File USING [Capability], FileIO USING [CapabilityFromStream, STREAM], Graphics USING [Context, Scale], GraphicsBasic USING [black], PressImage, PressReader USING [Dots], Space USING [Create, CreateUniformSwapUnits, Delete, Handle, LongPointer, Map, virtualMemory]; -- GetAttributes Unmap nullHandle PressImageImpl: PROGRAM -- MONITOR IMPORTS CGArea, CGContext, CGMatrix, CGStorage, FileIO, Graphics, Space EXPORTS PressImage SHARES Graphics = BEGIN Context: TYPE = Graphics.Context; ContextData: TYPE = REF ContextDataRep; ContextDataRep: PUBLIC TYPE = CGContext.Rep; PressImage: PUBLIC TYPE = REF PressImageData; PressImageData: PUBLIC TYPE = RECORD [ file: FileIO.STREAM, numberPages: NAT, pageNumber: NAT, byteOffset: INT, length: INT, scanDirection: CARDINAL, scanCount: CARDINAL, -- lines scanLength: CARDINAL, -- dots wordsPerLine: CARDINAL, -- words per scan line imageHeight: REAL, imageWidth: REAL, miv: CGMatrix.Ref, -- image-to-virtual matrix matrix: CGMatrix.Ref, -- image-to-device matrix src: CGSource.Ref -- source info for image ]; dataZone: ZONE = CGStorage.qZone; srcZone: ZONE = CGStorage.qZone; PressImageError: PUBLIC ERROR = CODE; MakePressImage: PUBLIC PROCEDURE [sampleType, dots, lines, mode, pd, dd, pl, dl: INT, width, height: REAL, bits: PressReader.Dots] RETURNS [self: PressImage _ NIL] = { scanlines, pixels, wpl, bps: CARDINAL; scanlines _ lines; pixels _ dots; wpl _ (dots+Environment.bitsPerWord-1)/Environment.bitsPerWord; IF dots MOD Environment.bitsPerWord # 0 THEN ERROR PressImageError; bps _ sampleType; self _ dataZone.NEW[PressImageData _ [ file: bits.file, numberPages: bits.numberPages, pageNumber: bits.pageNumber, byteOffset: bits.byteOffset, length: bits.length, scanDirection: mode, scanCount: scanlines, scanLength: pixels, wordsPerLine: wpl, imageHeight: height, imageWidth: width, miv: SELECT mode FROM 2 => CGMatrix.Make[[1,0,0,1,0,0]], 3 => CGMatrix.Make[[1,0,0,-1,0,lines]], 8 => CGMatrix.Make[[0,1,1,0,0,0]], ENDCASE => ERROR, -- unexpected scanDirection matrix: CGMatrix.New[], -- placeholder for image-to-device mapping src: srcZone.NEW[CGSource.Rep _ [type: array, mode: opaque, fat: FALSE, raw: FALSE, bps: bps, color: GraphicsBasic.black, xbase: NIL, xrast: wpl, Get: NIL]]]]; RETURN [self]; }; DrawPressImage: PUBLIC PROCEDURE [self: Context, image: PressImage] = { ctx: ContextData; data: PressImage _ image; T: CGMatrix.Ref; -- virtual to destination mapping M: CGMatrix.Ref _ data.matrix; -- image to destination mapping src: CGSource.Ref _ data.src; wpl: CARDINAL _ data.wordsPerLine; device: CGDevice.Ref; file: File.Capability _ FileIO.CapabilityFromStream[data.file]; space: Space.Handle; area: CGArea.Ref; basePtr, dotPtr: LONG POINTER; Graphics.Scale[self, data.imageWidth/REAL[data.scanLength], data.imageHeight/REAL[data.scanCount]]; ctx _ NARROW[self.data]; T _ ctx.matrix; device _ ctx.device; CGMatrix.Assign[M,T]; CGMatrix.SetTrans[M, ctx.cp]; -- translate to current position IF NOT ctx.yUp THEN CGMatrix.Concat[M,1,0,0,-1]; CGMatrix.ConcatTransformation[M, data.miv.m]; -- M _ miv * T src.color _ ctx.src.color; src.mode _ ctx.src.mode; space _ Space.Create[size: data.numberPages, parent: Space.virtualMemory]; Space.CreateUniformSwapUnits[size: 10, parent: space]; Space.Map[space, [file, data.pageNumber+1]]; basePtr _ Space.LongPointer[space]; dotPtr _ basePtr+data.byteOffset/2; src.xbase _ dotPtr; area _ CGContext.GenBox[ctx, [xmin: 0, ymin: 0, xmax: data.scanLength-1, ymax: data.scanCount-1], M]; IF NOT CGArea.Empty[area] THEN device.Show[device, area, src, M]; Space.Delete[space]; }; END. 0PressImageImpl.mesa Last edited by Shore; December 4, 1982 12:25 am Change Log Created by Shore; September 13, 1982 6:45 pm Changed by Shore; October 14, 1982 9:24 pm converted to Cedar 3.4 (FileIO) and new PressReader (Dots) Changed by Shore; December 4, 1982 12:24 am converted to Cedar.Style ΚΑ– "Cedar" style˜head1šΟc™Jšœ/™/unitšΟk ˜ Jšœžœ˜Jšœ žœ˜Jšœ žœ˜Jšœ žœB˜PJšœ žœ ˜Jšœ žœ ˜Jšœ žœ˜ Jšœžœ˜Jšœžœžœ˜,Jšœ žœ˜ Jšœžœ ˜J˜ Jšœ žœ˜JšœžœU!˜——šΟnœžœ ˜"Jšžœ@˜GJšžœ ˜Jšžœ ž˜J˜Jšœ žœ˜!Jšœ žœžœ˜'Jšœžœžœ˜,J˜Jšœ žœžœžœ˜-šœžœžœžœ˜&Jšœ žœ˜Jšœ žœ˜Jšœ žœ˜Jšœ žœ˜Jšœžœ˜ Jšœžœ˜Jšœ žœ˜Jšœ žœ˜Jšœžœ˜/Jšœ žœ˜Jšœ žœ˜Jšœ˜-Jšœ˜/Jšœ˜*Jšœ˜—Jšœ žœ˜!Jšœ žœ˜ J˜Jšœžœžœžœ˜%šŸœžœž œ1žœžœžœžœ˜§Jšœžœ˜&J˜Jšœ˜Jšœ˜Jšœ?˜?Jšžœžœžœžœ˜CJšœ˜J˜šœžœ˜&Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜J˜Jšœ˜Jšœ˜J˜Jšœ˜Jšœ˜šœžœž˜Jšœ"˜"Jšœ'˜'Jšœ"˜"Jšžœžœ˜-—Jšœ*˜BJš œ žœ1žœžœ/žœžœ˜Ÿ—J˜Jšžœ˜J˜—šŸœžœž œ'˜GJšœ˜J˜Jšžœ!˜2Jšžœ˜>Jšœ˜Jšœžœ˜"Jšœ˜Jšœ?˜?Jšœ˜Jšœ˜Jšœžœžœ˜J˜Jšœ%žœ$žœ˜cJšœžœ ˜Jšžœ˜Jšœ˜Jšœžœžœ˜Jšœžœ  ˜>Jšžœžœ žœžœ ˜0Jšœžœ˜