ColorTrixBasics.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Bloomenthal, December 4, 1986 9:19:08 pm PST
DIRECTORY Basics, Draw2d, Imager, ImagerColorMap, ImagerColorOperator, ImagerPixelArray, ImagerPixelMap, ImagerSample, InterminalBackdoor, Interpress, IO, Rope, Terminal;
ColorTrixBasics: CEDAR DEFINITIONS
IMPORTS Imager
~ BEGIN
DeviceRectangle: TYPE ~ ImagerPixelMap.DeviceRectangle;
PixelMap:    TYPE ~ ImagerPixelMap.PixelMap;
PixelMapMisc:  TYPE ~ RECORD [
bpp:       INTEGER,  -- 8 or 24 bits per pixel
bw, rg, b:     PixelMap, -- black/white, red/green and blue 8 bit pixel maps
x, y, w, h:     INTEGER  -- the window
];
VtMode:     TYPE ~ {dither, gray, none};
CdType:     TYPE ~ {gray, smooth, color};
PixelProc:    TYPE ~ Draw2d.PixelProc;
ValueProc:   TYPE ~ PROC [x, y: INTEGER, data: REF ANYNIL]
        RETURNS [value: CARDINAL];
RGBProc:    TYPE ~ PROC [x, y: INTEGER, data: REF ANYNIL]
        RETURNS [r, g, b: CARDINAL];
Generic Pixel Map Operations
InsureColorDisplayOn: PUBLIC PROC [bpp: NAT];
Insure that the color display is on with the given number of bits.
GetColorDisplayPmMisc: PROC RETURNS [pmMisc: PixelMapMisc];
Return the color display pixel maps, which depend on the mode of the color display.
ShowPmMisc: PROC [pmMisc: PixelMapMisc];
Transfer pixel map to color display for viewing; make color display mode and pmMisc agree.
8 Bit Pixel Map Operations
GetColorDisplayPm: PROC RETURNS [pm: PixelMap];
Set the color display to 8 bit mode if necessary and return its pixel map.
ShowPm: PROC [pm: PixelMap];
Transfer the pixel map to the color display for viewing.
FillPm: PROC [pm: PixelMap, color: CARDINAL];
Fill the pixel map with color.
PutPixel: PROC [pm: PixelMap, x, y: INTEGER, value: CARDINAL];
Write to (x, y) the 8 bit value.
GetPixel: PROC [pm: PixelMap, x, y: INTEGER] RETURNS [value: CARDINAL];
Read from (x, y) the 8 bit value.
PutBox: PROC [pm: PixelMap, x0, y0, x1, y1: INTEGER, value: CARDINAL];
Fill the box with the r, g, b values.
PutLine: PROC [pm: PixelMap, x0, y0, x1, y1: INTEGER, value: CARDINAL];
Draw a one pixel wide line from (x0, y0) to (x1, y1).
PutScanLine: PROC [pm: PixelMap, y: INTEGER, proc: ValueProc, data: REF ANYNIL];
Write scanline-y to the 8 bit color display; buffers the line to improve efficiency.
PutFrame: PROC [pm: PixelMap, proc: ValueProc, data: REF ANYNIL];
Write entire frame to the 8 bit color display; buffers each line to improve efficiency.
This is approximately 3 times faster than calling PutPixel[] for each pixel.
24 Bit Pixel Map Operations
FillRGBPm: PROC [pmMisc: PixelMapMisc, r, g, b: CARDINAL];
Fill pmMisc with r, g, b; no-op if pmMisc is an 8 bit buffer.
PutRGBPixel: PROC [pmMisc: PixelMapMisc, x, y: INTEGER, r, g, b: CARDINAL];
Write to (x, y) the 24 bit r, g, b value; no-op if pmMisc is an 8 bit buffer.
GetRGBPixel: PROC [pmMisc: PixelMapMisc, x, y: INTEGER] RETURNS [r, g, b: CARDINAL];
Read from (x, y) the 24 bit r, g, b value; no-op if pmMisc is an 8 bit buffer.
PutRGBBox: PROC [pmMisc: PixelMapMisc, x0, x1, y0, y1: INTEGER, r, g, b: CARDINAL];
Fill the box with the r, g, b values. No-op if pmMisc is an 8 bit buffer.
PutRGBLine: PROC [pmMisc: PixelMapMisc, x0, x1, y0, y1: INTEGER, r, g, b: CARDINAL];
Draw a one pixel wide line from (x0, y0) to (x1, y1). No-op if pmMisc is an 8 bit buffer.
PutRGBScanLine: PROC [
pmMisc: PixelMapMisc, y: INTEGER, proc: RGBProc, data: REF ANYNIL];
Write scanline-y to the 24 bit color display; buffers the line to improve efficiency.
No-op if pmMisc is an 8 bit buffer.
PutRGBFrame: PROC [pmMisc: PixelMapMisc, proc: RGBProc, data: REF ANYNIL];
Write entire frame to the 24 bit color display; buffers each line to improve efficiency.
No-op if pmMisc is an 8 bit buffer.
This is approximately 3 times faster than calling PutRGBPixel[] for each pixel.
PixelMapMisc Operations
SetPmMiscWindow: PROC [pm: PixelMapMisc, x, y, w, h: NAT] RETURNS [PixelMapMisc];
Set the window of the appropriate pixel maps.
FillPmMisc: PROC [pm: PixelMapMisc, r, g, b: CARDINAL ← 0];
Fill the appropriate pixel maps (if bw, fill bw with r value).
WindowFromPmMisc: PROC [pm: PixelMapMisc] RETURNS [DeviceRectangle];
Return the ImagerPixelMap style window.
CreatePmMisc: PROC [bpp: NAT, x, y, w, h: NAT] RETURNS [p: PixelMapMisc];
Create the appropriate pixel maps of the given size.
CopyPmMisc: PROC [src, dst: PixelMapMisc];
Copy src to dst through the intersection of their window.
CopyClippedPmMisc: PROC [src, dst: PixelMapMisc, xSrc, ySrc, w, h: NAT];
Clip the src and translate it to the beginning of dst; the copied size is w by h.
Imager Context Operations
InitCd: PROC [
type: CdType, pixelUnits: BOOLTRUE, clear: BOOLFALSE, cmapInit: BOOLTRUE]
RETURNS [Imager.Context];
ClearCd: PROC [cd: Imager.Context, color: Imager.ConstantColor ← Imager.black];
Clear context to specified color.
ClearVt: PROC [vt: Terminal.Virtual ← NIL, val: INTEGER ← 0];
Clear terminal to specified value.
Miscellaneous
SetVtMode: PUBLIC PROC [vtMode: VtMode] RETURNS [Terminal.Virtual];
Return color display virtual terminal. If mode is gray, then a gray display is created with
8pp. All 24bpp displays must be dither displays. The color display status is set and the
color display turned on.
END.