ImagerPixelMapsExtras.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Frank Crow, August 16, 1984 9:13:01 am PDT
Fancy operations on two-dimensional arrays of pixels.
Last Edited by: Stone, August 15, 1984 7:07:11 pm PDT
DIRECTORY
Basics     USING [LongMult],
ImagerBasic   USING [IntPair],
ImagerPixelMaps  USING [PixelMap, Function];
ImagerPixelMapsExtras: CEDAR DEFINITIONS
IMPORTS Basics
~ BEGIN
Type Definitions
PixelMap: TYPE ~ ImagerPixelMaps.PixelMap;
Function: TYPE ~ ImagerPixelMaps.Function;
IntPair: TYPE ~ ImagerBasic.IntPair;
ByteSequence: TYPE ~ RECORD [PACKED SEQUENCE length: CARDINAL OF [0..256)];
Pixel operations
FillConstantTrap: PROC [destination: PixelMap,   -- trapezoid, constant color
        top, bottom, leftTop, leftBot, rightTop, rightBot: NAT,
        pxlValue: CARDINAL, function: Function ← [null, null]];
FillSmoothTrap: PROC [ destination: PixelMap,  -- trapezoid, bilinear interpolated 8-bit color
        top, bottom, leftTop, leftBot, rightTop, rightBot: NAT,
        leftTopVal, leftBotVal, rightTopVal, rightBotVal: NAT ];
DrawLine: PUBLIC PROC [destination: PixelMap,   -- fast line, constant color
        p1, p2: IntPair,
        pxlValue: CARDINAL, function: Function ← [null, null]];
DrawBltLine: PUBLIC PROC [destination: PixelMap, -- fast line using BitBLT, constant color
          p1, p2: IntPair,
          pxlValue: CARDINAL, function: Function ← [null, null]];
LoadScanSeg: PUBLIC PROC[destination: PixelMap,
         s, f: INTEGER, length: NAT,
         segment: LONG POINTER, offset: NAT ← 0];
StoreScanSeg: PUBLIC PROC [source: PixelMap,
         s, f: INTEGER, length: NAT,
         segment: LONG POINTER, offset: NAT ← 0];
MergeMaps: PROC[dstMap, srcMap: PixelMap, srcWidth, dstOffset: NAT];
Merge source pixelMap into destination pixelMap. Take "srcWidth" least significant bits from "srcMap" pixels and load them into "dstMap" pixels offset by "dstOffset" bits.
SetPixel: PROC [destination: PixelMap, s, f: INTEGER, value: CARDINAL];
Raises bounds fault if the point is not in the window.
The following inline versions of SetPixel 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.
SetBit: PROC [dest: PixelMap, s, f: INTEGER, value: CARDINAL] ~ TRUSTED INLINE {
LOOPHOLE[
dest.refRep.pointer + Basics.LongMult[(s - dest.sOrigin), dest.refRep.rast],
LONG POINTER TO PACKED ARRAY [0..0) OF [0..2)]
[f - dest.fOrigin] ← value;
};
Set2Bits: PROC [dest: PixelMap, s, f: INTEGER, value: CARDINAL] ~ TRUSTED INLINE {
LOOPHOLE[
dest.refRep.pointer + Basics.LongMult[(s - dest.sOrigin), dest.refRep.rast],
LONG POINTER TO PACKED ARRAY [0..0) OF [0..4)]
[f - dest.fOrigin] ← value;
};
Set4Bits: PROC [dest: PixelMap, s, f: INTEGER, value: CARDINAL] ~ TRUSTED INLINE {
LOOPHOLE[
dest.refRep.pointer + Basics.LongMult[(s - dest.sOrigin), dest.refRep.rast],
LONG POINTER TO PACKED ARRAY [0..0) OF [0..16)]
[f - dest.fOrigin] ← value;
};
Set8Bits: PROC [dest: PixelMap, s, f: INTEGER, value: CARDINAL] ~ TRUSTED INLINE {
LOOPHOLE[
dest.refRep.pointer + Basics.LongMult[(s - dest.sOrigin), dest.refRep.rast],
LONG POINTER TO PACKED ARRAY [0..0) OF [0..256)]
[f - dest.fOrigin] ← value;
};
Set16Bits: PROC [dest: PixelMap, s, f: INTEGER, value: CARDINAL] ~ TRUSTED INLINE {
LOOPHOLE[
dest.refRep.pointer + Basics.LongMult[(s - dest.sOrigin), dest.refRep.rast],
LONG POINTER TO PACKED ARRAY [0..0) OF CARDINAL]
[f - dest.fOrigin] ← value;
};
END.