<> <> <> <> <<>> DIRECTORY BitmapViewer, PDFileFormat, PDInterpBitmap, ImagerPixelMap, PDInterpOutput, ViewerClasses, Process, PDTextBitmap, String, PDQueue, IO, FS; PDInterpOutputViewerImpl: PROGRAM IMPORTS BitmapViewer, ImagerPixelMap, Process, PDTextBitmap, PDInterpBitmap, String, IO, FS, PDQueue EXPORTS PDInterpOutput = BEGIN viewer: ViewerClasses.Viewer _ NIL; pageMap: ImagerPixelMap.PixelMap _ ImagerPixelMap.Create[0, [0,0,0,0]]; currentStartImage: PDFileFormat.StartImage; currentHerald: PDFileFormat.Herald; bandNumber: NAT _ 0; oneBandAtATime: BOOLEAN _ FALSE; nonStop: BOOLEAN _ FALSE; StartImage: PUBLIC PROC [herald: PDFileFormat.Herald, startImage: PDFileFormat.StartImage, request: PDQueue.Request] RETURNS [PDInterpBitmap.BitmapDesc] = { bandMap: ImagerPixelMap.PixelMap; pageMapLines: NAT _ IF oneBandAtATime THEN herald.bandSSize ELSE startImage.nBands*herald.bandSSize; pageMap _ ImagerPixelMap.Create[0, [startImage.passBands*herald.bandSSize, startImage.fMinPage, pageMapLines, startImage.fSizePage]]; currentStartImage _ startImage; currentHerald _ herald; bandNumber _ 0; pageMap.Clear; bandMap _ pageMap.Clip[[startImage.passBands*herald.bandSSize, startImage.fMinPage, herald.bandSSize, startImage.fSizePage]]; RETURN [[ sOrigin: bandMap.sOrigin, fOrigin: bandMap.fOrigin, sMin: bandMap.sMin, fMin: bandMap.fMin, sSize: bandMap.sSize, fSize: bandMap.fSize, pointer: bandMap.refRep.pointer, rast: bandMap.refRep.rast, lines: bandMap.refRep.lines ]] }; EndBand: PUBLIC PROC RETURNS [PDInterpBitmap.BitmapDesc] = { bandMap: ImagerPixelMap.PixelMap; bandNumber _ bandNumber + 1; IF oneBandAtATime THEN ShowPage[]; IF oneBandAtATime THEN {pageMap _ pageMap.ShiftMap[currentHerald.bandSSize, 0]; pageMap.Clear}; bandMap _ pageMap.Clip[[(currentStartImage.passBands+bandNumber)*currentHerald.bandSSize, currentStartImage.fMinPage, currentHerald.bandSSize, currentStartImage.fSizePage]]; RETURN [[ sOrigin: bandMap.sOrigin, fOrigin: bandMap.fOrigin, sMin: bandMap.sMin, fMin: bandMap.fMin, sSize: bandMap.sSize, fSize: bandMap.fSize, pointer: bandMap.refRep.pointer, rast: bandMap.refRep.rast, lines: bandMap.refRep.lines ]] }; ShowPage: PROC = { IF viewer = NIL OR viewer.destroyed THEN { viewer _ BitmapViewer.Create[info: [name: "PD page", column: left, iconic: TRUE, hscrollable: TRUE]]; }; BitmapViewer.SetBitmap[viewer, pageMap]; DO IF viewer.destroyed OR oneBandAtATime OR nonStop THEN EXIT; Process.Pause[Process.MsecToTicks[200]]; ENDLOOP; }; EndImage: PUBLIC PROC [request: PDQueue.Request] = { separator: LONG STRING _ [160]; String.Copy[separator, request.requestTime]; THROUGH [0..2) DO String.AppendChar[separator, ' ] ENDLOOP; String.AppendString[separator, request.fileName]; THROUGH [0..2) DO String.AppendChar[separator, ' ] ENDLOOP; String.AppendString[separator, request.requestor]; THROUGH [0..2) DO String.AppendChar[separator, ' ] ENDLOOP; ShowPage[]; IF PDTextBitmap.fontName.length = 0 THEN IF NOT PDTextBitmap.SetFont["[Indigo]Fonts>TimesRoman36B.ks", request.requestor, request.requestorPassword] THEN ERROR; pageMap _ pageMap.refRep.Reshape[0, [-1-PDTextBitmap.FontAscent[], -PDTextBitmap.FontAscent[], PDTextBitmap.FontAscent[]+PDTextBitmap.FontDescent[]+2, PDTextBitmap.TextWidth[separator]+2*PDTextBitmap.FontAscent[]]]; { bits: PDInterpBitmap.BitmapDesc _ [ sOrigin: pageMap.sOrigin, fOrigin: pageMap.fOrigin, sMin: pageMap.sMin, fMin: pageMap.fMin, sSize: pageMap.sSize, fSize: pageMap.fSize, pointer: pageMap.refRep.pointer, rast: pageMap.refRep.rast, lines: pageMap.refRep.lines ]; PDInterpBitmap.Fill[bits, [-10000, -10000, 20000, 20000], 1]; PDTextBitmap.TextToBitmap[dest: bits, string: separator, function: [and, complement]]; }; ShowPage[]; }; ReprintLastPage: PUBLIC PROC [copies: CARDINAL] = { IF currentHerald.password # PDFileFormat.passwordValue THEN RETURN; currentHerald.copies _ copies; ShowPage[]; }; ReadQueue: PROC [address: LONG POINTER, nwords: CARDINAL] = TRUSTED { stream: IO.STREAM; stream _ FS.StreamOpen["[]<>Peach.queue", $read, ALL[FALSE] ! FS.Error => CONTINUE]; IF stream#NIL THEN { [] _ stream.UnsafeGetBlock[[base: address, startIndex: 0, count: nwords*2]]; stream.Close; }; }; WriteQueue: PROC [address: LONG POINTER, nwords: CARDINAL] = TRUSTED { stream: IO.STREAM _ FS.StreamOpen["[]<>Peach.queue", $create]; [] _ stream.UnsafePutBlock[[base: address, startIndex: 0, count: nwords*2]]; stream.Close; }; RegisterDisk: PROC = {PDQueue.RegisterDisk[ReadQueue, WriteQueue, 1024]}; currentHerald.password _ 0; PDQueue.RegisterDisk[ReadQueue, WriteQueue, 1024]; END.