date and time created 83/08/05 13:34:37 by sam
[unix-history] / usr / src / old / lib2648 / aminmax.c
CommitLineData
ba67e389
RC
1/* aminmax.c 4.1 83/03/09 */
2/*
3 * aminmax: find the 4 edges of the glyph within a window.
4 * This version is approximate, in that it may include some
5 * blank areas. But it's much faster because it doesn't have
6 * to call mat over and over.
7 */
8
9#include "bit.h"
10
11aminmax(g, nrow, ncol, rmin, cmin, rmax, cmax)
12bitmat g;
13int nrow, ncol;
14int *rmin, *cmin, *rmax, *cmax;
15{
16 register int i, j;
17 register int nc = (ncol+7)>>3;
18 register int r1, r2, c1, c2;
19
20 r1 = nrow; c1 = nc; r2 = c2 = 0;
21 for (i=0; i<nrow; i++)
22 for (j=0; j<nc; j++)
23 if (g[i*nc+j]) {
24 r1 = min(r1, i);
25 r2 = max(r2, i);
26 c1 = min(c1, j);
27 c2 = max(c2, j);
28 }
29 if (r2 < r1) {
30 /* empty glyph! */
31 r1 = c1 = r2 = c2 = 1;
32 }
33 *rmin = r1; *rmax = r2;
34 *cmin = 8*c1; *cmax = 8*c2+7;
35}