|
|
1.1 ! root 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 ! 8: static char sccsid[] = "@(#)minmax.c 5.1 (Berkeley) 4/30/85"; ! 9: #endif not lint ! 10: ! 11: /* ! 12: * minmax: find the 4 edges of the glyph within a window. ! 13: */ ! 14: ! 15: #include "bit.h" ! 16: ! 17: minmax(g, nrow, ncol, rmin, cmin, rmax, cmax) ! 18: bitmat g; ! 19: int nrow, ncol; ! 20: int *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: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.