160 #include <config_auto.h>
165 #include "allheaders.h"
195 l_int32 i, n, d, xb, yb, wb, hb, res;
200 return (
PIX *)ERROR_PTR(
"pixa not defined", __func__, NULL);
203 if (n == 0 && w == 0 && h == 0)
204 return (
PIX *)ERROR_PTR(
"no components; no size", __func__, NULL);
206 L_WARNING(
"no components; returning empty 1 bpp pix\n", __func__);
212 if (w == 0 || h == 0) {
216 if (w == 0 || h == 0)
217 return (
PIX *)ERROR_PTR(
"no associated boxa", __func__, NULL);
222 d = pixGetDepth(pix1);
223 res = pixGetXRes(pix1);
227 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
231 for (i = 0; i < n; i++) {
233 L_WARNING(
"no box found!\n", __func__);
271 l_int32 i, n, same, maxd, index, xb, yb, wb, hb, res;
273 PIX *pixs, *pix1, *pixd;
277 return (
PIX *)ERROR_PTR(
"pixa not defined", __func__, NULL);
280 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
283 return (
PIX *)ERROR_PTR(
"not all components are 1 bpp", __func__, NULL);
287 if (w == 0 || h == 0) {
295 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
300 for (i = 0; i < n; i++) {
301 index = 1 + (i % 254);
304 if (i == 0) res = pixGetXRes(pixs);
341 l_float32 scalefactor,
347 l_int32 i, n, x, y, w, h, depth, bordval;
349 PIX *pix1, *pix2, *pix3, *pixd;
352 if (pboxa) *pboxa = NULL;
354 return (
PIX *)ERROR_PTR(
"pixas not defined", __func__, NULL);
355 if (direction != L_HORIZ && direction != L_VERT)
356 return (
PIX *)ERROR_PTR(
"invalid direction", __func__, NULL);
365 bordval = (depth == 1) ? 1 : 0;
367 for (i = 0; i < n; i++) {
369 L_WARNING(
"missing pix at index %d\n", __func__, i);
373 if (scalefactor != 1.0)
374 pix2 =
pixScale(pix1, scalefactor, scalefactor);
384 if (direction == L_HORIZ)
437 l_int32 n, nw, nh, w, h, d, wt, ht, res, samedepth;
438 l_int32 index, i, j, hascmap;
441 PIX *pix1, *pix2, *pixd;
444 if (pncols) *pncols = 0;
445 if (pboxa) *pboxa = NULL;
447 return (
PIX *)ERROR_PTR(
"pixa not defined", __func__, NULL);
451 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
454 if (hascmap || !samedepth) {
456 for (i = 0; i < n; i++) {
467 nw = (l_int32)sqrt((l_float64)n);
468 nh = (n + nw - 1) / nw;
474 d = pixGetDepth(pix1);
475 res = pixGetXRes(pix1);
477 if ((pixd =
pixCreate(w, h, d)) == NULL) {
479 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
487 for (i = 0; i < nh; i++) {
488 for (j = 0; j < nw && index < n; j++, index++) {
491 if (wt > cellw || ht > cellh) {
492 L_INFO(
"pix(%d) omitted; size %dx%x\n", __func__, index,
501 box =
boxCreate(j * cellw, i * cellh, wt, ht);
508 snprintf(buf,
sizeof(buf),
"n = %d",
boxaGetCount(boxa));
511 if (pncols) *pncols = nw;
549 l_uint32 bordercolor)
551 l_int32 w, h, d, wt, ht;
552 l_int32 i, j, k, x, y, n;
556 return (
PIX *)ERROR_PTR(
"pixa not defined", __func__, NULL);
557 if (nx <= 0 || ny <= 0)
558 return (
PIX *)ERROR_PTR(
"nx and ny must be > 0", __func__, NULL);
560 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
562 return (
PIX *)ERROR_PTR(
"n != nx * ny", __func__, NULL);
563 borderwidth = L_MAX(0, borderwidth);
566 w = nx * (wt + 2 * borderwidth);
567 h = ny * (ht + 2 * borderwidth);
570 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
578 for (i = 0, k = 0; i < ny; i++) {
580 for (j = 0; j < nx; j++, k++) {
584 x += wt + 2 * borderwidth;
586 y += ht + 2 * borderwidth;
623 l_int32 wmax, hmax, wd, hd, d, hascmap, res, same;
624 l_int32 i, j, n, ni, ncols, nrows;
625 l_int32 ystart, xstart, wt, ht;
626 PIX *pix1, *pix2, *pixd;
630 return (
PIX *)ERROR_PTR(
"pixa not defined", __func__, NULL);
631 spacing = L_MAX(spacing, 0);
633 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
639 for (i = 0; i < n; i++) {
653 return (
PIX *)ERROR_PTR(
"depths not equal", __func__, NULL);
658 ncols = (l_int32)((l_float32)(maxwidth - spacing) /
659 (l_float32)(wmax + spacing));
660 ncols = L_MAX(ncols, 1);
661 nrows = (n + ncols - 1) / ncols;
662 wd = wmax * ncols + spacing * (ncols + 1);
663 hd = hmax * nrows + spacing * (nrows + 1);
664 if ((pixd =
pixCreate(wd, hd, d)) == NULL) {
666 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
670 if ((background == 1 && d == 1) || (background == 0 && d != 1))
674 for (i = 0, ni = 0; i < nrows; i++) {
675 ystart = spacing + i * (hmax + spacing);
676 for (j = 0; j < ncols && ni < n; j++, ni++) {
677 xstart = spacing + j * (wmax + spacing);
679 if (ni == 0) res = pixGetXRes(pix1);
733 l_float32 scalefactor,
740 l_int32 bordval, wtry, wt, ht;
744 l_int32 i, j, index, n, x, y, nrows, ninrow, res;
750 PIX *pix, *pixn, *pix1, *pixd;
754 return (
PIX *)ERROR_PTR(
"pixa not defined", __func__, NULL);
755 if (outdepth != 1 && outdepth != 8 && outdepth != 32)
756 return (
PIX *)ERROR_PTR(
"outdepth not in {1, 8, 32}", __func__, NULL);
757 spacing = L_MAX(spacing, 0);
758 border = L_MAX(border, 0);
759 if (scalefactor <= 0.0) scalefactor = 1.0;
762 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
766 bordval = (outdepth == 1) ? 1 : 0;
767 for (i = 0; i < n; i++) {
773 else if (outdepth == 8)
779 if (scalefactor != 1.0)
780 pix1 =
pixScale(pixn, scalefactor, scalefactor);
794 L_WARNING(
"only got %d components\n", __func__, n);
797 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
807 for (i = 0, irow = 0; i < n; i++, irow++) {
809 wtry = w + wt + spacing;
810 if (wtry > maxwidth) {
813 wmaxrow = L_MAX(wmaxrow, w);
816 w = wt + 2 * spacing;
820 maxh = L_MAX(maxh, ht);
827 wmaxrow = L_MAX(wmaxrow, w);
830 if ((pixd =
pixCreate(wmaxrow, h, outdepth)) == NULL) {
834 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
838 if ((background == 1 && outdepth == 1) ||
839 (background == 0 && outdepth != 1))
847 for (i = 0, index = 0; i < nrows; i++) {
851 for (j = 0; j < ninrow; j++, index++) {
854 res = pixGetXRes(pix);
859 wt - 2 * border, ht - 2 *border),
L_INSERT);
914 l_float32 scalefactor,
918 l_int32 i, j, index, n, x, y, nrows, wb, hb, w, h, maxd, maxh, bordval, res;
923 PIX *pix1, *pix2, *pix3, *pixd;
927 return (
PIX *)ERROR_PTR(
"pixas not defined", __func__, NULL);
928 border = L_MAX(border, 0);
929 if (scalefactor <= 0.0) scalefactor = 1.0;
931 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
939 bordval = (maxd == 1) ? 1 : 0;
940 for (i = 0; i < n; i++) {
943 if (scalefactor != 1.0)
944 pix2 =
pixScale(pix1, scalefactor, scalefactor);
951 if (i == 0) res = pixGetXRes(pix3);
959 L_WARNING(
"only got %d components\n", __func__, n);
962 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
968 nrows = (n + nx - 1) / nx;
970 for (i = 0, index = 0; i < nrows; i++) {
973 for (j = 0; j < nx && index < n; j++) {
977 maxh = L_MAX(maxh, hb + spacing);
987 pixd =
pixaDisplay(pixa2, w + spacing, h + spacing);
1033 l_int32 x, y, w, h, wd, hd, d, res;
1034 l_int32 i, n, nrows, maxht, ninrow, irow, bordval;
1036 l_float32 scalefact;
1037 PIX *pix, *pixn, *pix1, *pixb, *pixd;
1041 return (
PIX *)ERROR_PTR(
"pixa not defined", __func__, NULL);
1042 if (outdepth != 1 && outdepth != 8 && outdepth != 32)
1043 return (
PIX *)ERROR_PTR(
"outdepth not in {1, 8, 32}", __func__, NULL);
1045 return (
PIX *)ERROR_PTR(
"ncols must be > 0", __func__, NULL);
1046 spacing = L_MAX(spacing, 0);
1047 if (border < 0 || border > tilewidth / 5)
1050 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
1054 bordval = (outdepth == 1) ? 1 : 0;
1055 for (i = 0; i < n; i++) {
1060 scalefact = (l_float32)(tilewidth - 2 * border) / (l_float32)w;
1061 if (d == 1 && outdepth > 1 && scalefact < 1.0)
1064 pix1 =
pixScale(pix, scalefact, scalefact);
1068 else if (outdepth == 8)
1085 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
1089 wd = tilewidth * ncols + spacing * (ncols + 1);
1090 nrows = (n + ncols - 1) / ncols;
1091 if ((rowht = (l_int32 *)LEPT_CALLOC(nrows,
sizeof(l_int32))) == NULL) {
1093 return (
PIX *)ERROR_PTR(
"rowht array not made", __func__, NULL);
1098 for (i = 0; i < n; i++) {
1102 maxht = L_MAX(h, maxht);
1103 if (ninrow == ncols) {
1104 rowht[irow] = maxht;
1111 rowht[irow] = maxht;
1115 hd = spacing * (nrows + 1);
1116 for (i = 0; i < nrows; i++)
1120 if ((background == 1 && outdepth == 1) ||
1121 (background == 0 && outdepth != 1))
1127 for (i = 0; i < n; i++) {
1130 res = pixGetXRes(pix);
1134 if (i && ((i % ncols) == 0)) {
1136 y += spacing + rowht[irow];
1140 x += tilewidth + spacing;
1180 l_float32 scalefactor,
1190 PIX *pix1, *pix2, *pix3, *pix4, *pixd;
1194 return (
PIX *)ERROR_PTR(
"pixa not defined", __func__, NULL);
1196 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
1198 return (
PIX *)ERROR_PTR(
"invalid maxwidth", __func__, NULL);
1199 spacing = L_MAX(spacing, 0);
1200 border = L_MAX(border, 0);
1201 if (scalefactor <= 0.0) scalefactor = 1.0;
1202 if (fontsize < 4 || fontsize > 20 || (fontsize & 1)) {
1203 l_int32 fsize = L_MAX(L_MIN(fontsize, 20), 4);
1204 if (fsize & 1) fsize--;
1205 L_WARNING(
"changed fontsize from %d to %d\n", __func__,
1212 maxwidth = L_MAX(maxwidth, scalefactor * (maxw + 2 * spacing + 2 * border));
1216 for (i = 0; i < n; i++) {
1220 spacing / 2, 0xffffff00);
1222 if (textstr && strlen(textstr) > 0) {
1223 snprintf(buf,
sizeof(buf),
"%s", textstr);
1237 0, spacing, border);
1282 l_int32 i, n, x, y, w, h, yval, index;
1287 PIX *pix1, *pix2, *pix3, *pix4, *pix5, *pixd;
1291 return (
PIX *)ERROR_PTR(
"pixa not defined", __func__, NULL);
1293 return (
PIX *)ERROR_PTR(
"na not defined", __func__, NULL);
1295 return (
PIX *)ERROR_PTR(
"no pixa components", __func__, NULL);
1297 return (
PIX *)ERROR_PTR(
"pixa and na counts differ", __func__, NULL);
1299 return (
PIX *)ERROR_PTR(
"invalid width", __func__, NULL);
1301 L_WARNING(
"very small width: %d\n", __func__, width);
1302 spacing = L_MAX(spacing, 0);
1303 border = L_MAX(border, 0);
1304 if (fontsize < 4 || fontsize > 20 || (fontsize & 1)) {
1305 l_int32 fsize = L_MAX(L_MIN(fontsize, 20), 4);
1306 if (fsize & 1) fsize--;
1307 L_WARNING(
"changed fontsize from %d to %d\n", __func__,
1317 for (i = 0; i < n; i++) {
1325 if (textstr && strlen(textstr) > 0) {
1326 snprintf(buf,
sizeof(buf),
"%s", textstr);
1332 x = spacing + border + index * (2 * border + width + spacing);
1335 yval += h + spacing;
1397 l_float32 scalefactor,
1406 l_int32 i, n, w, maxd, maxd1, maxd2, text;
1408 PIX *pixs1, *pixs2, *pix1, *pix2, *pix3, *pix4;
1409 PIX *pix5, *pix6, *pix7, *pix8, *pix9;
1410 PIXA *pixa1, *pixa2;
1414 return (
PIX *)ERROR_PTR(
"pixas1 not defined", __func__, NULL);
1416 return (
PIX *)ERROR_PTR(
"pixas2 not defined", __func__, NULL);
1417 spacing1 = L_MAX(spacing1, 0);
1418 spacing2 = L_MAX(spacing2, 0);
1419 border1 = L_MAX(border1, 0);
1420 border2 = L_MAX(border2, 0);
1421 if (scalefactor <= 0.0) scalefactor = 1.0;
1423 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
1425 return (
PIX *)ERROR_PTR(
"pixa sizes differ", __func__, NULL);
1426 text = (fontsize <= 0) ? 0 : 1;
1427 if (text && (fontsize < 4 || fontsize > 20 || (fontsize & 1))) {
1428 l_int32 fsize = L_MAX(L_MIN(fontsize, 20), 4);
1429 if (fsize & 1) fsize--;
1430 L_WARNING(
"changed fontsize from %d to %d\n", __func__,
1441 maxd = L_MAX(maxd1, maxd2);
1447 for (i = 0; i < n; i++) {
1450 if (!pixs1 || !pixs2)
continue;
1454 }
else if (maxd == 8) {
1463 if (scalefactor != 1.0) {
1464 pix3 =
pixScale(pix1, scalefactor, scalefactor);
1465 pix4 =
pixScale(pix2, scalefactor, scalefactor);
1517 border2, fontsize, 0xff000000);
1547 l_int32 i, j, n, nbox, na, d, wmax, hmax, x, y, xb, yb, wb, hb;
1554 return (
PIX *)ERROR_PTR(
"paa not defined", __func__, NULL);
1558 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
1564 if (w == 0 || h == 0) {
1569 for (i = 0; i < n; i++) {
1573 wmax = L_MAX(wmax, w);
1574 hmax = L_MAX(hmax, h);
1586 d = pixGetDepth(pix1);
1590 if ((pixd =
pixCreate(w, h, d)) == NULL) {
1592 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
1596 for (i = 0; i < n; i++) {
1601 for (j = 0; j < na; j++) {
1646 l_float32 scalefactor,
1653 PIXA *pixa1, *pixa2;
1656 return (
PIX *)ERROR_PTR(
"paa not defined", __func__, NULL);
1657 if (scalefactor <= 0.0) scalefactor = 1.0;
1658 if (hspacing < 0) hspacing = 0;
1659 if (vspacing < 0) vspacing = 0;
1660 if (border < 0) border = 0;
1663 return (
PIX *)ERROR_PTR(
"no components", __func__, NULL);
1667 for (i = 0; i < n; i++) {
1675 vs = vspacing - 2 * hspacing;
1718 return (
PIXA *)ERROR_PTR(
"paa not defined", __func__, NULL);
1719 if (outdepth != 1 && outdepth != 8 && outdepth != 32)
1720 return (
PIXA *)ERROR_PTR(
"outdepth not in {1, 8, 32}", __func__, NULL);
1722 return (
PIXA *)ERROR_PTR(
"ncols must be > 0", __func__, NULL);
1723 if (border < 0 || border > tilewidth / 5)
1727 return (
PIXA *)ERROR_PTR(
"no components", __func__, NULL);
1730 for (i = 0; i < n; i++) {
1733 background, spacing, border);
1762 return (
PIXA *)ERROR_PTR(
"pixas not defined", __func__, NULL);
1766 for (i = 0; i < n; i++) {
1801 return (
PIXA *)ERROR_PTR(
"pixas not defined", __func__, NULL);
1805 for (i = 0; i < n; i++) {
1840 return (
PIXA *)ERROR_PTR(
"pixas not defined", __func__, NULL);
1844 for (i = 0; i < n; i++) {
1879 return (
PIXA *)ERROR_PTR(
"pixas not defined", __func__, NULL);
1883 for (i = 0; i < n; i++) {
1929 l_int32 i, n, nselect, index;
1935 return (
PIXA *)ERROR_PTR(
"pixas not defined", __func__, NULL);
1937 first = L_MAX(0, first);
1938 last = (last < 0) ? n - 1 : L_MIN(n - 1, last);
1940 return (
PIXA *)ERROR_PTR(
"last < first!", __func__, NULL);
1942 return (
PIXA *)ERROR_PTR(
"nmax < 1!", __func__, NULL);
1947 for (i = 0; i < nselect; i++) {
1992 l_float32 scalefactor,
1997 const char *fileout)
2002 PIXA *pixa1, *pixa2;
2005 return ERROR_INT(
"pixas not defined", __func__, 1);
2007 L_WARNING(
"invalid compression type; using default\n", __func__);
2011 return ERROR_INT(
"fileout not defined", __func__, 1);
2015 first = L_MAX(0, first);
2016 last = (last < 0) ? n - 1 : L_MIN(n - 1, last);
2018 L_ERROR(
"first = %d > last = %d\n", __func__, first, last);
2024 bmf = (fontsize <= 0) ? NULL :
bmfCreate(NULL, fontsize);
2073 PIXA *pixad, *pixa1;
2076 return (
PIXA *)ERROR_PTR(
"pixas not defined", __func__, NULL);
2078 return (
PIXA *)ERROR_PTR(
"nsamp too large; typ. 100", __func__, NULL);
2082 if (nsamp <= 0) nsamp = 100;
2089 for (i = 0; i < 10; i++) {
2093 L_WARNING(
"requested %d; only %d tiles\n", __func__, nsamp, ntiles);
2095 snprintf(buf,
sizeof(buf),
"%d", i);
2150 l_int32 i, j, k, ws, hs, d, nx, ny, n, n_isvalid, ntiles, nmax;
2156 return (
PIXA *)ERROR_PTR(
"pixs not defined", __func__, NULL);
2157 if (!boxa && (w <= 0 || h <= 0))
2158 return (
PIXA *)ERROR_PTR(
"w and h must be > 0", __func__, NULL);
2167 if (nx < 1 || ny < 1)
2168 return (
PIXA *)ERROR_PTR(
"invalid dimensions", __func__, NULL);
2169 if (nx * w != ws || ny * h != hs)
2170 L_WARNING(
"some tiles will be clipped\n", __func__);
2176 n_isvalid = (n <= nx * ny && n > nx * (ny - 1)) ? TRUE : FALSE;
2177 ntiles = (n_isvalid) ? n : nx * ny;
2178 nmax = ntiles - start;
2179 num = (num == 0) ? nmax : L_MIN(num, nmax);
2183 return (
PIXA *)ERROR_PTR(
"pixa1 not made", __func__, NULL);
2185 cmap = pixGetColormap(pixs);
2186 for (i = 0, k = 0; i < ny; i++) {
2187 for (j = 0; j < nx; j++, k++) {
2188 if (k < start)
continue;
2189 if (k >= start + num)
break;
2223 return ERROR_INT(
"&n not defined", __func__, 1);
2226 return ERROR_INT(
"pix not defined", __func__, 1);
2229 if (text && strlen(text) > 4) {
2230 if (sscanf(text,
"n = %d", &n) == 1)
2267 l_float32 scalefactor,
2271 l_int32 n, i, j, ntile, nout, index;
2273 PIXA *pixa1, *pixa2, *pixad;
2276 return (
PIXA *)ERROR_PTR(
"pixas not defined", __func__, NULL);
2277 if (nx < 1 || ny < 1 || nx > 50 || ny > 50)
2278 return (
PIXA *)ERROR_PTR(
"invalid tiling factor(s)", __func__, NULL);
2280 return (
PIXA *)ERROR_PTR(
"pixas is empty", __func__, NULL);
2283 if (maxw == 0 && maxh == 0) {
2286 maxw = (maxw == 0) ? 1000000 : maxw;
2287 maxh = (maxh == 0) ? 1000000 : maxh;
2294 nout = L_MAX(1, (n + ntile - 1) / ntile);
2296 for (i = 0, index = 0; i < nout; i++) {
2298 for (j = 0; j < ntile && index < n; j++, index++) {
2348 l_int32 i, j, index, n, nt;
2353 return ERROR_INT(
"pixas not defined", __func__, 1);
2355 return ERROR_INT(
"nsplit must be >= 2", __func__, 1);
2357 return ERROR_INT(
"pixas is empty", __func__, 1);
2358 if (!write_pixa && !write_pix && !write_pdf)
2359 return ERROR_INT(
"no output is requested", __func__, 1);
2362 n = (nt + nsplit - 1) / nsplit;
2363 lept_stderr(
"nt = %d, n = %d, nsplit = %d\n", nt, n, nsplit);
2364 for (i = 0, index = 0; i < nsplit; i++) {
2366 for (j = 0; j < n && index < nt; j++, index++) {
2368 pix2 =
pixScale(pix1, scale, scale);
2373 snprintf(buf,
sizeof(buf),
"/tmp/lept/split/split%d.pa", i + 1);
2377 snprintf(buf,
sizeof(buf),
"/tmp/lept/split/split%d.tif", i + 1);
2379 pixWriteDebug(buf, pix1, IFF_TIFF_G4);
2383 snprintf(buf,
sizeof(buf),
"/tmp/lept/split/split%d.pdf", i + 1);
2441 return ERROR_INT(
"dir not defined", __func__, 1);
2442 if (nx < 1 || ny < 1 || nx > 50 || ny > 50)
2443 return ERROR_INT(
"invalid tiling N-factor", __func__, 1);
2444 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2445 return ERROR_INT(
"invalid fontsize", __func__, 1);
2447 return ERROR_INT(
"outdir not defined", __func__, 1);
2452 return ERROR_INT(
"pixa not made", __func__, 1);
2457 format = (d == 1) ? IFF_TIFF_G4 : IFF_JFIF_JPEG;
2460 pixaWriteFiles(rootpath, pixa, format);
2497 PIXA *pixa1, *pixa2;
2501 return (
PIXA *)ERROR_PTR(
"dir not defined", __func__, NULL);
2502 if (nx < 1 || ny < 1 || nx > 50 || ny > 50)
2503 return (
PIXA *)ERROR_PTR(
"invalid tiling N-factor", __func__, NULL);
2505 return (
PIXA *)ERROR_PTR(
"tw must be >= 20", __func__, NULL);
2506 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2507 return (
PIXA *)ERROR_PTR(
"invalid fontsize", __func__, NULL);
2513 for (i = 0; i < n; i++) {
2559 l_int32 i, j, k, nt, n2, nout, d;
2562 PIX *pix1, *pix2, *pix3, *pix4;
2563 PIXA *pixa1, *pixad;
2566 return (
PIXA *)ERROR_PTR(
"pixas not defined", __func__, NULL);
2567 if (nx < 1 || ny < 1 || nx > 50 || ny > 50)
2568 return (
PIXA *)ERROR_PTR(
"invalid tiling N-factor", __func__, NULL);
2570 return (
PIXA *)ERROR_PTR(
"tw must be >= 20", __func__, NULL);
2571 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2572 return (
PIXA *)ERROR_PTR(
"invalid fontsize", __func__, NULL);
2576 L_WARNING(
"pixa size %d not equal to sarray size %d\n", __func__,
2581 nout = (nt + n2 - 1) / n2;
2583 bmf = (fontsize == 0) ? NULL :
bmfCreate(NULL, fontsize);
2584 for (i = 0, j = 0; i < nout; i++) {
2586 for (k = 0; k < n2 && j < nt; j++, k++) {
2669 const char *fileout)
2671 l_int32 n1, n2, npairs;
2672 PIXA *pixa3, *pixa4, *pixa5;
2675 if (!pixa1 || !pixa2)
2676 return ERROR_INT(
"pixa1 and pixa2 not both defined", __func__, 1);
2677 if (nx < 1 || ny < 1 || nx > 20 || ny > 20)
2678 return ERROR_INT(
"invalid tiling factors", __func__, 1);
2680 return ERROR_INT(
"invalid tw; tw must be >= 20", __func__, 1);
2681 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2682 return ERROR_INT(
"invalid fontsize", __func__, 1);
2684 return ERROR_INT(
"fileout not defined", __func__, 1);
2687 if (n1 == 0 || n2 == 0)
2688 return ERROR_INT(
"at least one pixa is empty", __func__, 1);
2690 L_WARNING(
"sizes (%d, %d) differ; using the minimum in interleave\n",
2695 return ERROR_INT(
"pixa3 not made", __func__, 1);
2705 2 * tw + 4 * border + spacing,
2706 spacing, border, fontsize);
void bmfDestroy(L_BMF **pbmf)
bmfDestroy()
L_BMF * bmfCreate(const char *dir, l_int32 fontsize)
bmfCreate()
l_ok boxaWriteMem(l_uint8 **pdata, size_t *psize, BOXA *boxa)
boxaWriteMem()
l_ok boxaGetBoxGeometry(BOXA *boxa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxaGetBoxGeometry()
l_ok boxaAddBox(BOXA *boxa, BOX *box, l_int32 copyflag)
boxaAddBox()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
l_int32 boxaGetCount(const BOXA *boxa)
boxaGetCount()
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
BOXA * boxaCreate(l_int32 n)
boxaCreate()
l_ok boxaGetExtent(BOXA *boxa, l_int32 *pw, l_int32 *ph, BOX **pbox)
boxaGetExtent()
PIXCMAP * pixcmapCreateRandom(l_int32 depth, l_int32 hasblack, l_int32 haswhite)
pixcmapCreateRandom()
PIXCMAP * pixcmapCopy(const PIXCMAP *cmaps)
pixcmapCopy()
SARRAY * numaConvertToSarray(NUMA *na, l_int32 size1, l_int32 size2, l_int32 addzeros, l_int32 type)
numaConvertToSarray()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
NUMA * numaCreate(l_int32 n)
numaCreate()
void numaDestroy(NUMA **pna)
numaDestroy()
l_ok numaSetValue(NUMA *na, l_int32 index, l_float32 val)
numaSetValue()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
NUMA * numaMakeConstant(l_float32 val, l_int32 size)
numaMakeConstant()
l_ok numaGetMax(NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
numaGetMax()
NUMA * numaMakeSequence(l_float32 startval, l_float32 increment, l_int32 size)
numaMakeSequence()
NUMA * genConstrainedNumaInRange(l_int32 first, l_int32 last, l_int32 nmax, l_int32 use_pairs)
genConstrainedNumaInRange()
l_ok pixaConvertToPdf(PIXA *pixa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
pixaConvertToPdf()
l_ok pixSetColormap(PIX *pix, PIXCMAP *colormap)
pixSetColormap()
l_ok pixSetResolution(PIX *pix, l_int32 xres, l_int32 yres)
pixSetResolution()
void pixDestroy(PIX **ppix)
pixDestroy()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
char * pixGetText(PIX *pix)
pixGetText()
l_ok pixSetText(PIX *pix, const char *textstring)
pixSetText()
l_ok pixCopyColormap(PIX *pixd, const PIX *pixs)
pixCopyColormap()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
PIX * pixClone(PIX *pixs)
pixClone()
PIX * pixAddBorder(PIX *pixs, l_int32 npix, l_uint32 val)
pixAddBorder()
PIX * pixAddBorderGeneral(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val)
pixAddBorderGeneral()
l_ok pixSetAll(PIX *pix)
pixSetAll()
PIX * pixAddBlackOrWhiteBorder(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_int32 op)
pixAddBlackOrWhiteBorder()
l_ok pixSetBlackOrWhite(PIX *pixs, l_int32 op)
pixSetBlackOrWhite()
l_ok pixSetAllArbitrary(PIX *pix, l_uint32 val)
pixSetAllArbitrary()
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
l_ok pixaVerifyDepth(PIXA *pixa, l_int32 *psame, l_int32 *pmaxd)
pixaVerifyDepth()
PIXA * pixaInterleave(PIXA *pixa1, PIXA *pixa2, l_int32 copyflag)
pixaInterleave()
l_ok pixaSetText(PIXA *pixa, const char *text, SARRAY *sa)
pixaSetText()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_ok pixaGetPixDimensions(PIXA *pixa, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixaGetPixDimensions()
PIXA * pixaCopy(PIXA *pixa, l_int32 copyflag)
pixaCopy()
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
l_ok pixaAddBox(PIXA *pixa, BOX *box, l_int32 copyflag)
pixaAddBox()
BOXA * pixaGetBoxa(PIXA *pixa, l_int32 accesstype)
pixaGetBoxa()
BOXA * pixaaGetBoxa(PIXAA *paa, l_int32 accesstype)
pixaaGetBoxa()
l_ok pixaGetBoxGeometry(PIXA *pixa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
pixaGetBoxGeometry()
l_ok pixaWriteDebug(const char *fname, PIXA *pixa)
pixaWriteDebug()
PIXA * pixaCreateFromBoxa(PIX *pixs, BOXA *boxa, l_int32 start, l_int32 num, l_int32 *pcropwarn)
pixaCreateFromBoxa()
l_int32 pixaaGetCount(PIXAA *paa, NUMA **pna)
pixaaGetCount()
l_ok pixaJoin(PIXA *pixad, PIXA *pixas, l_int32 istart, l_int32 iend)
pixaJoin()
PIXA * pixaaGetPixa(PIXAA *paa, l_int32 index, l_int32 accesstype)
pixaaGetPixa()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
l_ok pixaSetBoxa(PIXA *pixa, BOXA *boxa, l_int32 accesstype)
pixaSetBoxa()
PIXA * pixaSelectRange(PIXA *pixas, l_int32 first, l_int32 last, l_int32 copyflag)
pixaSelectRange()
l_ok pixaGetRenderingDepth(PIXA *pixa, l_int32 *pdepth)
pixaGetRenderingDepth()
l_ok pixaSizeRange(PIXA *pixa, l_int32 *pminw, l_int32 *pminh, l_int32 *pmaxw, l_int32 *pmaxh)
pixaSizeRange()
l_ok pixaAnyColormaps(PIXA *pixa, l_int32 *phascmap)
pixaAnyColormaps()
l_ok pixaGetDepthInfo(PIXA *pixa, l_int32 *pmaxdepth, l_int32 *psame)
pixaGetDepthInfo()
PIXA * pixaSelectBySize(PIXA *pixas, l_int32 width, l_int32 height, l_int32 type, l_int32 relation, l_int32 *pchanged)
pixaSelectBySize()
PIXA * pixaConvertToSameDepth(PIXA *pixas)
pixaConvertToSameDepth()
PIX * pixaDisplayTiled(PIXA *pixa, l_int32 maxwidth, l_int32 background, l_int32 spacing)
pixaDisplayTiled()
PIX * pixaDisplay(PIXA *pixa, l_int32 w, l_int32 h)
pixaDisplay()
PIXA * convertToNUpPixa(const char *dir, const char *substr, l_int32 nx, l_int32 ny, l_int32 tw, l_int32 spacing, l_int32 border, l_int32 fontsize)
convertToNUpPixa()
PIXA * pixaConvertTo1(PIXA *pixas, l_int32 thresh)
pixaConvertTo1()
PIX * pixaDisplayUnsplit(PIXA *pixa, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor)
pixaDisplayUnsplit()
PIX * pixaDisplayLinearly(PIXA *pixas, l_int32 direction, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border, BOXA **pboxa)
pixaDisplayLinearly()
l_ok pixGetTileCount(PIX *pix, l_int32 *pn)
pixGetTileCount()
PIXA * pixaMakeFromTiledPixa(PIXA *pixas, l_int32 w, l_int32 h, l_int32 nsamp)
pixaMakeFromTiledPixa()
PIXA * pixaConstrainedSelect(PIXA *pixas, l_int32 first, l_int32 last, l_int32 nmax, l_int32 use_pairs, l_int32 copyflag)
pixaConstrainedSelect()
PIX * pixaDisplayRandomCmap(PIXA *pixa, l_int32 w, l_int32 h)
pixaDisplayRandomCmap()
PIXA * pixaConvertTo8Colormap(PIXA *pixas, l_int32 dither)
pixaConvertTo8Colormap()
PIX * pixaDisplayOnLattice(PIXA *pixa, l_int32 cellw, l_int32 cellh, l_int32 *pncols, BOXA **pboxa)
pixaDisplayOnLattice()
PIX * pixaDisplayTiledInRows(PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledInRows()
PIXA * pixaConvertTo32(PIXA *pixas)
pixaConvertTo32()
l_ok pixaSplitIntoFiles(PIXA *pixas, l_int32 nsplit, l_float32 scale, l_int32 outwidth, l_int32 write_pixa, l_int32 write_pix, l_int32 write_pdf)
pixaSplitIntoFiles()
PIX * pixaDisplayTiledWithText(PIXA *pixa, l_int32 maxwidth, l_float32 scalefactor, l_int32 spacing, l_int32 border, l_int32 fontsize, l_uint32 textcolor)
pixaDisplayTiledWithText()
l_ok pixaCompareInPdf(PIXA *pixa1, PIXA *pixa2, l_int32 nx, l_int32 ny, l_int32 tw, l_int32 spacing, l_int32 border, l_int32 fontsize, const char *fileout)
pixaCompareInPdf()
l_ok convertToNUpFiles(const char *dir, const char *substr, l_int32 nx, l_int32 ny, l_int32 tw, l_int32 spacing, l_int32 border, l_int32 fontsize, const char *outdir)
convertToNUpFiles()
PIXA * pixaDisplayMultiTiled(PIXA *pixas, l_int32 nx, l_int32 ny, l_int32 maxw, l_int32 maxh, l_float32 scalefactor, l_int32 spacing, l_int32 border)
pixaDisplayMultiTiled()
PIXA * pixaConvertToNUpPixa(PIXA *pixas, SARRAY *sa, l_int32 nx, l_int32 ny, l_int32 tw, l_int32 spacing, l_int32 border, l_int32 fontsize)
pixaConvertToNUpPixa()
PIX * pixaaDisplay(PIXAA *paa, l_int32 w, l_int32 h)
pixaaDisplay()
PIX * pixaDisplayPairTiledInColumns(PIXA *pixas1, PIXA *pixas2, l_int32 nx, l_float32 scalefactor, l_int32 spacing1, l_int32 spacing2, l_int32 border1, l_int32 border2, l_int32 fontsize, l_int32 startindex, SARRAY *sa)
pixaDisplayPairTiledInColumns()
PIXA * pixaaDisplayTiledAndScaled(PIXAA *paa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)
pixaaDisplayTiledAndScaled()
PIX * pixaDisplayTiledAndScaled(PIXA *pixa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledAndScaled()
PIXA * pixaConvertTo8(PIXA *pixas, l_int32 cmapflag)
pixaConvertTo8()
PIXA * pixaMakeFromTiledPix(PIX *pixs, l_int32 w, l_int32 h, l_int32 start, l_int32 num, BOXA *boxa)
pixaMakeFromTiledPix()
PIX * pixaaDisplayByPixa(PIXAA *paa, l_int32 maxnx, l_float32 scalefactor, l_int32 hspacing, l_int32 vspacing, l_int32 border)
pixaaDisplayByPixa()
PIX * pixaDisplayTiledInColumns(PIXA *pixas, l_int32 nx, l_float32 scalefactor, l_int32 spacing, l_int32 border)
pixaDisplayTiledInColumns()
PIX * pixaDisplayTiledByIndex(PIXA *pixa, NUMA *na, l_int32 width, l_int32 spacing, l_int32 border, l_int32 fontsize, l_uint32 textcolor)
pixaDisplayTiledByIndex()
l_ok pixaSelectToPdf(PIXA *pixas, l_int32 first, l_int32 last, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, l_uint32 color, l_int32 fontsize, const char *fileout)
pixaSelectToPdf()
PIX * pixConvertTo8Colormap(PIX *pixs, l_int32 dither)
pixConvertTo8Colormap()
PIX * pixConvertTo1(PIX *pixs, l_int32 threshold)
pixConvertTo1()
PIX * pixConvert1To8(PIX *pixd, PIX *pixs, l_uint8 val0, l_uint8 val1)
pixConvert1To8()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
PIXA * pixaReadFilesSA(SARRAY *sa)
pixaReadFilesSA()
l_ok pixRasterop(PIX *pixd, l_int32 dx, l_int32 dy, l_int32 dw, l_int32 dh, l_int32 op, PIX *pixs, l_int32 sx, l_int32 sy)
pixRasterop()
SARRAY * sarrayCreate(l_int32 n)
sarrayCreate()
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
l_ok sarrayAddString(SARRAY *sa, const char *string, l_int32 copyflag)
sarrayAddString()
SARRAY * getSortedPathnamesInDirectory(const char *dirname, const char *substr, l_int32 first, l_int32 nfiles)
getSortedPathnamesInDirectory()
SARRAY * sarrayGenerateIntegers(l_int32 n)
sarrayGenerateIntegers()
PIX * pixScale(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScale()
PIX * pixScaleToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleToSize()
PIX * pixScaleToGray(PIX *pixs, l_float32 scalefactor)
pixScaleToGray()
PIX * pixAddTextlines(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location)
pixAddTextlines()
PIX * pixAddSingleTextblock(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location, l_int32 *poverflow)
pixAddSingleTextblock()
PIXA * pixaAddTextNumber(PIXA *pixas, L_BMF *bmf, NUMA *na, l_uint32 val, l_int32 location)
pixaAddTextNumber()
void lept_stderr(const char *fmt,...)
lept_stderr()
l_int32 lept_roundftoi(l_float32 fval)
lept_roundftoi()
l_int32 lept_rmdir(const char *subdir)
lept_rmdir()
l_ok modifyTrailingSlash(char *path, size_t nbytes, l_int32 flag)
modifyTrailingSlash()
l_ok splitPathAtDirectory(const char *pathname, char **pdir, char **ptail)
splitPathAtDirectory()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
l_ok makeTempDirname(char *result, size_t nbytes, const char *subdir)
makeTempDirname()