ImagerBackdoor.mesa
Copyright Ó 1984, 1985, 1986, 1987, 1991 by Xerox Corporation. All rights reserved.
Doug Wyatt, April 21, 1985 3:45:00 pm PST
Michael Plass, August 19, 1991 10:14 am PDT
Not all contexts implement the operations in this interface. To be device-independent, clients should avoid them.
DIRECTORY
Imager USING [Color, ColorOperator, SpecialColor, Context, Font, Outline, PathProc, PixelMap, Rectangle, SampleMap, Transformation, VEC];
ImagerBackdoor: CEDAR DEFINITIONS
~ BEGIN OPEN Imager;
Access to imager variables
IntKey: TYPE ~ { -- for SetInt, GetInt
priorityImportant,
noImage,
strokeEnd,
strokeJoint,
correctPass,
raiseWarnings,
intA, intB, intC -- spares
};
RealKey: TYPE ~ { -- for SetReal, GetReal
DCScpx, DCScpy,
mediumXSize, mediumYSize,
fieldXMin, fieldYMin, fieldXMax, fieldYMax,
strokeWidth,
underlineStart,
amplifySpace,
correctShrink,
correctMX, correctMY,
correctTX, correctTY,
correctStretch, -- not present in Interpress 3.1
miterLimit, -- not present in Interpress 3.1
realA, realB, realC -- spares
};
Clipper: TYPE ~ LIST OF ClipperItem; -- for SetClipper, GetClipper
ClipperItem: TYPE ~ RECORD [outline: Outline, oddWrap, exclude: BOOL ¬ FALSE];
SetInt: PROC [context: Context, key: IntKey, val: INT];
SetReal: PROC [context: Context, key: RealKey, val: REAL];
SetT: PROC [context: Context, m: Transformation];
SetClipper: PROC [context: Context, clipper: Clipper];
GetInt: PROC [context: Context, key: IntKey] RETURNS [INT];
GetReal: PROC [context: Context, key: RealKey] RETURNS [REAL];
GetT: PROC [context: Context] RETURNS [Transformation];
GetFont: PROC [context: Context] RETURNS [Font];
GetColor: PROC [context: Context] RETURNS [Color];
GetClipper: PROC [context: Context] RETURNS [Clipper];
GetCP: PROC [context: Context, rounded: BOOL ¬ FALSE] RETURNS [VEC];
Returns, in client coordinates, the current position.
If rounded~TRUE, first rounds the position to the nearest device grid point.
GetBounds: PROC [context: Context] RETURNS [Rectangle];
Returns, in client coordinates, a bounding rectangle for the composite clipping outline.
Save/Restore
Alternatives to DoSave, DoSaveAll for clients that can't use callbacks.
Clients should ensure that Save and Restore calls are properly paired.
The return value of Save should be passed to Restore, so that the proper pairing can be checked.
Save: PROC [context: Context, all: BOOL ¬ FALSE] RETURNS [REF];
Restore: PROC [context: Context, ref: REF];
Coordinate Systems and Transformations
CoordSys: TYPE ~ {client, view, surface, device};
Note: In device coordinates, s ~ x and f ~ y.
TransformPoint: PROC [context: Context, p: VEC, from, to: CoordSys] RETURNS [VEC];
TransformVec: PROC [context: Context, v: VEC, from, to: CoordSys] RETURNS [VEC];
GetTransformation: PROC [context: Context, from, to: CoordSys] RETURNS [Transformation];
Makes a new Transformation; use ImagerTransformation.Destroy, if appropriate, to save allocations.
View Operations
ViewReset: PROC [context: Context];
ViewClip: PROC [context: Context, path: PathProc, oddWrap, exclude: BOOL ¬ FALSE];
ViewClipRectangleI: PROC [context: Context, x, y, w, h: INTEGER, exclude: BOOL ¬ FALSE];
coordinates relative to current view origin
ViewTranslateI: PROC [context: Context, x, y: INTEGER];
Visibility: TYPE ~ {none, part, all};
TestViewRectangle: PROC [context: Context, x, y, w, h: INTEGER] RETURNS [Visibility];
MoveViewRectangle: PROC [context: Context, width, height, fromX, fromY, toX, toY: INTEGER];
Simple Bitmap Context
These are simple versions; for more control, refer to other interfaces.
NewBitmap: PROC [width, height: NAT] RETURNS [SampleMap];
BitmapContext: PROC [bitmap: SampleMap] RETURNS [Context];
Buffer Access
GetBufferColorOperator: PROC [context: Context] RETURNS [ColorOperator];
For raster contexts with an explicit image buffer, this returns a ColorOperator that describes how the pixels in the buffer are interpreted. Returns NIL if not applicable.
AccessBuffer: PROC [context: Context, action: PROC [pixelMap: PixelMap], path: PathProc, oddWrap: BOOL ¬ FALSE];
For raster contexts with an explicit image buffer, this allows client access to the buffer. The interpretation of the pixels is according to the ColorOperator above. The path is in client coordinates.
AccessBufferRectangle: PROC [context: Context, action: PROC [pixelMap: PixelMap], rectangle: Rectangle];
SaveBuffer: PROC [context: Context, id: ATOM, path: PathProc, oddWrap: BOOL ¬ FALSE];
This saves the specified region of the image (subject to the current clipper) in a context-specific variable of the given name. This variable will be subject to DoSave. The path is in client coordinates.
SaveBufferRectangle: PROC [context: Context, id: ATOM, rectangle: Rectangle];
A common case of SaveBuffer.
RestoreBuffer: PROC [context: Context, id: ATOM];
Restores a region that was saved with SaveBuffer or SaveBufferRectangle, in the same place in the device coordinate system that it was saved from, but subject to the current clipping region.
DiscardBuffer: PROC [context: Context, id: ATOM];
Discards the saved buffer.
Other Utilities
invert: READONLY SpecialColor;
MakeStipple: PROC [stipple: WORD, xor: BOOL ¬ FALSE] RETURNS [SpecialColor];
MaskBits: PROC [context: Context, base: LONG POINTER, wordsPerLine: NAT,
sMin, fMin, sSize, fSize: NAT, tx, ty: INTEGER ¬ 0];
Provided for compatibility with earlier Imager releases.
[base, wordsPerLine, sMin, fMin, sSize, fSize] describes a raw raster;
a scan mode of [slow~down, fast~right] is assumed for the raster
[tx, ty] is the position in client coordinates at which to place the upper left corner of the raster
DrawBits: PROC [context: Context, base: LONG POINTER, wordsPerLine: NAT,
sMin, fMin, sSize, fSize: NAT, tx, ty: INTEGER ¬ 0];
Analogous to MaskBits, but zero bits become white and one bits become black, regardless of the current color.
ClientFromView: PROC [context: Context, p: VEC] RETURNS [VEC]
~ INLINE {RETURN [TransformPoint[context: context, p: p, from: view, to: client]]};
ViewFromClient: PROC [context: Context, p: VEC] RETURNS [VEC]
~ INLINE {RETURN [TransformPoint[context: context, p: p, from: client, to: view]]};
ViewFromDevice: PROC [context: Context, p: VEC] RETURNS [VEC]
~ INLINE {RETURN [TransformPoint[context: context, p: p, from: device, to: view]]};
DeviceFromView: PROC [context: Context, p: VEC] RETURNS [VEC]
~ INLINE {RETURN [TransformPoint[context: context, p: p, from: view, to: device]]};
ClientFromDevice: PROC [context: Context, p: VEC] RETURNS [VEC]
~ INLINE {RETURN [TransformPoint[context: context, p: p, from: device, to: client]]};
DeviceFromClient: PROC [context: Context, p: VEC] RETURNS [VEC]
~ INLINE {RETURN [TransformPoint[context: context, p: p, from: client, to: device]]};
END.