152 #include <config_auto.h>
156 #include "allheaders.h"
160 static const l_uint32 MaxPtrArraySize = 1000000;
164 static const size_t MaxDataSize = 1000000000;
167 extern l_int32 NumImageFileFormatExtensions;
168 extern const char *ImageFileFormatExtensions[];
173 l_uint8 **pdata,
size_t *pnbytes);
205 return (
PIXC *)ERROR_PTR(
"pix not defined", __func__, NULL);
206 if (comptype != IFF_DEFAULT && comptype != IFF_TIFF_G4 &&
207 comptype != IFF_PNG && comptype != IFF_JFIF_JPEG)
208 return (
PIXC *)ERROR_PTR(
"invalid comptype", __func__, NULL);
210 pixc = (
PIXC *)LEPT_CALLOC(1,
sizeof(
PIXC));
213 if (pixGetColormap(pix))
220 ret = pixWriteMem(&data, &size, pix, format);
222 L_ERROR(
"write to memory failed\n", __func__);
253 l_int32 format, w, h, d, bps, spp, iscmap;
257 return (
PIXC *)ERROR_PTR(
"data not defined", __func__, NULL);
259 return (
PIXC *)ERROR_PTR(
"invalid copyflag", __func__, NULL);
261 if (
pixReadHeaderMem(data, size, &format, &w, &h, &bps, &spp, &iscmap) == 1)
262 return (
PIXC *)ERROR_PTR(
"header data not read", __func__, NULL);
263 pixc = (
PIXC *)LEPT_CALLOC(1,
sizeof(
PIXC));
264 d = (spp == 3) ? 32 : bps * spp;
305 return (
PIXC *)ERROR_PTR(
"filename not defined", __func__, NULL);
306 if (comptype != IFF_DEFAULT && comptype != IFF_TIFF_G4 &&
307 comptype != IFF_PNG && comptype != IFF_JFIF_JPEG)
308 return (
PIXC *)ERROR_PTR(
"invalid comptype", __func__, NULL);
311 if (format == IFF_UNKNOWN) {
312 L_ERROR(
"unreadable file: %s\n", __func__, filename);
320 if ((format == IFF_TIFF_G4 && comptype != IFF_PNG) ||
321 (format == IFF_JFIF_JPEG && comptype != IFF_PNG))
323 if (comptype != IFF_DEFAULT && comptype == format) {
327 return (
PIXC *)ERROR_PTR(
"pixc not made (string)", __func__, NULL);
333 if ((pix =
pixRead(filename)) == NULL)
334 return (
PIXC *)ERROR_PTR(
"pix not read", __func__, NULL);
337 return (
PIXC *)ERROR_PTR(
"pixc not made", __func__, NULL);
361 L_WARNING(
"ptr address is null!\n", __func__);
365 if ((pixc = *ppixc) == NULL)
368 LEPT_FREE(pixc->
data);
370 LEPT_FREE(pixc->
text);
391 l_uint8 *datas, *datad;
395 return (
PIXC *)ERROR_PTR(
"pixcs not defined", __func__, NULL);
397 if (size > MaxDataSize)
398 return (
PIXC *)ERROR_PTR(
"size > 1 GB; too big", __func__, NULL);
400 pixcd = (
PIXC *)LEPT_CALLOC(1,
sizeof(
PIXC));
407 if (pixcs->
text != NULL)
413 if ((datad = (l_uint8 *)LEPT_CALLOC(size,
sizeof(l_int8))) == NULL) {
415 return (
PIXC *)ERROR_PTR(
"pixcd not made", __func__, NULL);
417 memcpy(datad, datas, size);
441 return ERROR_INT(
"pixc not defined", __func__, 1);
442 if (pw) *pw = pixc->
w;
443 if (ph) *ph = pixc->
h;
444 if (pd) *pd = pixc->
d;
464 return ERROR_INT(
"pixc not defined", __func__, 1);
465 if (pxres) *pxres = pixc->
xres;
466 if (pyres) *pyres = pixc->
yres;
467 if (pcomptype) *pcomptype = pixc->
comptype;
468 if (pcmapflag) *pcmapflag = pixc->
cmapflag;
508 return ERROR_INT(
"&format not defined", __func__, 1);
510 if (comptype != IFF_DEFAULT && comptype != IFF_TIFF_G4 &&
511 comptype != IFF_PNG && comptype != IFF_JFIF_JPEG)
512 return ERROR_INT(
"invalid comptype", __func__, 1);
514 if (comptype == IFF_DEFAULT) {
516 *pformat = IFF_TIFF_G4;
519 else if (d >= 8 && !cmapflag)
520 *pformat = IFF_JFIF_JPEG;
521 }
else if (comptype == IFF_TIFF_G4 && d == 1) {
522 *pformat = IFF_TIFF_G4;
523 }
else if (comptype == IFF_JFIF_JPEG && d >= 8 && !cmapflag) {
524 *pformat = IFF_JFIF_JPEG;
543 l_int32 w, h, d, cmapinpix, format;
547 return (
PIX *)ERROR_PTR(
"pixc not defined", __func__, NULL);
550 return (
PIX *)ERROR_PTR(
"pix not read", __func__, NULL);
558 L_INFO(
"pix width %d != pixc width %d\n", __func__, w, pixc->
w);
559 L_ERROR(
"pix width %d != pixc width\n", __func__, w);
562 L_ERROR(
"pix height %d != pixc height\n", __func__, h);
565 L_WARNING(
"pix depth %d != pixc depth 16\n", __func__, d);
567 L_ERROR(
"pix depth %d != pixc depth\n", __func__, d);
569 cmapinpix = (pixGetColormap(pix) != NULL);
571 L_ERROR(
"pix cmap flag inconsistent\n", __func__);
572 format = pixGetInputFormat(pix);
574 L_ERROR(
"pix comptype %d not equal to pixc comptype\n",
596 if (n <= 0 || n > MaxPtrArraySize)
599 pixac = (
PIXAC *)LEPT_CALLOC(1,
sizeof(
PIXAC));
603 if ((pixac->
pixc = (
PIXC **)LEPT_CALLOC(n,
sizeof(
PIXC *))) == NULL) {
605 return (
PIXAC *)ERROR_PTR(
"pixc ptrs not made", __func__, NULL);
609 return (
PIXAC *)ERROR_PTR(
"boxa not made", __func__, NULL);
665 if (n <= 0 || n > MaxPtrArraySize)
666 return (
PIXAC *)ERROR_PTR(
"n out of valid bounds", __func__, NULL);
668 if (comptype != IFF_DEFAULT && comptype != IFF_TIFF_G4 &&
669 comptype != IFF_PNG && comptype != IFF_JFIF_JPEG)
670 return (
PIXAC *)ERROR_PTR(
"invalid comptype", __func__, NULL);
672 comptype = IFF_TIFF_G4;
675 L_WARNING(
"offset < 0; setting to 0\n", __func__);
680 return (
PIXAC *)ERROR_PTR(
"pixac not made", __func__, NULL);
686 for (i = 0; i < n; i++) {
727 return (
PIXAC *)ERROR_PTR(
"pixa not defined", __func__, NULL);
728 if (comptype != IFF_DEFAULT && comptype != IFF_TIFF_G4 &&
729 comptype != IFF_PNG && comptype != IFF_JFIF_JPEG)
730 return (
PIXAC *)ERROR_PTR(
"invalid comptype", __func__, NULL);
733 return (
PIXAC *)ERROR_PTR(
"invalid accesstype", __func__, NULL);
737 return (
PIXAC *)ERROR_PTR(
"pixac not made", __func__, NULL);
738 for (i = 0; i < n; i++) {
743 if ((boxa =
pixaGetBoxa(pixa, accesstype)) != NULL) {
782 return (
PIXAC *)ERROR_PTR(
"dirname not defined", __func__, NULL);
783 if (comptype != IFF_DEFAULT && comptype != IFF_TIFF_G4 &&
784 comptype != IFF_PNG && comptype != IFF_JFIF_JPEG)
785 return (
PIXAC *)ERROR_PTR(
"invalid comptype", __func__, NULL);
788 return (
PIXAC *)ERROR_PTR(
"sa not made", __func__, NULL);
820 return (
PIXAC *)ERROR_PTR(
"sarray not defined", __func__, NULL);
821 if (comptype != IFF_DEFAULT && comptype != IFF_TIFF_G4 &&
822 comptype != IFF_PNG && comptype != IFF_JFIF_JPEG)
823 return (
PIXAC *)ERROR_PTR(
"invalid comptype", __func__, NULL);
827 for (i = 0; i < n; i++) {
830 L_ERROR(
"pixc not read from file: %s\n", __func__, str);
856 if (ppixac == NULL) {
857 L_WARNING(
"ptr address is NULL!\n", __func__);
861 if ((pixac = *ppixac) == NULL)
864 for (i = 0; i < pixac->
n; i++)
866 LEPT_FREE(pixac->
pixc);
898 l_int32 cmapflag, format;
902 return ERROR_INT(
"pixac not defined", __func__, 1);
904 return ERROR_INT(
"pix not defined", __func__, 1);
905 if (comptype != IFF_DEFAULT && comptype != IFF_TIFF_G4 &&
906 comptype != IFF_PNG && comptype != IFF_JFIF_JPEG)
907 return ERROR_INT(
"invalid format", __func__, 1);
909 cmapflag = pixGetColormap(pix) ? 1 : 0;
912 return ERROR_INT(
"pixc not made", __func__, 1);
941 return ERROR_INT(
"pixac not defined", __func__, 1);
943 return ERROR_INT(
"pixc not defined", __func__, 1);
945 return ERROR_INT(
"invalid copyflag", __func__, 1);
950 return ERROR_INT(
"extension failed", __func__, 1);
954 pixac->
pixc[n] = pixc;
981 size_t oldsize, newsize;
984 return ERROR_INT(
"pixac not defined", __func__, 1);
985 if (pixac->
nalloc > MaxPtrArraySize)
986 return ERROR_INT(
"pixac has too many ptrs", __func__, 1);
988 newsize = 2 * oldsize;
989 if (newsize > 8 * MaxPtrArraySize)
990 return ERROR_INT(
"newsize > 8 MB; too large", __func__, 1);
993 oldsize, newsize)) == NULL)
994 return ERROR_INT(
"new ptr array not returned", __func__, 1);
1028 return ERROR_INT(
"pixac not defined", __func__, 1);
1030 aindex = index - pixac->
offset;
1031 if (aindex < 0 || aindex >= n)
1032 return ERROR_INT(
"array index out of bounds", __func__, 1);
1034 return ERROR_INT(
"pix not defined", __func__, 1);
1035 if (comptype != IFF_DEFAULT && comptype != IFF_TIFF_G4 &&
1036 comptype != IFF_PNG && comptype != IFF_JFIF_JPEG)
1037 return ERROR_INT(
"invalid format", __func__, 1);
1070 return ERROR_INT(
"pixac not defined", __func__, 1);
1072 aindex = index - pixac->
offset;
1073 if (aindex < 0 || aindex >= n)
1074 return ERROR_INT(
"array index out of bounds", __func__, 1);
1076 return ERROR_INT(
"pixc not defined", __func__, 1);
1080 pixac->
pixc[aindex] = pixc;
1100 return ERROR_INT(
"pixac not defined", __func__, 1);
1102 return ERROR_INT(
"box not defined", __func__, 1);
1104 return ERROR_INT(
"invalid copyflag", __func__, 1);
1124 return ERROR_INT(
"pixac not defined", __func__, 0);
1154 return (
PIXC *)ERROR_PTR(
"pixac not defined", __func__, NULL);
1156 return (
PIXC *)ERROR_PTR(
"invalid copyflag", __func__, NULL);
1157 aindex = index - pixac->
offset;
1158 if (aindex < 0 || aindex >= pixac->
n)
1159 return (
PIXC *)ERROR_PTR(
"array index not valid", __func__, NULL);
1162 return pixac->
pixc[aindex];
1189 return (
PIX *)ERROR_PTR(
"pixac not defined", __func__, NULL);
1190 aindex = index - pixac->
offset;
1191 if (aindex < 0 || aindex >= pixac->
n)
1192 return (
PIX *)ERROR_PTR(
"array index not valid", __func__, NULL);
1225 return ERROR_INT(
"pixac not defined", __func__, 1);
1226 aindex = index - pixac->
offset;
1227 if (aindex < 0 || aindex >= pixac->
n)
1228 return ERROR_INT(
"array index not valid", __func__, 1);
1230 if ((pixc = pixac->
pixc[aindex]) == NULL)
1231 return ERROR_INT(
"pixc not found!", __func__, 1);
1249 return (
BOXA *)ERROR_PTR(
"pixac not defined", __func__, NULL);
1251 return (
BOXA *)ERROR_PTR(
"boxa not defined", __func__, NULL);
1254 return (
BOXA *)ERROR_PTR(
"invalid accesstype", __func__, NULL);
1270 return ERROR_INT(
"pixac not defined", __func__, 0);
1308 return (
BOX *)ERROR_PTR(
"pixac not defined", __func__, NULL);
1310 return (
BOX *)ERROR_PTR(
"boxa not defined", __func__, NULL);
1311 aindex = index - pixac->
offset;
1312 if (aindex < 0 || aindex >= pixac->
boxa->
n)
1313 return (
BOX *)ERROR_PTR(
"array index not valid", __func__, NULL);
1315 return (
BOX *)ERROR_PTR(
"invalid accesstype", __func__, NULL);
1317 box = pixac->
boxa->
box[aindex];
1319 if (accesstype ==
L_COPY)
1356 return ERROR_INT(
"pixac not defined", __func__, 1);
1357 aindex = index - pixac->
offset;
1358 if (aindex < 0 || aindex >= pixac->
n)
1359 return ERROR_INT(
"array index not valid", __func__, 1);
1362 return ERROR_INT(
"box not found!", __func__, 1);
1386 return ERROR_INT(
"pixac not defined", __func__, 0);
1410 return ERROR_INT(
"pixac not defined", __func__, 1);
1411 pixac->
offset = L_MAX(0, offset);
1437 l_int32 i, n, offset;
1442 return (
PIXA *)ERROR_PTR(
"pixac not defined", __func__, NULL);
1445 return (
PIXA *)ERROR_PTR(
"invalid accesstype", __func__, NULL);
1451 return (
PIXA *)ERROR_PTR(
"pixa not made", __func__, NULL);
1452 for (i = 0; i < n; i++) {
1454 L_WARNING(
"pix %d not made\n", __func__, i);
1496 BOXA *boxas, *boxad;
1500 return ERROR_INT(
"pixacd not defined", __func__, 1);
1506 if (iend < 0 || iend >= n)
1509 return ERROR_INT(
"istart > iend; nothing to add", __func__, 1);
1511 for (i = istart; i <= iend; i++) {
1519 iend = L_MIN(iend, nb - 1);
1520 boxaJoin(boxad, boxas, istart, iend);
1544 l_int32 i, n1, n2, n, nb1, nb2;
1546 PIXC *pixc1, *pixc2;
1550 return (
PIXAC *)ERROR_PTR(
"pixac1 not defined", __func__, NULL);
1552 return (
PIXAC *)ERROR_PTR(
"pixac2 not defined", __func__, NULL);
1557 return (
PIXAC *)ERROR_PTR(
"at least one input pixac is empty",
1560 L_WARNING(
"counts differ: %d != %d\n", __func__, n1, n2);
1565 for (i = 0; i < n; i++) {
1607 return (
PIXAC *)ERROR_PTR(
"filename not defined", __func__, NULL);
1610 return (
PIXAC *)ERROR_PTR(
"stream not opened", __func__, NULL);
1614 return (
PIXAC *)ERROR_PTR(
"pixac not read", __func__, NULL);
1635 l_int32 n, offset, i, w, h, d, ignore;
1636 l_int32 comptype, cmapflag, version, xres, yres;
1643 return (
PIXAC *)ERROR_PTR(
"stream not defined", __func__, NULL);
1645 if (fscanf(fp,
"\nPixacomp Version %d\n", &version) != 1)
1646 return (
PIXAC *)ERROR_PTR(
"not a pixacomp file", __func__, NULL);
1648 return (
PIXAC *)ERROR_PTR(
"invalid pixacomp version", __func__, NULL);
1649 if (fscanf(fp,
"Number of pixcomp = %d\n", &n) != 1)
1650 return (
PIXAC *)ERROR_PTR(
"not a pixacomp file", __func__, NULL);
1651 if (fscanf(fp,
"Offset of index into array = %d", &offset) != 1)
1652 return (
PIXAC *)ERROR_PTR(
"offset not read", __func__, NULL);
1654 return (
PIXAC *)ERROR_PTR(
"num pixcomp ptrs < 0", __func__, NULL);
1655 if (n > MaxPtrArraySize)
1656 return (
PIXAC *)ERROR_PTR(
"too many pixcomp ptrs", __func__, NULL);
1657 if (n == 0) L_INFO(
"the pixacomp is empty\n", __func__);
1660 return (
PIXAC *)ERROR_PTR(
"pixac not made", __func__, NULL);
1663 return (
PIXAC *)ERROR_PTR(
"boxa not made", __func__, NULL);
1669 for (i = 0; i < n; i++) {
1670 if (fscanf(fp,
"\nPixcomp[%d]: w = %d, h = %d, d = %d\n",
1671 &ignore, &w, &h, &d) != 4) {
1673 return (
PIXAC *)ERROR_PTR(
"dimension reading", __func__, NULL);
1675 if (fscanf(fp,
" comptype = %d, size = %zu, cmapflag = %d\n",
1676 &comptype, &size, &cmapflag) != 3) {
1678 return (
PIXAC *)ERROR_PTR(
"comptype/size reading", __func__, NULL);
1680 if (size > MaxDataSize) {
1682 L_ERROR(
"data size = %zu is too big", __func__, size);
1691 if (fgets(buf,
sizeof(buf), fp) == NULL) {
1693 return (
PIXAC *)ERROR_PTR(
"fgets read fail", __func__, NULL);
1695 if (sscanf(buf,
" xres = %d, yres = %d\n", &xres, &yres) != 2) {
1697 return (
PIXAC *)ERROR_PTR(
"read fail for res", __func__, NULL);
1699 if ((data = (l_uint8 *)LEPT_CALLOC(1, size)) == NULL) {
1701 return (
PIXAC *)ERROR_PTR(
"calloc fail for data", __func__, NULL);
1703 if (fread(data, 1, size, fp) != size) {
1706 return (
PIXAC *)ERROR_PTR(
"error reading data", __func__, NULL);
1709 pixc = (
PIXC *)LEPT_CALLOC(1,
sizeof(
PIXC));
1745 return (
PIXAC *)ERROR_PTR(
"data not defined", __func__, NULL);
1747 return (
PIXAC *)ERROR_PTR(
"stream not opened", __func__, NULL);
1751 if (!pixac) L_ERROR(
"pixac not read\n", __func__);
1778 return ERROR_INT(
"filename not defined", __func__, 1);
1780 return ERROR_INT(
"pixacomp not defined", __func__, 1);
1783 return ERROR_INT(
"stream not opened", __func__, 1);
1787 return ERROR_INT(
"pixacomp not written to stream", __func__, 1);
1807 return ERROR_INT(
"stream not defined", __func__, 1);
1809 return ERROR_INT(
"pixac not defined", __func__, 1);
1813 fprintf(fp,
"Number of pixcomp = %d\n", n);
1814 fprintf(fp,
"Offset of index into array = %d", pixac->
offset);
1816 for (i = 0; i < n; i++) {
1819 return ERROR_INT(
"pixc not found", __func__, 1);
1820 fprintf(fp,
"\nPixcomp[%d]: w = %d, h = %d, d = %d\n",
1821 i, pixc->
w, pixc->
h, pixc->
d);
1822 fprintf(fp,
" comptype = %d, size = %zu, cmapflag = %d\n",
1824 fprintf(fp,
" xres = %d, yres = %d\n", pixc->
xres, pixc->
yres);
1825 fwrite(pixc->
data, 1, pixc->
size, fp);
1853 if (pdata) *pdata = NULL;
1854 if (psize) *psize = 0;
1856 return ERROR_INT(
"&data not defined", __func__, 1);
1858 return ERROR_INT(
"&size not defined", __func__, 1);
1860 return ERROR_INT(
"&pixac not defined", __func__, 1);
1863 if ((fp = open_memstream((
char **)pdata, psize)) == NULL)
1864 return ERROR_INT(
"stream not opened", __func__, 1);
1868 *psize = *psize - 1;
1870 L_INFO(
"work-around: writing to a temp file\n", __func__);
1873 return ERROR_INT(
"tmpfile stream not opened", __func__, 1);
1875 if ((fp = tmpfile()) == NULL)
1876 return ERROR_INT(
"tmpfile stream not opened", __func__, 1);
1925 l_float32 scalefactor,
1929 const char *fileout)
1936 return ERROR_INT(
"pixac not defined", __func__, 1);
1939 title, &data, &nbytes);
1942 return ERROR_INT(
"conversion to pdf failed", __func__, 1);
1948 L_ERROR(
"pdf data not written to file\n", __func__);
1976 l_float32 scalefactor,
1984 l_int32 i, n, ret, scaledres, pagetype;
1991 return ERROR_INT(
"&data not defined", __func__, 1);
1994 return ERROR_INT(
"&nbytes not defined", __func__, 1);
1997 return ERROR_INT(
"pixac not defined", __func__, 1);
1998 if (scalefactor <= 0.0) scalefactor = 1.0;
2002 L_WARNING(
"invalid compression type; using per-page default\n",
2010 for (i = 0; i < n; i++) {
2013 L_ERROR(
"pix[%d] not retrieved\n", __func__, i);
2016 if (pixGetWidth(pixs) == 1) {
2017 L_INFO(
"placeholder image[%d] has w = 1\n", __func__, i);
2021 if (scalefactor != 1.0)
2022 pix =
pixScale(pixs, scalefactor, scalefactor);
2026 scaledres = (l_int32)(res * scalefactor);
2032 L_ERROR(
"encoding type selection failed for pix[%d]\n",
2039 0, 0, scaledres, title, NULL, 0);
2042 L_ERROR(
"pdf encoding failed for pix[%d]\n", __func__, i);
2051 L_ERROR(
"no pdf files made\n", __func__);
2060 for (i = 0; i < n; i++) {
2094 l_int32 i, n, ret, comptype;
2101 return ERROR_INT(
"&data not defined", __func__, 1);
2104 return ERROR_INT(
"&nbytes not defined", __func__, 1);
2107 return ERROR_INT(
"pixac not defined", __func__, 1);
2112 for (i = 0; i < n; i++) {
2114 L_ERROR(
"pixc[%d] not retrieved\n", __func__, i);
2118 if (comptype != IFF_JFIF_JPEG) {
2119 L_ERROR(
"pixc[%d] not jpeg compressed\n", __func__, i);
2124 L_ERROR(
"pdf encoding failed for pixc[%d]\n", __func__, i);
2133 L_ERROR(
"no pdf files made\n", __func__);
2143 for (i = 0; i < n; i++) {
2180 return ERROR_INT(
"&data not defined", __func__, 1);
2183 return ERROR_INT(
"&nbytes not defined", __func__, 1);
2186 return ERROR_INT(
"pixc not defined", __func__, 1);
2213 l_int32 i, n, nboxes;
2217 return ERROR_INT(
"fp not defined", __func__, 1);
2219 return ERROR_INT(
"pixac not defined", __func__, 1);
2222 fprintf(fp,
"Pixacomp Info for %s:\n", text);
2224 fprintf(fp,
"Pixacomp Info:\n");
2227 fprintf(fp,
"Number of pixcomp: %d\n", n);
2228 fprintf(fp,
"Size of pixcomp array alloc: %d\n", pixac->
nalloc);
2229 fprintf(fp,
"Offset of index into array: %d\n", pixac->
offset);
2231 fprintf(fp,
"Boxa has %d boxes\n", nboxes);
2233 fprintf(fp,
"Boxa is empty\n");
2234 for (i = 0; i < n; i++) {
2256 return ERROR_INT(
"fp not defined", __func__, 1);
2258 return ERROR_INT(
"pixc not defined", __func__, 1);
2261 fprintf(fp,
" Pixcomp Info for %s:", text);
2263 fprintf(fp,
" Pixcomp Info:");
2264 fprintf(fp,
" width = %d, height = %d, depth = %d\n",
2265 pixc->
w, pixc->
h, pixc->
d);
2266 fprintf(fp,
" xres = %d, yres = %d, size in bytes = %zu\n",
2269 fprintf(fp,
" has colormap\n");
2271 fprintf(fp,
" no colormap\n");
2272 if (pixc->
comptype < NumImageFileFormatExtensions) {
2273 fprintf(fp,
" comptype = %s (%d)\n",
2276 fprintf(fp,
" Error!! Invalid comptype index: %d\n", pixc->
comptype);
2317 return (
PIX *)ERROR_PTR(
"pixac not defined", __func__, NULL);
2320 return (
PIX *)ERROR_PTR(
"pixa not made", __func__, NULL);
2323 background, spacing, border);
2345 return ERROR_INT(
"pixac not defined", __func__, 1);
2348 return ERROR_INT(
"invalid subdir", __func__, 1);
2351 for (i = 0; i < n; i++) {
2353 snprintf(buf,
sizeof(buf),
"/tmp/%s/%03d", subdir, i);
2359 extern const char *ImageFileFormatExtensions[];
2381 return ERROR_INT(
"pixc not defined", __func__, 1);
2383 snprintf(buf,
sizeof(buf),
"%s.%s", rootname,
2384 ImageFileFormatExtensions[pixc->
comptype]);
l_ok boxGetGeometry(const BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
boxGetGeometry()
BOXA * boxaReadStream(FILE *fp)
boxaReadStream()
BOXA * boxaCopy(BOXA *boxa, l_int32 copyflag)
boxaCopy()
void boxDestroy(BOX **pbox)
boxDestroy()
BOX * boxClone(BOX *box)
boxClone()
l_ok boxaAddBox(BOXA *boxa, BOX *box, l_int32 copyflag)
boxaAddBox()
l_ok boxaExtendArray(BOXA *boxa)
boxaExtendArray()
void boxaDestroy(BOXA **pboxa)
boxaDestroy()
l_int32 boxaGetCount(const BOXA *boxa)
boxaGetCount()
BOX * boxCopy(BOX *box)
boxCopy()
BOXA * boxaCreate(l_int32 n)
boxaCreate()
l_ok boxaWriteStream(FILE *fp, BOXA *boxa)
boxaWriteStream()
l_ok boxaJoin(BOXA *boxad, BOXA *boxas, l_int32 istart, l_int32 iend)
boxaJoin()
void l_byteaDestroy(L_BYTEA **pba)
l_byteaDestroy()
L_BYTEA * l_byteaInitFromMem(const l_uint8 *data, size_t size)
l_byteaInitFromMem()
l_ok selectDefaultPdfEncoding(PIX *pix, l_int32 *ptype)
selectDefaultPdfEncoding()
L_COMP_DATA * l_generateJpegDataMem(l_uint8 *data, size_t nbytes, l_int32 ascii85flag)
l_generateJpegDataMem()
l_ok pixConvertToPdfData(PIX *pix, l_int32 type, l_int32 quality, l_uint8 **pdata, size_t *pnbytes, l_int32 x, l_int32 y, l_int32 res, const char *title, L_PDF_DATA **plpd, l_int32 position)
pixConvertToPdfData()
l_ok ptraConcatenatePdfToData(L_PTRA *pa_data, SARRAY *sa, l_uint8 **pdata, size_t *pnbytes)
ptraConcatenatePdfToData()
l_ok cidConvertToPdfData(L_COMP_DATA *cid, const char *title, l_uint8 **pdata, size_t *pnbytes)
cidConvertToPdfData()
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 pixGetResolution(const PIX *pix, l_int32 *pxres, l_int32 *pyres)
pixGetResolution()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
PIX * pixClone(PIX *pixs)
pixClone()
#define PIXACOMP_VERSION_NUMBER
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
BOXA * pixaGetBoxa(PIXA *pixa, l_int32 accesstype)
pixaGetBoxa()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
PIX * pixaDisplayTiledAndScaled(PIXA *pixa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledAndScaled()
l_ok pixacompJoin(PIXAC *pixacd, PIXAC *pixacs, l_int32 istart, l_int32 iend)
pixacompJoin()
PIXC * pixcompCreateFromPix(PIX *pix, l_int32 comptype)
pixcompCreateFromPix()
PIXAC * pixacompReadStream(FILE *fp)
pixacompReadStream()
PIXAC * pixacompCreateFromPixa(PIXA *pixa, l_int32 comptype, l_int32 accesstype)
pixacompCreateFromPixa()
void pixacompDestroy(PIXAC **ppixac)
pixacompDestroy()
l_ok pixacompFastConvertToPdfData(PIXAC *pixac, const char *title, l_uint8 **pdata, size_t *pnbytes)
pixacompFastConvertToPdfData()
l_ok pixacompWriteStream(FILE *fp, PIXAC *pixac)
pixacompWriteStream()
PIXAC * pixacompCreateFromSA(SARRAY *sa, l_int32 comptype)
pixacompCreateFromSA()
l_ok pixacompWrite(const char *filename, PIXAC *pixac)
pixacompWrite()
void pixcompDestroy(PIXC **ppixc)
pixcompDestroy()
PIXA * pixaCreateFromPixacomp(PIXAC *pixac, l_int32 accesstype)
pixaCreateFromPixacomp()
l_ok pixacompWriteMem(l_uint8 **pdata, size_t *psize, PIXAC *pixac)
pixacompWriteMem()
PIXAC * pixacompRead(const char *filename)
pixacompRead()
static const l_int32 InitialPtrArraySize
PIXAC * pixacompReadMem(const l_uint8 *data, size_t size)
pixacompReadMem()
PIXAC * pixacompCreateWithInit(l_int32 n, l_int32 offset, PIX *pix, l_int32 comptype)
pixacompCreateWithInit()
l_ok pixacompConvertToPdfData(PIXAC *pixac, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, l_uint8 **pdata, size_t *pnbytes)
pixacompConvertToPdfData()
PIXC * pixacompGetPixcomp(PIXAC *pixac, l_int32 index, l_int32 copyflag)
pixacompGetPixcomp()
PIXAC * pixacompCreateFromFiles(const char *dirname, const char *substr, l_int32 comptype)
pixacompCreateFromFiles()
PIX * pixacompDisplayTiledAndScaled(PIXAC *pixac, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)
pixacompDisplayTiledAndScaled()
l_int32 pixacompGetBoxaCount(PIXAC *pixac)
pixacompGetBoxaCount()
l_ok pixcompGetParameters(PIXC *pixc, l_int32 *pxres, l_int32 *pyres, l_int32 *pcomptype, l_int32 *pcmapflag)
pixcompGetParameters()
l_ok pixcompWriteFile(const char *rootname, PIXC *pixc)
pixcompWriteFile()
l_ok pixacompReplacePix(PIXAC *pixac, l_int32 index, PIX *pix, l_int32 comptype)
pixacompReplacePix()
PIXAC * pixacompCreate(l_int32 n)
pixacompCreate()
static l_int32 pixacompExtendArray(PIXAC *pixac)
pixacompExtendArray()
l_ok pixcompGetDimensions(PIXC *pixc, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixcompGetDimensions()
l_ok pixacompConvertToPdf(PIXAC *pixac, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
pixacompConvertToPdf()
BOX * pixacompGetBox(PIXAC *pixac, l_int32 index, l_int32 accesstype)
pixacompGetBox()
PIXC * pixcompCreateFromString(l_uint8 *data, size_t size, l_int32 copyflag)
pixcompCreateFromString()
PIXC * pixcompCopy(PIXC *pixcs)
pixcompCopy()
l_ok pixacompSetOffset(PIXAC *pixac, l_int32 offset)
pixacompSetOffset()
static l_int32 pixcompFastConvertToPdfData(PIXC *pixc, const char *title, l_uint8 **pdata, size_t *pnbytes)
pixcompFastConvertToPdfData()
PIXAC * pixacompInterleave(PIXAC *pixac1, PIXAC *pixac2)
pixacompInterleave()
l_ok pixacompWriteStreamInfo(FILE *fp, PIXAC *pixac, const char *text)
pixacompWriteStreamInfo()
PIXC * pixcompCreateFromFile(const char *filename, l_int32 comptype)
pixcompCreateFromFile()
l_ok pixacompGetBoxGeometry(PIXAC *pixac, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
pixacompGetBoxGeometry()
l_int32 pixacompGetOffset(PIXAC *pixac)
pixacompGetOffset()
l_int32 pixacompGetCount(PIXAC *pixac)
pixacompGetCount()
l_ok pixacompAddPix(PIXAC *pixac, PIX *pix, l_int32 comptype)
pixacompAddPix()
l_ok pixacompAddBox(PIXAC *pixac, BOX *box, l_int32 copyflag)
pixacompAddBox()
l_ok pixacompAddPixcomp(PIXAC *pixac, PIXC *pixc, l_int32 copyflag)
pixacompAddPixcomp()
l_ok pixcompDetermineFormat(l_int32 comptype, l_int32 d, l_int32 cmapflag, l_int32 *pformat)
pixcompDetermineFormat()
PIX * pixacompGetPix(PIXAC *pixac, l_int32 index)
pixacompGetPix()
l_ok pixacompWriteFiles(PIXAC *pixac, const char *subdir)
pixacompWriteFiles()
BOXA * pixacompGetBoxa(PIXAC *pixac, l_int32 accesstype)
pixacompGetBoxa()
PIX * pixCreateFromPixcomp(PIXC *pixc)
pixCreateFromPixcomp()
l_ok pixcompWriteStreamInfo(FILE *fp, PIXC *pixc, const char *text)
pixcompWriteStreamInfo()
l_ok pixacompReplacePixcomp(PIXAC *pixac, l_int32 index, PIXC *pixc)
pixacompReplacePixcomp()
l_ok pixacompGetPixDimensions(PIXAC *pixac, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixacompGetPixDimensions()
L_PTRA * ptraCreate(l_int32 n)
ptraCreate()
l_ok ptraGetActualCount(L_PTRA *pa, l_int32 *pcount)
ptraGetActualCount()
l_ok ptraAdd(L_PTRA *pa, void *item)
ptraAdd()
void ptraDestroy(L_PTRA **ppa, l_int32 freeflag, l_int32 warnflag)
ptraDestroy()
void * ptraRemove(L_PTRA *pa, l_int32 index, l_int32 flag)
ptraRemove()
l_ok findFileFormat(const char *filename, l_int32 *pformat)
findFileFormat()
PIX * pixReadMem(const l_uint8 *data, size_t size)
pixReadMem()
PIX * pixRead(const char *filename)
pixRead()
l_ok pixReadHeaderMem(const l_uint8 *data, size_t size, l_int32 *pformat, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap)
pixReadHeaderMem()
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
SARRAY * getSortedPathnamesInDirectory(const char *dirname, const char *substr, l_int32 first, l_int32 nfiles)
getSortedPathnamesInDirectory()
PIX * pixScale(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScale()
char * stringNew(const char *src)
stringNew()
l_uint8 * l_binaryReadStream(FILE *fp, size_t *pnbytes)
l_binaryReadStream()
FILE * fopenReadFromMemory(const l_uint8 *data, size_t size)
fopenReadFromMemory()
FILE * fopenWriteStream(const char *filename, const char *modestring)
fopenWriteStream()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
l_ok l_binaryWrite(const char *filename, const char *operation, const void *data, size_t nbytes)
l_binaryWrite()
void * reallocNew(void **pindata, size_t oldsize, size_t newsize)
reallocNew()
FILE * fopenWriteWinTempfile(void)
fopenWriteWinTempfile()
FILE * fopenReadStream(const char *filename)
fopenReadStream()
l_uint8 * l_binaryCopy(const l_uint8 *datas, size_t size)
l_binaryCopy()
l_uint8 * l_binaryRead(const char *filename, size_t *pnbytes)
l_binaryRead()