include	"draw.m";
draw := load Draw Draw->PATH;
Display: adt
{
    image:       ref Image;
    white:       ref Image;
    black:       ref Image;
    opaque:      ref Image;
    transparent: ref Image;
    allocate:    fn(dev: string): ref Display;
    startrefresh:fn(d: self ref Display);
    publicscreen:fn(d: self ref Display, id: int):
                 ref Screen;
    newimage:    fn(d: self ref Display,
                 r: Rect, chans: Chans,
                 repl, rgba: int):
                 ref Image;
    color:       fn(d: self ref Display, rgba: int):
                 ref Image;
    colormix:    fn(d: self ref Display, one: int, three: int):
                 ref Image;
    rgb:         fn(d: self ref Display, red, green, blue: int):
                 ref Image;
    namedimage:  fn(d: self ref Display, name: string):
                 ref Image;
    open:        fn(d: self ref Display, name: string):
                 ref Image;
    readimage:   fn(d: self ref Display, fd: ref Sys->FD):
                 ref Image;
    writeimage:  fn(d: self ref Display, fd: ref Sys->FD,
                 i: ref Image): int;
    rgb2cmap:    fn(d: self ref Display, red, green, blue: int):
                 int;
    cmap2rgb:    fn(d: self ref Display, c: int):
                 (int, int, int);
    cmap2rgba:   fn(d: self ref Display, c: int):
                 int;
};
Chans: adt
{
   mk:    fn(s: string): Chans;
   text:  fn(c: self Chans): string;
   eq:    fn(c: self Chans, d: Chans): int;
   depth: fn(c: self Chans): int;
};
The pixel channel structure of an Image is determined when the image is allocated (including the image allocated by the system to represent a physical display). This structure is described externally by a channel format string, described in colour(6), and internally by a value of the Chans adt, which is used when allocating new images in the calls below. Draw defines a set of constants of type Chans for common channel types: GREY1, GREY2 and GREY8 for greyscale (depths 1, 2 and 8); CMAP8 for 8-bit rgbv(8) colour-mapped images; RGB16 for 16-bit r5g6b5 colour images; RGB24 for 24-bit colour; and RGBA32 for 24-bit colour with alpha channel. Chans has the following operations:
Colours in the calls below are specified as 32-bit integers (`32-bit RGBA format') containing red, green, blue and alpha components as 8-bit values, in order from most to least significant byte. The 8-bit colour component values express illumination, ranging from 0 (no colour) to 255 (saturated). For the alpha component, 0 is fully transparent, and 255 is fully opaque.
Display itself has the following components:
Opaque: con int 16rFFFFFFFF; Transparent: con int 16r00000000; Black: con int 16r000000FF; White: con int 16rFFFFFFFF; Red: con int 16rFF0000FF; Green: con int 16r00FF00FF; Blue: con int 16r0000FFFF; Cyan: con int 16r00FFFFFF; Magenta: con int 16rFF00FFFF; Yellow: con int 16rFFFF00FF; Grey: con int 16rEEEEEEFF; Paleyellow: con int 16rFFFFAAFF; Darkyellow: con int 16rEEEE9EFF; Darkgreen: con int 16r448844FF; Palegreen: con int 16rAAFFAAFF; Medgreen: con int 16r88CC88FF; Darkblue: con int 16r000055FF; Palebluegreen: con int 16rAAFFFFFF; Paleblue: con int 16r0000BBFF; Bluegreen: con int 16r008888FF; Greygreen: con int 16r55AAAAFF; Palegreygreen: con int 16r9EEEEEFF; Yellowgreen: con int 16r99994CFF; Medblue: con int 16r000099FF; Greyblue: con int 16r005DBBFF; Palegreyblue: con int 16r4993DDFF; Purpleblue: con int 16r8888CCFF; Notacolor: con int 16rFFFFFF00; Nofill: con Notacolor;
The special values Draw->Opaque (fully opaque) and Draw->Transparent (fully transparent) are useful as the pixel values for Display.newimage when forming a matte. The special value Draw->Nofill tells Display.newimage not to paint a new image with any colour, leaving it uninitialised.
| DRAW-DISPLAY(2 ) | Rev: Thu Feb 15 14:43:27 GMT 2007 |