PDImageReader.mesa
Last edited by Ken Pier, September 18, 1985 11:52:59 am PDT
DIRECTORY
ImagerPixelMap USING [PixelMap],
PDFileReader USING [Handle, WhatChanged],
ViewerClasses USING [Viewer];
PDImageReader: CEDAR DEFINITIONS = BEGIN
Handle: TYPE=REF Rep;
Rep: TYPE = RECORD [
pixelMap: ImagerPixelMap.PixelMap
];
ImageLink: TYPE = REF ImageRep;
ImageRep: TYPE = RECORD [
link: ImageLink, --NIL => end of list
type: PDFileReader.WhatChanged, --imageStart or loadChange
imageNumber: INT, -- -1 if loadChange
index: INT --index in PD file of the startImage or storeLoad command
];
PaintActionProc: TYPE = PROC [self: ViewerClasses.Viewer, whatChanged: REF ANY];
InterpretImage: PROC [handle: PDFileReader.Handle, viewer: ViewerClasses.Viewer, paintAction: PaintActionProc] RETURNS [lastImage: BOOLEAN ← FALSE];
Interprets one image in a PDFile. Must be called ONLY AFTER the desired image has been selected by a call to ResetToImage.
May raise PDFileReader.Warning or PDFileReader.Error or PDReaderOutput.Error or PDReaderOutput.Abort
Returns TRUE if the interpreted image is the last image in the document.
GetPageStructure: PROCEDURE [handle: PDFileReader.Handle] RETURNS [list: ImageLink, imageCount: INT];
Assumes filestream is available from Handle and Gets can be executed safely.
Scans the PD file and returns a linked list of records (ImageReps) which contain the indexes
in the file of imageStart or loadChange commands. Allows a client to skip thru the file
to a particular image, building the load for that image as needed. The total number of images is also returned.
ResetToImage: PROCEDURE [pdData: REF ANY] RETURNS [ImageLink];
A routine to reconstruct the load for the image number in pdData.pageNumber. In this case, pdData.pageNumber contains an image number rather than a page number. pdData MUST BE a Preview.PDData. It has type REF ANY to avoid circular recompilation dependencies between this module and PreView.mesa.
Requires that a page structure has already been built using GetPageStructure
and stored in pdData.pageStructure. Returns an ImageLink (single element) for the page that has been successfully reset to. Returns NIL if pageNumber is not in the images list.
END.