152 #include "allheaders.h" 183 l_int32 i, n, d, xb, yb, wb, hb, res;
187 PROCNAME(
"pixaDisplay");
190 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
193 if (n == 0 && w == 0 && h == 0)
194 return (
PIX *)ERROR_PTR(
"no components; no size", procName, NULL);
196 L_WARNING(
"no components; returning empty 1 bpp pix\n", procName);
202 if (w == 0 || h == 0) {
206 if (w == 0 || h == 0)
207 return (
PIX *)ERROR_PTR(
"no associated boxa", procName, NULL);
212 d = pixGetDepth(pix1);
213 res = pixGetXRes(pix1);
217 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
221 for (i = 0; i < n; i++) {
223 L_WARNING(
"no box found!\n", procName);
264 l_int32 i, n, xb, yb, wb, hb, hascmap, maxdepth, same, res;
266 PIX *pix1, *pix2, *pixd;
269 PROCNAME(
"pixaDisplayOnColor");
272 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
274 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
278 if (w == 0 || h == 0) {
288 if (hascmap || !same) {
291 for (i = 0; i < n; i++) {
302 if ((pixd =
pixCreate(w, h, maxdepth)) == NULL) {
304 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
306 if ((maxdepth == 1 && bgcolor > 0) ||
307 (maxdepth == 2 && bgcolor >= 0x3) ||
308 (maxdepth == 4 && bgcolor >= 0xf) ||
309 (maxdepth == 8 && bgcolor >= 0xff) ||
310 (maxdepth == 16 && bgcolor >= 0xffff) ||
311 (maxdepth == 32 && bgcolor >= 0xffffff00)) {
313 }
else if (bgcolor > 0) {
318 for (i = 0; i < n; i++) {
320 L_WARNING(
"no box found!\n", procName);
324 if (i == 0) res = pixGetXRes(pix1);
358 l_int32 i, n, same, maxd, index, xb, yb, wb, hb, res;
360 PIX *pixs, *pix1, *pixd;
363 PROCNAME(
"pixaDisplayRandomCmap");
366 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
369 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
372 return (
PIX *)ERROR_PTR(
"not all components are 1 bpp", procName, NULL);
376 if (w == 0 || h == 0) {
384 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
389 for (i = 0; i < n; i++) {
390 index = 1 + (i % 254);
393 if (i == 0) res = pixGetXRes(pixs);
430 l_float32 scalefactor,
436 l_int32 i, n, x, y, w, h, size, depth, bordval;
438 PIX *pix1, *pix2, *pix3, *pixd;
441 PROCNAME(
"pixaDisplayLinearly");
443 if (pboxa) *pboxa = NULL;
445 return (
PIX *)ERROR_PTR(
"pixas not defined", procName, NULL);
446 if (direction != L_HORIZ && direction != L_VERT)
447 return (
PIX *)ERROR_PTR(
"invalid direction", procName, NULL);
456 bordval = (depth == 1) ? 1 : 0;
457 size = (n - 1) * spacing;
459 for (i = 0; i < n; i++) {
461 L_WARNING(
"missing pix at index %d\n", procName, i);
465 if (scalefactor != 1.0)
466 pix2 =
pixScale(pix1, scalefactor, scalefactor);
476 if (direction == L_HORIZ) {
528 l_int32 n, nw, nh, w, h, d, wt, ht, res;
529 l_int32 index, i, j, hascmap;
532 PIX *pix1, *pix2, *pixd;
535 PROCNAME(
"pixaDisplayOnLattice");
537 if (pncols) *pncols = 0;
538 if (pboxa) *pboxa = NULL;
540 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
544 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
546 res = pixGetXRes(pix1);
551 for (i = 0; i < n; i++) {
563 nw = (l_int32)sqrt((l_float64)n);
564 nh = (n + nw - 1) / nw;
570 if ((pixd =
pixCreate(w, h, d)) == NULL) {
572 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
579 for (i = 0; i < nh; i++) {
580 for (j = 0; j < nw && index < n; j++, index++) {
583 if (wt > cellw || ht > cellh) {
584 L_INFO(
"pix(%d) omitted; size %dx%x\n", procName, index,
593 box =
boxCreate(j * cellw, i * cellh, wt, ht);
599 if (pncols) *pncols = nw;
637 l_uint32 bordercolor)
639 l_int32 w, h, d, wt, ht;
640 l_int32 i, j, k, x, y, n;
643 PROCNAME(
"pixaDisplayUnsplit");
646 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
647 if (nx <= 0 || ny <= 0)
648 return (
PIX *)ERROR_PTR(
"nx and ny must be > 0", procName, NULL);
650 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
652 return (
PIX *)ERROR_PTR(
"n != nx * ny", procName, NULL);
653 borderwidth = L_MAX(0, borderwidth);
656 w = nx * (wt + 2 * borderwidth);
657 h = ny * (ht + 2 * borderwidth);
660 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
668 for (i = 0, k = 0; i < ny; i++) {
670 for (j = 0; j < nx; j++, k++) {
674 x += wt + 2 * borderwidth;
676 y += ht + 2 * borderwidth;
713 l_int32 wmax, hmax, wd, hd, d, hascmap, res, same;
714 l_int32 i, j, n, ni, ncols, nrows;
715 l_int32 ystart, xstart, wt, ht;
716 PIX *pix1, *pix2, *pixd;
719 PROCNAME(
"pixaDisplayTiled");
722 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
726 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
730 for (i = 0; i < n; i++) {
744 return (
PIX *)ERROR_PTR(
"depths not equal", procName, NULL);
749 spacing = L_MAX(spacing, 0);
750 ncols = (l_int32)((l_float32)(maxwidth - spacing) /
751 (l_float32)(wmax + spacing));
752 nrows = (n + ncols - 1) / ncols;
753 wd = wmax * ncols + spacing * (ncols + 1);
754 hd = hmax * nrows + spacing * (nrows + 1);
755 if ((pixd =
pixCreate(wd, hd, d)) == NULL) {
757 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
761 if ((background == 1 && d == 1) || (background == 0 && d != 1))
765 for (i = 0, ni = 0; i < nrows; i++) {
766 ystart = spacing + i * (hmax + spacing);
767 for (j = 0; j < ncols && ni < n; j++, ni++) {
768 xstart = spacing + j * (wmax + spacing);
770 if (ni == 0) res = pixGetXRes(pix1);
824 l_float32 scalefactor,
831 l_int32 bordval, wtry, wt, ht;
835 l_int32 i, j, index, n, x, y, nrows, ninrow, res;
841 PIX *pix, *pixn, *pix1, *pixd;
844 PROCNAME(
"pixaDisplayTiledInRows");
847 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
848 if (outdepth != 1 && outdepth != 8 && outdepth != 32)
849 return (
PIX *)ERROR_PTR(
"outdepth not in {1, 8, 32}", procName, NULL);
852 if (scalefactor <= 0.0) scalefactor = 1.0;
855 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
859 bordval = (outdepth == 1) ? 1 : 0;
860 for (i = 0; i < n; i++) {
866 else if (outdepth == 8)
872 if (scalefactor != 1.0)
873 pix1 =
pixScale(pixn, scalefactor, scalefactor);
887 L_WARNING(
"only got %d components\n", procName, n);
890 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
900 for (i = 0, irow = 0; i < n; i++, irow++) {
902 wtry = w + wt + spacing;
903 if (wtry > maxwidth) {
906 wmaxrow = L_MAX(wmaxrow, w);
909 w = wt + 2 * spacing;
913 maxh = L_MAX(maxh, ht);
920 wmaxrow = L_MAX(wmaxrow, w);
923 if ((pixd =
pixCreate(wmaxrow, h, outdepth)) == NULL) {
927 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
931 if ((background == 1 && outdepth == 1) ||
932 (background == 0 && outdepth != 1))
940 for (i = 0, index = 0; i < nrows; i++) {
944 for (j = 0; j < ninrow; j++, index++) {
947 res = pixGetXRes(pix);
952 wt - 2 * border, ht - 2 *border),
L_INSERT);
1007 l_float32 scalefactor,
1011 l_int32 i, j, index, n, x, y, nrows, wb, hb, w, h, maxd, maxh, bordval, res;
1016 PIX *pix1, *pix2, *pix3, *pixd;
1017 PIXA *pixa1, *pixa2;
1019 PROCNAME(
"pixaDisplayTiledInColumns");
1022 return (
PIX *)ERROR_PTR(
"pixas not defined", procName, NULL);
1025 if (scalefactor <= 0.0) scalefactor = 1.0;
1028 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
1036 bordval = (maxd == 1) ? 1 : 0;
1037 for (i = 0; i < n; i++) {
1040 if (scalefactor != 1.0)
1041 pix2 =
pixScale(pix1, scalefactor, scalefactor);
1048 if (i == 0) res = pixGetXRes(pix3);
1056 L_WARNING(
"only got %d components\n", procName, n);
1059 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
1065 nrows = (n + nx - 1) / nx;
1067 for (i = 0, index = 0; i < nrows; i++) {
1070 for (j = 0; j < nx && index < n; j++) {
1074 maxh = L_MAX(maxh, hb + spacing);
1084 pixd =
pixaDisplay(pixa2, w + spacing, h + spacing);
1130 l_int32 x, y, w, h, wd, hd, d, res;
1131 l_int32 i, n, nrows, maxht, ninrow, irow, bordval;
1133 l_float32 scalefact;
1134 PIX *pix, *pixn, *pix1, *pixb, *pixd;
1137 PROCNAME(
"pixaDisplayTiledAndScaled");
1140 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
1141 if (outdepth != 1 && outdepth != 8 && outdepth != 32)
1142 return (
PIX *)ERROR_PTR(
"outdepth not in {1, 8, 32}", procName, NULL);
1143 if (border < 0 || border > tilewidth / 5)
1147 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
1151 bordval = (outdepth == 1) ? 1 : 0;
1152 for (i = 0; i < n; i++) {
1157 scalefact = (l_float32)(tilewidth - 2 * border) / (l_float32)w;
1158 if (d == 1 && outdepth > 1 && scalefact < 1.0)
1161 pix1 =
pixScale(pix, scalefact, scalefact);
1165 else if (outdepth == 8)
1182 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
1186 wd = tilewidth * ncols + spacing * (ncols + 1);
1187 nrows = (n + ncols - 1) / ncols;
1188 if ((rowht = (l_int32 *)LEPT_CALLOC(nrows,
sizeof(l_int32))) == NULL) {
1190 return (
PIX *)ERROR_PTR(
"rowht array not made", procName, NULL);
1195 for (i = 0; i < n; i++) {
1199 maxht = L_MAX(h, maxht);
1200 if (ninrow == ncols) {
1201 rowht[irow] = maxht;
1208 rowht[irow] = maxht;
1212 hd = spacing * (nrows + 1);
1213 for (i = 0; i < nrows; i++)
1217 if ((background == 1 && outdepth == 1) ||
1218 (background == 0 && outdepth != 1))
1224 for (i = 0; i < n; i++) {
1227 res = pixGetXRes(pix);
1231 if (i && ((i % ncols) == 0)) {
1233 y += spacing + rowht[irow];
1237 x += tilewidth + spacing;
1277 l_float32 scalefactor,
1287 PIX *pix1, *pix2, *pix3, *pix4, *pixd;
1290 PROCNAME(
"pixaDisplayTiledWithText");
1293 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
1295 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
1297 return (
PIX *)ERROR_PTR(
"invalid maxwidth", procName, NULL);
1300 if (scalefactor <= 0.0) {
1301 L_WARNING(
"invalid scalefactor; setting to 1.0\n", procName);
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", procName,
1314 maxwidth = L_MAX(maxwidth, scalefactor * (maxw + 2 * spacing + 2 * border));
1318 for (i = 0; i < n; i++) {
1322 spacing, 0xffffff00);
1324 if (textstr && strlen(textstr) > 0) {
1325 snprintf(buf,
sizeof(buf),
"%s", textstr);
1384 l_int32 i, n, x, y, w, h, yval, index;
1389 PIX *pix1, *pix2, *pix3, *pix4, *pix5, *pixd;
1392 PROCNAME(
"pixaDisplayTiledByIndex");
1395 return (
PIX *)ERROR_PTR(
"pixa not defined", procName, NULL);
1397 return (
PIX *)ERROR_PTR(
"na not defined", procName, NULL);
1399 return (
PIX *)ERROR_PTR(
"no pixa components", procName, NULL);
1401 return (
PIX *)ERROR_PTR(
"pixa and na counts differ", procName, NULL);
1403 return (
PIX *)ERROR_PTR(
"invalid width", procName, NULL);
1405 L_WARNING(
"very small width: %d\n", procName, width);
1408 if (fontsize < 4 || fontsize > 20 || (fontsize & 1)) {
1409 l_int32 fsize = L_MAX(L_MIN(fontsize, 20), 4);
1410 if (fsize & 1) fsize--;
1411 L_WARNING(
"changed fontsize from %d to %d\n", procName,
1421 for (i = 0; i < n; i++) {
1429 if (textstr && strlen(textstr) > 0) {
1430 snprintf(buf,
sizeof(buf),
"%s", textstr);
1436 x = spacing + border + index * (2 * border + width + spacing);
1439 yval += h + spacing;
1481 l_int32 i, j, n, nbox, na, d, wmax, hmax, x, y, xb, yb, wb, hb;
1487 PROCNAME(
"pixaaDisplay");
1490 return (
PIX *)ERROR_PTR(
"paa not defined", procName, NULL);
1494 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
1500 if (w == 0 || h == 0) {
1505 for (i = 0; i < n; i++) {
1509 wmax = L_MAX(wmax, w);
1510 hmax = L_MAX(hmax, h);
1522 d = pixGetDepth(pix1);
1526 if ((pixd =
pixCreate(w, h, d)) == NULL) {
1528 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1532 for (i = 0; i < n; i++) {
1537 for (j = 0; j < na; j++) {
1576 l_int32 i, j, npixa, npix, same, use_maxw, x, y, w, h, hindex;
1577 l_int32 maxwidth, maxd, width, lmaxh, lmaxw;
1580 PIX *pix, *pix1, *pixd;
1583 PROCNAME(
"pixaaDisplayByPixa");
1586 return (
PIX *)ERROR_PTR(
"paa not defined", procName, NULL);
1589 return (
PIX *)ERROR_PTR(
"no components", procName, NULL);
1591 if (!same && maxd < 8)
1592 return (
PIX *)ERROR_PTR(
"depths differ; max < 8", procName, NULL);
1596 if (maxwidth > maxw) {
1597 L_WARNING(
"maxwidth > maxw; using maxwidth\n", procName);
1608 for (i = 0; i < npixa; i++) {
1617 for (j = 0; j < npix; j++) {
1620 if (x + w >= maxw) {
1622 y += lmaxh + yspace;
1628 lmaxh = L_MAX(h, lmaxh);
1629 lmaxw = L_MAX(lmaxw, x);
1632 y += lmaxh + yspace;
1636 width = (use_maxw) ? maxw : lmaxw;
1638 if ((pixd =
pixCreate(width, y, maxd)) == NULL) {
1640 return (
PIX *)ERROR_PTR(
"pixd not made", procName, NULL);
1647 for (i = 0; i < npixa; i++) {
1655 for (j = 0; j < npix; j++) {
1657 if (pixGetDepth(pix) != maxd) {
1666 if (x + w >= maxw) {
1668 y += harray[hindex++] + yspace;
1675 y += harray[hindex++] + yspace;
1720 PROCNAME(
"pixaaDisplayTiledAndScaled");
1723 return (
PIXA *)ERROR_PTR(
"paa not defined", procName, NULL);
1724 if (outdepth != 1 && outdepth != 8 && outdepth != 32)
1725 return (
PIXA *)ERROR_PTR(
"outdepth not in {1, 8, 32}", procName, NULL);
1726 if (border < 0 || border > tilewidth / 5)
1730 return (
PIXA *)ERROR_PTR(
"no components", procName, NULL);
1733 for (i = 0; i < n; i++) {
1736 background, spacing, border);
1764 PROCNAME(
"pixaConvertTo1");
1767 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
1771 for (i = 0; i < n; i++) {
1805 PROCNAME(
"pixaConvertTo8");
1808 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
1812 for (i = 0; i < n; i++) {
1846 PROCNAME(
"pixaConvertTo8Colormap");
1849 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
1853 for (i = 0; i < n; i++) {
1887 PROCNAME(
"pixaConvertTo32");
1890 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
1894 for (i = 0; i < n; i++) {
1940 l_int32 i, n, nselect, index;
1945 PROCNAME(
"pixaConstrainedSelect");
1948 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
1950 first = L_MAX(0, first);
1951 last = (last < 0) ? n - 1 : L_MIN(n - 1, last);
1953 return (
PIXA *)ERROR_PTR(
"last < first!", procName, NULL);
1955 return (
PIXA *)ERROR_PTR(
"nmax < 1!", procName, NULL);
1960 for (i = 0; i < nselect; i++) {
2005 l_float32 scalefactor,
2010 const char *fileout)
2015 PIXA *pixa1, *pixa2;
2017 PROCNAME(
"pixaSelectToPdf");
2020 return ERROR_INT(
"pixas not defined", procName, 1);
2022 L_WARNING(
"invalid compression type; using default\n", procName);
2026 return ERROR_INT(
"fileout not defined", procName, 1);
2030 first = L_MAX(0, first);
2031 last = (last < 0) ? n - 1 : L_MIN(n - 1, last);
2033 L_ERROR(
"first = %d > last = %d\n", procName, first, last);
2039 bmf = (fontsize <= 0) ? NULL :
bmfCreate(NULL, fontsize);
2086 l_float32 scalefactor,
2090 l_int32 n, i, j, ntile, nout, index;
2092 PIXA *pixa1, *pixa2, *pixad;
2094 PROCNAME(
"pixaDisplayMultiTiled");
2097 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
2098 if (nx < 1 || ny < 1 || nx > 50 || ny > 50)
2099 return (
PIXA *)ERROR_PTR(
"invalid tiling factor(s)", procName, NULL);
2101 return (
PIXA *)ERROR_PTR(
"pixas is empty", procName, NULL);
2104 if (maxw == 0 && maxh == 0) {
2107 maxw = (maxw == 0) ? 1000000 : maxw;
2108 maxh = (maxh == 0) ? 1000000 : maxh;
2115 nout = L_MAX(1, (n + ntile - 1) / ntile);
2117 for (i = 0, index = 0; i < nout; i++) {
2119 for (j = 0; j < ntile && index < n; j++, index++) {
2169 l_int32 i, j, index, n, nt;
2173 PROCNAME(
"pixaSplitIntoFiles");
2176 return ERROR_INT(
"pixas not defined", procName, 1);
2178 return ERROR_INT(
"nsplit must be >= 2", procName, 1);
2180 return ERROR_INT(
"pixas is empty", procName, 1);
2181 if (!write_pixa && !write_pix && !write_pdf)
2182 return ERROR_INT(
"no output is requested", procName, 1);
2185 n = (nt + nsplit - 1) / nsplit;
2186 fprintf(stderr,
"nt = %d, n = %d, nsplit = %d\n", nt, n, nsplit);
2187 for (i = 0, index = 0; i < nsplit; i++) {
2189 for (j = 0; j < n && index < nt; j++, index++) {
2191 pix2 =
pixScale(pix1, scale, scale);
2196 snprintf(buf,
sizeof(buf),
"/tmp/lept/split/split%d.pa", i + 1);
2200 snprintf(buf,
sizeof(buf),
"/tmp/lept/split/split%d.tif", i + 1);
2202 pixWrite(buf, pix1, IFF_TIFF_G4);
2206 snprintf(buf,
sizeof(buf),
"/tmp/lept/split/split%d.pdf", i + 1);
2263 PROCNAME(
"convertToNUpFiles");
2266 return ERROR_INT(
"dir not defined", procName, 1);
2267 if (nx < 1 || ny < 1 || nx > 50 || ny > 50)
2268 return ERROR_INT(
"invalid tiling N-factor", procName, 1);
2269 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2270 return ERROR_INT(
"invalid fontsize", procName, 1);
2272 return ERROR_INT(
"outdir not defined", procName, 1);
2277 return ERROR_INT(
"pixa not made", procName, 1);
2282 format = (d == 1) ? IFF_TIFF_G4 : IFF_JFIF_JPEG;
2285 pixaWriteFiles(rootpath, pixa, format);
2322 PIXA *pixa1, *pixa2;
2325 PROCNAME(
"convertToNUpPixa");
2328 return (
PIXA *)ERROR_PTR(
"dir not defined", procName, NULL);
2329 if (nx < 1 || ny < 1 || nx > 50 || ny > 50)
2330 return (
PIXA *)ERROR_PTR(
"invalid tiling N-factor", procName, NULL);
2332 return (
PIXA *)ERROR_PTR(
"tw must be >= 20", procName, NULL);
2333 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2334 return (
PIXA *)ERROR_PTR(
"invalid fontsize", procName, NULL);
2340 for (i = 0; i < n; i++) {
2386 l_int32 i, j, k, nt, n2, nout, d;
2389 PIX *pix1, *pix2, *pix3, *pix4;
2390 PIXA *pixa1, *pixad;
2392 PROCNAME(
"pixaConvertToNUpPixa");
2395 return (
PIXA *)ERROR_PTR(
"pixas not defined", procName, NULL);
2396 if (nx < 1 || ny < 1 || nx > 50 || ny > 50)
2397 return (
PIXA *)ERROR_PTR(
"invalid tiling N-factor", procName, NULL);
2399 return (
PIXA *)ERROR_PTR(
"tw must be >= 20", procName, NULL);
2400 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2401 return (
PIXA *)ERROR_PTR(
"invalid fontsize", procName, NULL);
2405 L_WARNING(
"pixa size %d not equal to sarray size %d\n", procName,
2410 nout = (nt + n2 - 1) / n2;
2412 bmf = (fontsize == 0) ? NULL :
bmfCreate(NULL, fontsize);
2413 for (i = 0, j = 0; i < nout; i++) {
2415 for (k = 0; k < n2 && j < nt; j++, k++) {
2498 const char *fileout)
2500 l_int32 n1, n2, npairs;
2501 PIXA *pixa3, *pixa4, *pixa5;
2504 PROCNAME(
"pixaCompareInPdf");
2506 if (!pixa1 || !pixa2)
2507 return ERROR_INT(
"pixa1 and pixa2 not both defined", procName, 1);
2508 if (nx < 1 || ny < 1 || nx > 20 || ny > 20)
2509 return ERROR_INT(
"invalid tiling factors", procName, 1);
2511 return ERROR_INT(
"invalid tw; tw must be >= 20", procName, 1);
2512 if (fontsize < 0 || fontsize > 20 || fontsize & 1 || fontsize == 2)
2513 return ERROR_INT(
"invalid fontsize", procName, 1);
2515 return ERROR_INT(
"fileout not defined", procName, 1);
2518 if (n1 == 0 || n2 == 0)
2519 return ERROR_INT(
"at least one pixa is empty", procName, 1);
2521 L_WARNING(
"sizes (%d, %d) differ; using the minimum in interleave\n",
2526 return ERROR_INT(
"pixa3 not made", procName, 1);
2536 2 * tw + 4 * border + spacing,
2537 spacing, border, fontsize);
PIX * pixaaDisplay(PIXAA *paa, l_int32 w, l_int32 h)
pixaaDisplay()
l_int32 pixCopyColormap(PIX *pixd, PIX *pixs)
pixCopyColormap()
PIXA * pixaInterleave(PIXA *pixa1, PIXA *pixa2, l_int32 copyflag)
pixaInterleave()
void bmfDestroy(L_BMF **pbmf)
bmfDestroy()
PIX * pixConvertTo1(PIX *pixs, l_int32 threshold)
pixConvertTo1()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
PIX * pixScaleToGray(PIX *pixs, l_float32 scalefactor)
pixScaleToGray()
l_int32 numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
l_int32 lept_roundftoi(l_float32 fval)
lept_roundftoi()
SARRAY * sarrayGenerateIntegers(l_int32 n)
sarrayGenerateIntegers()
l_int32 pixaGetDepthInfo(PIXA *pixa, l_int32 *pmaxdepth, l_int32 *psame)
pixaGetDepthInfo()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
PIXA * pixaaDisplayTiledAndScaled(PIXAA *paa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)
pixaaDisplayTiledAndScaled()
l_int32 numaGetMax(NUMA *na, l_float32 *pmaxval, l_int32 *pimaxloc)
numaGetMax()
l_int32 pixSetAllArbitrary(PIX *pix, l_uint32 val)
pixSetAllArbitrary()
l_int32 modifyTrailingSlash(char *path, size_t nbytes, l_int32 flag)
modifyTrailingSlash()
PIXA * pixaaGetPixa(PIXAA *paa, l_int32 index, l_int32 accesstype)
pixaaGetPixa()
PIX * pixaDisplayLinearly(PIXA *pixas, l_int32 direction, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border, BOXA **pboxa)
pixaDisplayLinearly()
PIX * pixaDisplayUnsplit(PIXA *pixa, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor)
pixaDisplayUnsplit()
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()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
l_int32 pixaaGetCount(PIXAA *paa, NUMA **pna)
pixaaGetCount()
l_int32 splitPathAtDirectory(const char *pathname, char **pdir, char **ptail)
splitPathAtDirectory()
NUMA * numaMakeConstant(l_float32 val, l_int32 size)
numaMakeConstant()
l_int32 boxaAddBox(BOXA *boxa, BOX *box, l_int32 copyflag)
boxaAddBox()
PIX * pixaDisplayOnLattice(PIXA *pixa, l_int32 cellw, l_int32 cellh, l_int32 *pncols, BOXA **pboxa)
pixaDisplayOnLattice()
l_int32 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 * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
SARRAY * sarrayCreate(l_int32 n)
sarrayCreate()
PIXA * pixaConvertToSameDepth(PIXA *pixas)
pixaConvertToSameDepth()
NUMA * numaCreate(l_int32 n)
numaCreate()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
l_int32 pixaAnyColormaps(PIXA *pixa, l_int32 *phascmap)
pixaAnyColormaps()
l_int32 boxaGetBoxGeometry(BOXA *boxa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxaGetBoxGeometry()
PIX * pixaDisplay(PIXA *pixa, l_int32 w, l_int32 h)
pixaDisplay()
PIX * pixaDisplayTiledInColumns(PIXA *pixas, l_int32 nx, l_float32 scalefactor, l_int32 spacing, l_int32 border)
pixaDisplayTiledInColumns()
l_int32 pixaaVerifyDepth(PIXAA *paa, l_int32 *psame, l_int32 *pmaxd)
pixaaVerifyDepth()
l_int32 pixaVerifyDepth(PIXA *pixa, l_int32 *psame, l_int32 *pmaxd)
pixaVerifyDepth()
l_int32 pixaSizeRange(PIXA *pixa, l_int32 *pminw, l_int32 *pminh, l_int32 *pmaxw, l_int32 *pmaxh)
pixaSizeRange()
PIX * pixAddBorder(PIX *pixs, l_int32 npix, l_uint32 val)
pixAddBorder()
PIXA * pixaConvertTo8(PIXA *pixas, l_int32 cmapflag)
pixaConvertTo8()
PIXA * pixaCopy(PIXA *pixa, l_int32 copyflag)
pixaCopy()
l_int32 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()
l_int32 * numaGetIArray(NUMA *na)
numaGetIArray()
l_int32 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()
PIXA * pixaConstrainedSelect(PIXA *pixas, l_int32 first, l_int32 last, l_int32 nmax, l_int32 use_pairs, l_int32 copyflag)
pixaConstrainedSelect()
NUMA * genConstrainedNumaInRange(l_int32 first, l_int32 last, l_int32 nmax, l_int32 use_pairs)
genConstrainedNumaInRange()
PIX * pixaDisplayRandomCmap(PIXA *pixa, l_int32 w, l_int32 h)
pixaDisplayRandomCmap()
static const l_int32 L_INSERT
PIX * pixaDisplayTiledByIndex(PIXA *pixa, NUMA *na, l_int32 width, l_int32 spacing, l_int32 border, l_int32 fontsize, l_uint32 textcolor)
pixaDisplayTiledByIndex()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
l_int32 pixaWrite(const char *filename, PIXA *pixa)
pixaWrite()
l_int32 pixaGetPixDimensions(PIXA *pixa, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixaGetPixDimensions()
l_int32 pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
l_int32 pixaGetRenderingDepth(PIXA *pixa, l_int32 *pdepth)
pixaGetRenderingDepth()
PIX * pixaDisplayTiledInRows(PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledInRows()
PIXA * pixaSelectBySize(PIXA *pixas, l_int32 width, l_int32 height, l_int32 type, l_int32 relation, l_int32 *pchanged)
pixaSelectBySize()
PIX * pixConvertTo8Colormap(PIX *pixs, l_int32 dither)
pixConvertTo8Colormap()
l_int32 pixSetColormap(PIX *pix, PIXCMAP *colormap)
pixSetColormap()
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
PIX * pixaDisplayOnColor(PIXA *pixa, l_int32 w, l_int32 h, l_uint32 bgcolor)
pixaDisplayOnColor()
PIX * pixClone(PIX *pixs)
pixClone()
PIX * pixaDisplayTiledAndScaled(PIXA *pixa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledAndScaled()
l_int32 sarrayAddString(SARRAY *sa, char *string, l_int32 copyflag)
sarrayAddString()
PIX * pixScaleToSize(PIX *pixs, l_int32 wd, l_int32 hd)
pixScaleToSize()
l_int32 pixaConvertToPdf(PIXA *pixa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
pixaConvertToPdf()
void pixDestroy(PIX **ppix)
pixDestroy()
NUMA * numaMakeSequence(l_float32 startval, l_float32 increment, l_int32 size)
numaMakeSequence()
SARRAY * getSortedPathnamesInDirectory(const char *dirname, const char *substr, l_int32 first, l_int32 nfiles)
getSortedPathnamesInDirectory()
PIX * pixaaDisplayByPixa(PIXAA *paa, l_int32 xspace, l_int32 yspace, l_int32 maxw)
pixaaDisplayByPixa()
PIXA * pixaReadFilesSA(SARRAY *sa)
pixaReadFilesSA()
void numaDestroy(NUMA **pna)
numaDestroy()
l_int32 pixSetResolution(PIX *pix, l_int32 xres, l_int32 yres)
pixSetResolution()
l_int32 pixSetBlackOrWhite(PIX *pixs, l_int32 op)
pixSetBlackOrWhite()
l_int32 makeTempDirname(char *result, size_t nbytes, const char *subdir)
makeTempDirname()
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
char * pixGetText(PIX *pix)
pixGetText()
l_int32 boxaWriteMem(l_uint8 **pdata, size_t *psize, BOXA *boxa)
boxaWriteMem()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
l_int32 pixaGetBoxGeometry(PIXA *pixa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
pixaGetBoxGeometry()
l_int32 numaSetValue(NUMA *na, l_int32 index, l_float32 val)
numaSetValue()
l_int32 pixaAddBox(PIXA *pixa, BOX *box, l_int32 copyflag)
pixaAddBox()
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()
BOXA * boxaCreate(l_int32 n)
boxaCreate()
l_int32 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 * pixaConvertTo32(PIXA *pixas)
pixaConvertTo32()
l_int32 boxaGetExtent(BOXA *boxa, l_int32 *pw, l_int32 *ph, BOX **pbox)
boxaGetExtent()
PIX * pixConvert1To8(PIX *pixd, PIX *pixs, l_uint8 val0, l_uint8 val1)
pixConvert1To8()
PIXA * pixaConvertTo8Colormap(PIXA *pixas, l_int32 dither)
pixaConvertTo8Colormap()
PIX * pixAddTextlines(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location)
pixAddTextlines()
l_int32 boxaGetCount(BOXA *boxa)
boxaGetCount()
l_int32 numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
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()
BOXA * pixaaGetBoxa(PIXAA *paa, l_int32 accesstype)
pixaaGetBoxa()
l_int32 pixSetAll(PIX *pix)
pixSetAll()
l_int32 pixGetDimensions(PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
PIXA * pixaConvertTo1(PIXA *pixas, l_int32 thresh)
pixaConvertTo1()
PIXA * pixaSelectRange(PIXA *pixas, l_int32 first, l_int32 last, l_int32 copyflag)
pixaSelectRange()
l_int32 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_int32 lept_rmdir(const char *subdir)
lept_rmdir()
PIX * pixaDisplayTiledWithText(PIXA *pixa, l_int32 maxwidth, l_float32 scalefactor, l_int32 spacing, l_int32 border, l_int32 fontsize, l_uint32 textcolor)
pixaDisplayTiledWithText()
l_int32 pixaaSizeRange(PIXAA *paa, l_int32 *pminw, l_int32 *pminh, l_int32 *pmaxw, l_int32 *pmaxh)
pixaaSizeRange()
PIX * pixScale(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScale()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIX * pixAddSingleTextblock(PIX *pixs, L_BMF *bmf, const char *textstr, l_uint32 val, l_int32 location, l_int32 *poverflow)
pixAddSingleTextblock()
l_int32 pixaSetBoxa(PIXA *pixa, BOXA *boxa, l_int32 accesstype)
pixaSetBoxa()
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
PIX * pixAddBorderGeneral(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_uint32 val)
pixAddBorderGeneral()
l_int32 pixSetText(PIX *pix, const char *textstring)
pixSetText()
PIXA * pixaAddTextNumber(PIXA *pixas, L_BMF *bmf, NUMA *na, l_uint32 val, l_int32 location)
pixaAddTextNumber()
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
PIX * pixaDisplayTiled(PIXA *pixa, l_int32 maxwidth, l_int32 background, l_int32 spacing)
pixaDisplayTiled()
PIXCMAP * pixcmapCreateRandom(l_int32 depth, l_int32 hasblack, l_int32 haswhite)
pixcmapCreateRandom()
L_BMF * bmfCreate(const char *dir, l_int32 fontsize)
bmfCreate()
BOXA * pixaGetBoxa(PIXA *pixa, l_int32 accesstype)
pixaGetBoxa()