|
|
1.1 ! root 1: /* minmax.c 4.1 83/03/09 */ ! 2: /* ! 3: * minmax: find the 4 edges of the glyph within a window. ! 4: */ ! 5: ! 6: #include "bit.h" ! 7: ! 8: minmax(g, nrow, ncol, rmin, cmin, rmax, cmax) ! 9: bitmat g; ! 10: int nrow, ncol; ! 11: int *rmin, *cmin, *rmax, *cmax; ! 12: { ! 13: register int i, j; ! 14: register int r1, r2, c1, c2; ! 15: int ar1, ar2, ac1, ac2; ! 16: ! 17: aminmax(g, nrow, ncol, &ar1, &ac1, &ar2, &ac2); ! 18: #ifdef TRACE ! 19: if (trace) ! 20: fprintf(trace, "aminmax returns %d, %d, %d, %d\n", ar1, ac1, ar2, ac2); ! 21: #endif ! 22: r1 = nrow; c1 = ncol; r2 = c2 = 0; ! 23: for (i=ar1; i<=ar2; i++) ! 24: for (j=ac1; j<=ac2; j++) ! 25: if (mat(g, nrow, ncol, i, j, 8)) { ! 26: r1 = min(r1, i); ! 27: r2 = max(r2, i); ! 28: c1 = min(c1, j); ! 29: c2 = max(c2, j); ! 30: } ! 31: if (r2 < r1) { ! 32: /* empty glyph! */ ! 33: r1 = c1 = r2 = c2 = 1; ! 34: } ! 35: *rmin = r1; *rmax = r2; ! 36: *cmin = c1; *cmax = c2; ! 37: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.