| DRAW-IMAGE(2) | System Calls Manual | DRAW-IMAGE(2) |
Image - pictures and drawing
include "draw.m";
draw := load Draw Draw->PATH;
# compositing operators
SinD: con 1<<3;
DinS: con 1<<2;
SoutD: con 1<<1;
DoutS: con 1<<0;
S: con SinD|SoutD;
SoverD: con SinD|SoutD|DoutS;
SatopD: con SinD|DoutS;
SxorD: con SoutD|DoutS;
D: con DinS|DoutS;
DoverS: con DinS|DoutS|SoutD;
DatopS: con DinS|SoutD;
DxorS: con DoutS|SoutD;
Clear: con 0;
Image: adt
{
r: Rect;
clipr: Rect;
chans: Chans;
depth: int;
repl: int;
display: ref Display;
screen: ref Screen;
draw: fn(dst: self ref Image, r: Rect, src: ref Image,
mask: ref Image, p: Point);
drawop: fn(dst: self ref Image, r: Rect, src: ref Image,
mask: ref Image, p: Point, op: int);
gendraw: fn(dst: self ref Image, r: Rect, src: ref Image,
p0: Point, mask: ref Image, p1: Point);
gendrawop: fn(dst: self ref Image, r: Rect, src: ref Image,
p0: Point, mask: ref Image, p1: Point, op: int);
line: fn(dst: self ref Image, p0,p1: Point,
end0,end1,thick: int,
src: ref Image, sp: Point);
lineop: fn(dst: self ref Image, p0,p1: Point,
end0,end1,thick: int,
src: ref Image, sp: Point, op: int);
poly: fn(dst: self ref Image, p: array of Point,
end0,end1,thick: int,
src: ref Image, sp: Point);
polyop: fn(dst: self ref Image, p: array of Point,
end0,end1,thick: int,
src: ref Image, sp: Point, op: int);
bezspline: fn(dst: self ref Image, p: array of Point,
end0,end1,thick: int,
src: ref Image, sp: Point);
bezsplineop: fn(dst: self ref Image, p: array of Point,
end0,end1,thick: int,
src: ref Image, sp: Point, op: int);
fillpoly: fn(dst: self ref Image, p: array of Point,
wind: int, src: ref Image, sp: Point);
fillpolyop: fn(dst: self ref Image, p: array of Point,
wind: int, src: ref Image, sp: Point, op: int);
fillbezspline: fn(dst: self ref Image, p: array of Point,
wind: int, src: ref Image, sp: Point);
fillbezsplineop: fn(dst: self ref Image, p: array of Point,
wind: int, src: ref Image, sp: Point, op: int);
ellipse: fn(dst: self ref Image, c: Point, a, b,
thick: int, src: ref Image, sp: Point);
ellipseop: fn(dst: self ref Image, c: Point, a, b,
thick: int, src: ref Image, sp: Point, op: int);
fillellipse:fn(dst: self ref Image, c: Point, a, b: int,
src: ref Image, sp: Point);
fillellipseop:fn(dst: self ref Image, c: Point, a, b: int,
src: ref Image, sp: Point, op: int);
arc: fn(dst: self ref Image, c: Point, a, b, thick: int,
src: ref Image, sp: Point, alpha, phi: int);
arcop: fn(dst: self ref Image, c: Point, a, b, thick: int,
src: ref Image, sp: Point,
alpha, phi: int, op: int);
fillarc: fn(dst: self ref Image, c: Point, a, b: int,
src: ref Image, sp: Point, alpha, phi: int);
fillarcop: fn(dst: self ref Image, c: Point, a, b: int,
src: ref Image, sp: Point,
alpha, phi: int, op: int);
bezier: fn(dst: self ref Image, a,b,c,d: Point,
end0,end1,thick: int,
src: ref Image, sp: Point);
bezierop: fn(dst: self ref Image, a,b,c,d: Point,
end0,end1,thick: int,
src: ref Image, sp: Point, op: int);
fillbezier: fn(dst: self ref Image, a,b,c,d: Point, wind:int,
src: ref Image, sp: Point);
fillbezierop: fn(dst: self ref Image, a,b,c,d: Point, wind:int,
src: ref Image, sp: Point, op: int);
arrow: fn(a,b,c: int): int;
text: fn(dst: self ref Image, p: Point, src: ref Image,
sp: Point, font: ref Font, str: string): Point;
textop: fn(dst: self ref Image, p: Point, src: ref Image,
sp: Point, font: ref Font, str: string,
op: int): Point;
textbg: fn(dst: self ref Image, p: Point, src: ref Image,
sp: Point, font: ref Font, str: string,
bg: ref Image, bgp: Point): Point;
textbgop: fn(dst: self ref Image, p: Point, src: ref Image,
sp: Point, font: ref Font, str: string,
bg: ref Image, bgp: Point, op: int): Point;
border: fn(dst: self ref Image, r: Rect, i: int,
src: ref Image, sp: Point);
borderop: fn(dst: self ref Image, r: Rect, i: int,
src: ref Image, sp: Point, op: int);
readpixels: fn(src: self ref Image, r: Rect,
data: array of byte): int;
writepixels:fn(dst: self ref Image, r: Rect,
data: array of byte): int;
name: fn(im: self ref Image, s: string, in: int): int;
top: fn(win: self ref Image);
bottom: fn(win: self ref Image);
flush: fn(win: self ref Image, func: int);
origin: fn(win: self ref Image, log, scr: Point): int;
};
The Image type defines rectangular pictures and the methods to draw upon them; it is also the building block for higher level objects such as windows and fonts. In particular, a window is represented as an Image; no special operators are needed to draw on a window. Off-screen images can have an alpha channel, which gives each pixel an opacity factor, which in turn allows non-rectangular images to be defined (ie, pixels made fully transparent by the alpha channel do not appear when the image is displayed). Many drawing operations allow images to be shaped, or partial transparency added, by using the alpha channel of another image as a mask (also called a `matte'). There are two functions in Image for each such operation. One has an op suffix, and takes an explicit image compositing operator: S, D, SinD,..., SoverD and so on. (See the Porter-Duff paper mentioned below for the meaning of each operation.) The other function (without the op suffix) provides as its default operation the most common operation, SoverD, by which the source image, within its matte, is drawn over the destination image.
An Image has a pixel channel structure as described in colour (6), represented by a value of the Chans adt, defined in draw-display (2). The channel structure of an image is fixed when the image is allocated.
Image has the following components:
/libdraw
draw-intro (2), draw-display (2), draw-point (2), draw-rect (2), draw-screen (2), colour (6), image (6), font (6) utf (6)
T. Porter, T. Duff. ``Compositing Digital Images'', Computer Graphics (Proc. SIGGRAPH), 18:3, pp. 253-259, 1984.
These functions raise exceptions if argument images are nil, except for draw and gendraw where the mask image is optional and may be nil.
Anti-aliased characters can be drawn by defining a font with multiple bits per pixel, but there are no anti-aliasing geometric primitives.