DIRECTORY Basics USING [LongMult], ImagerBasic USING [DeviceRectangle], PrincOps USING [DstFunc, SrcFunc]; ImagerPixelMaps: CEDAR DEFINITIONS IMPORTS Basics ~ BEGIN -- ^ -- f | -- | -- | +----------------------------+ -- | | | -- | |rast * bitsPerWord / bitsPerPixel | -- | | | -- | | +------------+ | -- | | | | | -- | | | | | -- | | |fSize | | -- | | | | | -- | | sMin | sSize | | -- | |<-- -->+------------+ | -- | | ^ | -- | | |fMin | -- | sOrigin | v lines | -- |<---- ---->+----------------------------+ -- | ^origin of buffer -- | | -- | |fOrigin -- | | -- | | -- | v -- +--------------------------------------------> -- Device space origin s PixelMap: TYPE ~ RECORD [ sOrigin, fOrigin: INTEGER, sMin, fMin: INTEGER, sSize, fSize: NAT, refRep: REF PixelMapRep ]; DeviceRectangle: TYPE ~ ImagerBasic.DeviceRectangle; Intersect: PROC [a, b: DeviceRectangle] RETURNS [DeviceRectangle]; Create: PROC [lgBitsPerPixel: [0..4], bounds: DeviceRectangle] RETURNS [PixelMap]; CreateFrameBuffer: UNSAFE PROC [pointer: LONG POINTER, words: LONG CARDINAL, lgBitsPerPixel: [0..4], rast: CARDINAL, lines: CARDINAL, ref: REF _ NIL] RETURNS [PixelMap]; Clear: PROC [pixelMap: PixelMap]; Reshape: PROC [refRep: REF PixelMapRep, lgBitsPerPixel: [0..4], bounds: DeviceRectangle] RETURNS [PixelMap]; Copy: PROC [p: PixelMap, scratch: REF PixelMapRep _ NIL] RETURNS [PixelMap]; ShiftMap: PROC [p: PixelMap, s, f: INTEGER] RETURNS [PixelMap]; ShiftWindow: PROC [p: PixelMap, s, f: INTEGER] RETURNS [PixelMap]; Clip: PROC [p: PixelMap, bounds: DeviceRectangle] RETURNS [PixelMap]; SetWindow: PROC [p: PixelMap, bounds: DeviceRectangle] RETURNS [PixelMap]; Window: PROC [p: PixelMap] RETURNS [DeviceRectangle]; BufferBounds: PROC [p: PixelMap] RETURNS [DeviceRectangle]; BoundedWindow: PROC [p: PixelMap] RETURNS [DeviceRectangle]; GetPixel: PROC [source: PixelMap, s, f: INTEGER] RETURNS [CARDINAL]; GetBit: PROC [source: PixelMap, s, f: INTEGER] RETURNS [CARDINAL] ~ TRUSTED INLINE {RETURN [LOOPHOLE[source.refRep.pointer + Basics.LongMult[(s - source.sOrigin), source.refRep.rast], LONG POINTER TO PACKED ARRAY [0..0) OF [0..2)][f - source.fOrigin]]}; Get2Bits: PROC [source: PixelMap, s, f: INTEGER] RETURNS [CARDINAL] ~ TRUSTED INLINE {RETURN [LOOPHOLE[source.refRep.pointer + Basics.LongMult[(s - source.sOrigin), source.refRep.rast], LONG POINTER TO PACKED ARRAY [0..0) OF [0..4)][f - source.fOrigin]]}; Get4Bits: PROC [source: PixelMap, s, f: INTEGER] RETURNS [CARDINAL] ~ TRUSTED INLINE {RETURN [LOOPHOLE[source.refRep.pointer + Basics.LongMult[(s - source.sOrigin), source.refRep.rast], LONG POINTER TO PACKED ARRAY [0..0) OF [0..16)][f - source.fOrigin]]}; Get8Bits: PROC [source: PixelMap, s, f: INTEGER] RETURNS [CARDINAL] ~ TRUSTED INLINE {RETURN [LOOPHOLE[source.refRep.pointer + Basics.LongMult[(s - source.sOrigin), source.refRep.rast], LONG POINTER TO PACKED ARRAY [0..0) OF [0..256)][f - source.fOrigin]]}; Get16Bits: PROC [source: PixelMap, s, f: INTEGER] RETURNS [CARDINAL] ~ TRUSTED INLINE {RETURN [LOOPHOLE[source.refRep.pointer + Basics.LongMult[(s - source.sOrigin), source.refRep.rast], LONG POINTER TO PACKED ARRAY [0..0) OF CARDINAL][f - source.fOrigin]]}; Equal: PROC [a, b: PixelMap] RETURNS [BOOLEAN]; IsAll: PROC [pixelMap: PixelMap, value: CARDINAL _ 0] RETURNS [BOOLEAN]; Trim: PROC [pixelMap: PixelMap, backround: CARDINAL _ 0] RETURNS [PixelMap]; Fill: PROC [dest: PixelMap, area: DeviceRectangle, value: CARDINAL, function: Function _ [null, null]]; Function: TYPE ~ RECORD [dstFunc: PrincOps.DstFunc, srcFunc: PrincOps.SrcFunc]; Transfer: PROC [dest, source: PixelMap, function: Function _ [null, null]]; Tile: TYPE ~ RECORD [ sOrigin, fOrigin: INTEGER, sSize, fSize: NAT, phase: INTEGER, refRep: REF PixelMapRep ]; CreateTile: PROC [pixelMap: PixelMap, phase: INTEGER _ 0, fSizeHint: NAT _ 100, scratch: REF PixelMapRep _ NIL] RETURNS [tile: Tile]; TileFromStipple: PROC [stipple: CARDINAL, scratch: REF PixelMapRep _ NIL] RETURNS [tile: Tile]; TileFromConstant: PROC [pixelValue: CARDINAL, lgBitsPerPixel: [0..4] _ 0, scratch: REF PixelMapRep _ NIL] RETURNS [tile: Tile]; TransferTile: PROC [dest: PixelMap, tile: Tile, function: Function _ [null, null]]; Rotate: PROC [pixelMap: PixelMap, scratch: REF PixelMapRep _ NIL] RETURNS [PixelMap]; Reflect: PROC [pixelMap: PixelMap, scratch: REF PixelMapRep _ NIL] RETURNS [PixelMap]; PixelMapRep: TYPE ~ RECORD [ ref: REF, pointer: LONG POINTER, words: LONG CARDINAL, lgBitsPerPixel: [0..4], -- logarithm base two of bitsPerPixel rast: CARDINAL, lines: CARDINAL ]; END. 4ImagerPixelMaps.mesa Michael Plass, October 27, 1983 9:18 am Edited by Doug Wyatt, November 21, 1983 7:05 pm Basic operations on two-dimensional arrays of pixels. This interface provides most of the functionality of BitBlt, without the attendant risks of smashing the world. To avoid confusion no matter how the map is physically laid out, terms like height and width are avoided, and the coordinates are expressed in terms of s and f, for slow and fast. On a display, the s axis is normally vertical, and points down, but on a printer that scans in the long direction, the f axis will point up. The diagram below takes the latter point of view. A PixelMap describes a window into a buffer, and the buffer itself may be positioned anywhere in a global device space. The windowing information is stored in the PixelMap record, so that it may be easily changed to accomplish translation and clipping by rectangles. The translation feature may be used for destination maps to conveniently implement band buffers. These parameters define a window within the buffer, as well as where the buffer is positioned in device space; they are fair game for clients to modify. Computes the intersection of device rectangles. Allocates a new pixel map. To create a description of a pre-allocated frame buffer as a PixelMap. The ref may be used for finalization, if desired; otherwise the client is responsible for making sure the storage does not go away while the PixelMap is still in use. A very fast way to clear a whole buffer. The effect is not limited to the windowed area. Makes a PixelMap from recycled storage. Copies the windowed part of a PixelMap. Translates the pixelMap in device space. Translates the window in device space. Further restricts the window Changes the window Returns a rectangle describing the actual bounds of the buffer p.Window.Intersect[p.BufferBounds] Raises bounds fault if the point is not in the window. The following inline versions of GetPixel assume that the client already knows the number of bits per pixel, and they do not do a bounds check, since the worst that can happen is an address fault. No bounds check; the worst that can happen is an address fault. Tests for equality. Tests for a constant. Shrinks the bounding box to remove unneeded background. [null, null] makes zero bits white, one bits black [or, null] makes zero bits transparent, one bits black [and, null] makes zero bits white, one bits black [and, complement] makes zero bits transparent, one bits white [xor, null] makes zero bits transparent, one bits inverted etcetera. Does a BITBLT from the source to the dest, through the intersection of the two windows. Does the right thing if the source and dest overlap in the same buffer. A tile is similar to a PixelMap, but the window specifications are more primitive, and there is an additional phase specification. A tile is replicated to fill the plane, with tile shifted by phase pixels in the f direction every source.sSize lines. The pixelMap is turned into a tile. This may involve replicating the pattern to make a larger tile that will speed the coloring operation, so the size of the result will not in general be the same as the source. The fSizeHint is used to help decide how big to make the macro-tile. The client may supply some scratch storage for re-use. Makes a 4-by-4 one-bit-per-pixel tile from the stipple bits. Makes a tile with a constant value. Transfers from the tiled plane to dest. Makes a pixelMap that is rotated 90 degrees counterclockwise. Repeat to get other rotations. Makes a pixelMap that is reflected about the f axis. Stored contiguously, with each line padded to a word boundary, rast words per line. The ref is for garbage collection hacks; the long pointer points to the actual bits. Must have rast*lines <= words. Clients should try to avoid dealing directly with this record. ส*˜Jšœ™J™'J™/J™5J™šฯk ˜ Jšœœ ˜Jšœ œ˜$Jšœ œ˜"—J˜Jšœœ ˜"Jšœ˜šœ˜Idefault™KšœฯbœG™ๅJ˜Jšœฯf˜JšœŸœŸ˜JšœŸ˜JšœŸ%˜(JšœŸ˜JšœŸฯs!Ÿ˜0JšœŸ˜JšœŸ˜!JšœŸ˜JšœŸ˜JšœŸ  Ÿ ˜JšœŸ˜JšœŸ ฯdŸก Ÿ ˜(JšœŸ"˜%JšœŸ˜JšœŸ  Ÿ˜JšœŸกŸ กŸ˜"JšœŸ-˜0JšœŸ ฯu˜JšœŸ˜ JšœŸ ˜JšœŸ˜ JšœŸ˜ JšœŸ˜ JšœŸ0˜3JšœŸขŸœ˜ K™Kšœํ™ํ—unitšœ œœ˜J™™Jšœœ˜Jšœ œ˜Jšœœ˜Jšœœ ˜Jšœ˜—Lšœœ˜4šฯn œœœ˜BJ™/—šฃœœ3œ ˜RJ™—šฃœœœ œœ œœ œ œœœœ ˜ฉJ™๎—šฃœœ˜!Jšœ8žœ™Y—šฃœœ œ?œ ˜lJšœ'™'—š ฃœœœœœ ˜LJšœ'™'—šฃœœœœ ˜?Jšœ(™(—šฃ œœœœ ˜BJšœ&™&—šฃœœ(œ ˜EJ™—šฃ œœ(œ ˜JJ™—Lšฃœœœ˜5šฃ œœœ˜;J™>—šฃ œœœ˜