Appendix III: Utility Routines and Data Formats (1)
BITMAP(FAX)
NAME
bitmap - convert vector format to core bit map
SYNOPSIS
int bitmap(ivec, cnt, buff);
int *ivec;
int cnt;
char *buff;
DESCRIPTION
Bitmap converts the fax vector format into a bit map, using each bit of the area pointed to by buff. The number of ele-ments in ivec is given by cnt, and the first element of ivec is taken as a white pel count, the second as a black pel count, etc. The resultant bit map is placed in the area pointed to by buff. The actual number of bits stored is re-turned from the function. The bits in buff are stored in byte order, with the highest value bit of the byte taken as the first bit of the byte.
BUGS
You have to make sure that buff is big enough for all the bits.
SEE ALSO
vector(fax), tovec(fax)
TOVEC(FAX)
NAME
tovec - convert bitmap to vector format
SYNOPSIS
int *tovec(buff, nbits);
char *buff;
int nbits;
DESCRIPTION
The bitmap in the buffer pointed to by buff is converted to vector format. The length of the bitmap in bits is passed in nbits. As the caller would normally not know how many vec-tor elements are going to be needed, the tovec routine allo-cates this area for the user.
Buff is assumed to be organised in byte order with the highest value bit of each byte being the first bit of the byte. The counts of white and black pels are placed into an integer vector, the first element of which is the length of the rest of the vector. The vector information proper starts in the second element which is the count of the number of leading white pels. This is followed by the count of the numbr of black pels, etc.
The routine goes to great lengths to make sure only enough vector storage is allocated. Temporary storage is allocated in small chunks and then, when the length of the whole vec-tor is known, the chunks are contacenated into a contiguous vector. The pointer to this vector is returned to the user.
SEE ALSO
vector(fax), bitmap(fax)
CHOICE(FAX)
NAME
choice - specify a rectangular area on Grinnell
SYNOPSIS
struct square {
int x0, y0;
int x1, y1;
};
struct square *choice(colour, height, width, area, fw, fh)
char colour;
int height, width, area, fw, fh;
DESCRIPTION
This subroutine is called by a MOS task. to specify a rec-tangular area of an image by manipulating a square on the Grinnel display being illustrating the image. The dimension of the original image is defined as height and width. The area on which the original image is shown is specified by the parameter area.
value area dimension coordinates
0 the whole screen 512x512 0,511,511,0
1 the left half 256x512 0,511,255,0
2 the right half 256x512 256,511,511,0
The square will be drwan in a colour defined by the parame-ter colour, which can only be:
value colour
'r' red
'g' green
'b' blue
There are two modes being supported:
(1) Fixed: The square will have a fixed dimension specified by the parameters fw and fh. The operator can move the square around as a whole within the predetermined area by using following commands, each of which is invoked by typing the corresponding characer on the keyboard of the system console.
command function
'u' move the square up one step
'd' move the square down one step
'l' move the square one step left
'r' move the square one step right
'f' move fast - set the step to 8 pel
'o' move slowly - set the step to 1 pel
<CR> ok - the area has been chosen, and
return its coordinates
(2) Arbitrary: This mode is set up when the subroutine is called with the parameters fw and fh set to 0. Any edge of the square can be selected to be moved on its own by using the same commands described above. The following commands are required to select the relevant edge as well as switching the operation mode.
command function
'e' select the right ('east') edge.
'w' select the left ('west') edge.
'n' select the upper ('north') edge.
's' select the lower ('south') edge.
'a' move the square as a whole
As soon as the user types <CR>, the coordinates of the current square, which are accommodated in a square struc-ture, are returned. Note these are concerned with the coor-dinate system defined for the image but not for the grin-nell.
BUGS
Currently, only three working areas can be used.
SEE ALSO
vector(fax), grinnell(dev), grinnell(fax)
CRC(FAX)
NAME
crc - calculate or check the DACOM CRC code
SYNOPSIS
int crc(buff, insert);
char *buff;
int insert;
DESCRIPTION
This routine will check/insert the 12-bit CRC code for a DACOM block, pointed to by buff. The block contains 585 bits, the last 12 bits being the CRC code. The block is checked only when the parameter insert is set to 0, other-wise the CRC code is created and inserted into the block. When the block is checked, the routine returns the result: 0 means OK and any non-zero value means the block is bad. On the other hand, when the CRC code is inserted, the routine returns the CRC code it has created.
This routine uses a tabular approach to determine the CRC code, processing a whole byte at a time and resulting in a high throughput.
BUGS
Do not forget to supply enough space when the 12-bit CRC code is to be inserted.
SEE ALSO
dacom(dev)