BSD 4_3_Reno release
[unix-history] / usr / src / old / lib2648 / minmax.c
CommitLineData
051b1e55
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
7#ifndef lint
95f51977 8static char sccsid[] = "@(#)minmax.c 5.1 (Berkeley) 4/30/85";
051b1e55
DF
9#endif not lint
10
e5de0618
RC
11/*
12 * minmax: find the 4 edges of the glyph within a window.
13 */
14
15#include "bit.h"
16
17minmax(g, nrow, ncol, rmin, cmin, rmax, cmax)
18bitmat g;
19int nrow, ncol;
20int *rmin, *cmin, *rmax, *cmax;
21{
22 register int i, j;
23 register int r1, r2, c1, c2;
24 int ar1, ar2, ac1, ac2;
25
26 aminmax(g, nrow, ncol, &ar1, &ac1, &ar2, &ac2);
27#ifdef TRACE
28 if (trace)
29 fprintf(trace, "aminmax returns %d, %d, %d, %d\n", ar1, ac1, ar2, ac2);
30#endif
31 r1 = nrow; c1 = ncol; r2 = c2 = 0;
32 for (i=ar1; i<=ar2; i++)
33 for (j=ac1; j<=ac2; j++)
34 if (mat(g, nrow, ncol, i, j, 8)) {
35 r1 = min(r1, i);
36 r2 = max(r2, i);
37 c1 = min(c1, j);
38 c2 = max(c2, j);
39 }
40 if (r2 < r1) {
41 /* empty glyph! */
42 r1 = c1 = r2 = c2 = 1;
43 }
44 *rmin = r1; *rmax = r2;
45 *cmin = c1; *cmax = c2;
46}