75 #include <config_auto.h>
79 #include "allheaders.h"
82 static const char *FILE_BMP =
"/tmp/lept/format/file.bmp";
83 static const char *FILE_PNG =
"/tmp/lept/format/file.png";
84 static const char *FILE_PNM =
"/tmp/lept/format/file.pnm";
85 static const char *FILE_G3 =
"/tmp/lept/format/file_g3.tif";
86 static const char *FILE_G4 =
"/tmp/lept/format/file_g4.tif";
87 static const char *FILE_RLE =
"/tmp/lept/format/file_rle.tif";
88 static const char *FILE_PB =
"/tmp/lept/format/file_packbits.tif";
89 static const char *FILE_LZW =
"/tmp/lept/format/file_lzw.tif";
90 static const char *FILE_ZIP =
"/tmp/lept/format/file_zip.tif";
91 static const char *FILE_TIFF_JPEG =
"/tmp/lept/format/file_jpeg.tif";
92 static const char *FILE_TIFF =
"/tmp/lept/format/file.tif";
93 static const char *FILE_JPG =
"/tmp/lept/format/file.jpg";
94 static const char *FILE_GIF =
"/tmp/lept/format/file.gif";
95 static const char *FILE_WEBP =
"/tmp/lept/format/file.webp";
96 static const char *FILE_JP2K =
"/tmp/lept/format/file.jp2";
101 static const unsigned char JP2K_CODESTREAM[4] = { 0xff, 0x4f, 0xff, 0x51 };
102 static const unsigned char JP2K_IMAGE_DATA[12] = { 0x00, 0x00, 0x00, 0x0c,
103 0x6a, 0x50, 0x20, 0x20,
104 0x0d, 0x0a, 0x87, 0x0a };
134 return (
PIXA *)ERROR_PTR(
"dirname not defined", __func__, NULL);
137 return (
PIXA *)ERROR_PTR(
"sa not made", __func__, NULL);
160 return (
PIXA *)ERROR_PTR(
"sa not defined", __func__, NULL);
164 for (i = 0; i < n; i++) {
166 if ((pix =
pixRead(str)) == NULL) {
167 L_WARNING(
"pix not read from file %s\n", __func__, str);
195 return (
PIX *)ERROR_PTR(
"filename not defined", __func__, NULL);
198 L_ERROR(
"image file not found: %s\n", __func__, filename);
204 return (
PIX *)ERROR_PTR(
"pix not read", __func__, NULL);
231 return (
PIX *)ERROR_PTR(
"filename not defined", __func__, NULL);
234 return (
PIX *)ERROR_PTR(
"image file not found", __func__, NULL);
239 return (
PIX *)ERROR_PTR(
"image not returned", __func__, NULL);
281 return (
PIX *)ERROR_PTR(
"sa not defined", __func__, NULL);
283 if (index < 0 || index >= n)
284 return (
PIX *)ERROR_PTR(
"index out of bounds", __func__, NULL);
287 if (fname[0] ==
'\0')
290 if ((pix =
pixRead(fname)) == NULL) {
291 L_ERROR(
"pix not read from file %s\n", __func__, fname);
315 l_int32 format, ret, valid;
321 return (
PIX *)ERROR_PTR(
"stream not defined", __func__, NULL);
329 return (
PIX *)ERROR_PTR(
"bmp: no pix returned", __func__, NULL);
334 return (
PIX *)ERROR_PTR(
"jpeg: no pix returned", __func__, NULL);
335 ret = fgetJpegComment(fp, &comment);
343 return (
PIX *)ERROR_PTR(
"png: no pix returned", __func__, NULL);
347 case IFF_TIFF_PACKBITS:
355 return (
PIX *)ERROR_PTR(
"tiff: no pix returned", __func__, NULL);
360 return (
PIX *)ERROR_PTR(
"pnm: no pix returned", __func__, NULL);
364 if ((pix = pixReadStreamGif(fp)) == NULL)
365 return (
PIX *)ERROR_PTR(
"gif: no pix returned", __func__, NULL);
369 if ((pix = pixReadStreamJp2k(fp, 1, NULL, 0, 0)) == NULL)
370 return (
PIX *)ERROR_PTR(
"jp2: no pix returned", __func__, NULL);
374 if ((pix = pixReadStreamWebP(fp)) == NULL)
375 return (
PIX *)ERROR_PTR(
"webp: no pix returned", __func__, NULL);
379 L_ERROR(
"PostScript reading is not supported\n", __func__);
383 L_ERROR(
"Pdf reading is not supported\n", __func__);
388 return (
PIX *)ERROR_PTR(
"spix: no pix returned", __func__, NULL);
392 return (
PIX *)ERROR_PTR(
"Unknown format: no pix returned",
398 pixSetInputFormat(pix, format);
399 if ((cmap = pixGetColormap(pix))) {
403 return (
PIX *)ERROR_PTR(
"invalid colormap", __func__, NULL);
442 l_int32 format, ret, w, h, d, bps, spp, iscmap;
451 if (piscmap) *piscmap = 0;
452 if (pformat) *pformat = 0;
455 return ERROR_INT(
"filename not defined", __func__, 1);
458 return ERROR_INT(
"image file not found", __func__, 1);
465 if ((pix =
pixRead(filename)) == NULL)
466 return ERROR_INT(
"bmp: pix not read", __func__, 1);
468 if (pixGetColormap(pix))
471 bps = (d == 32) ? 8 : d;
472 spp = (d == 32) ? 3 : 1;
479 return ERROR_INT(
"jpeg: no header info returned", __func__, 1);
485 return ERROR_INT(
"png: no header info returned", __func__, 1);
489 case IFF_TIFF_PACKBITS:
497 ret =
readHeaderTiff(filename, 0, &w, &h, &bps, &spp, NULL, &iscmap,
500 return ERROR_INT(
"tiff: no header info returned", __func__, 1);
504 ret =
readHeaderPnm(filename, &w, &h, &d, &type, &bps, &spp);
506 return ERROR_INT(
"pnm: no header info returned", __func__, 1);
510 if ((pix =
pixRead(filename)) == NULL)
511 return ERROR_INT(
"gif: pix not read", __func__, 1);
524 if (readHeaderWebP(filename, &w, &h, &spp))
525 return ERROR_INT(
"webp: no header info returned", __func__, 1);
530 if (pformat) *pformat = format;
531 return ERROR_INT(
"PostScript reading is not supported\n", __func__, 1);
534 if (pformat) *pformat = format;
535 return ERROR_INT(
"Pdf reading is not supported\n", __func__, 1);
540 return ERROR_INT(
"spix: no header info returned", __func__, 1);
544 L_ERROR(
"unknown format in file %s\n", __func__, filename);
551 if (pbps) *pbps = bps;
552 if (pspp) *pspp = spp;
553 if (piscmap) *piscmap = iscmap;
554 if (pformat) *pformat = format;
577 return ERROR_INT(
"&format not defined", __func__, 1);
578 *pformat = IFF_UNKNOWN;
580 return ERROR_INT(
"filename not defined", __func__, 1);
583 return ERROR_INT(
"image file not found", __func__, 1);
606 l_uint8 firstbytes[13];
610 return ERROR_INT(
"&format not defined", __func__, 1);
611 *pformat = IFF_UNKNOWN;
613 return ERROR_INT(
"stream not defined", __func__, 1);
617 return ERROR_INT(
"truncated file", __func__, 1);
619 if (fread(&firstbytes, 1, 12, fp) != 12)
620 return ERROR_INT(
"failed to read first 12 bytes of file", __func__, 1);
625 if (format == IFF_TIFF) {
630 if (format == IFF_UNKNOWN)
659 return ERROR_INT(
"&format not defined", __func__, 1);
660 *pformat = IFF_UNKNOWN;
662 return ERROR_INT(
"byte buffer not defined", __func__, 0);
665 ((
char *)(&twobytepw))[0] = buf[0];
666 ((
char *)(&twobytepw))[1] = buf[1];
668 if (convertOnBigEnd16(twobytepw) ==
BMP_ID) {
679 if ((buf[0] ==
'P' && buf[1] ==
'4') ||
680 (buf[0] ==
'P' && buf[1] ==
'1')) {
685 if ((buf[0] ==
'P' && buf[1] ==
'5') ||
686 (buf[0] ==
'P' && buf[1] ==
'2')) {
691 if ((buf[0] ==
'P' && buf[1] ==
'6') ||
692 (buf[0] ==
'P' && buf[1] ==
'3')) {
697 if (buf[0] ==
'P' && buf[1] ==
'7') {
713 if (buf[0] == 0xff && buf[1] == 0xd8) {
714 *pformat = IFF_JFIF_JPEG;
720 if (buf[0] == 137 && buf[1] == 80 && buf[2] == 78 && buf[3] == 71 &&
721 buf[4] == 13 && buf[5] == 10 && buf[6] == 26 && buf[7] == 10) {
727 if (buf[0] ==
'G' && buf[1] ==
'I' && buf[2] ==
'F' && buf[3] ==
'8' &&
728 (buf[4] ==
'7' || buf[4] ==
'9') && buf[5] ==
'a') {
734 if (memcmp(buf, JP2K_CODESTREAM, 4) == 0 ||
735 memcmp(buf, JP2K_IMAGE_DATA, 12) == 0) {
741 if (buf[0] ==
'R' && buf[1] ==
'I' && buf[2] ==
'F' && buf[3] ==
'F' &&
742 buf[8] ==
'W' && buf[9] ==
'E' && buf[10] ==
'B' && buf[11] ==
'P') {
748 if (buf[0] ==
'%' && buf[1] ==
'!' && buf[2] ==
'P' && buf[3] ==
'S' &&
749 buf[4] ==
'-' && buf[5] ==
'A' && buf[6] ==
'd' && buf[7] ==
'o' &&
750 buf[8] ==
'b' && buf[9] ==
'e') {
756 if (buf[0] ==
'%' && buf[1] ==
'P' && buf[2] ==
'D' && buf[3] ==
'F' &&
757 buf[4] ==
'-' && buf[5] ==
'1') {
763 if (buf[0] ==
's' && buf[1] ==
'p' && buf[2] ==
'i' && buf[3] ==
'x') {
785 return ERROR_INT(
"stream not defined", __func__, 0);
788 if (format == IFF_TIFF || format == IFF_TIFF_PACKBITS ||
789 format == IFF_TIFF_RLE || format == IFF_TIFF_G3 ||
790 format == IFF_TIFF_G4 || format == IFF_TIFF_LZW ||
791 format == IFF_TIFF_ZIP || format == IFF_TIFF_JPEG)
825 l_int32 format, valid;
830 return (
PIX *)ERROR_PTR(
"data not defined", __func__, NULL);
832 return (
PIX *)ERROR_PTR(
"size < 12", __func__, NULL);
840 return (
PIX *)ERROR_PTR(
"bmp: no pix returned", __func__, NULL);
845 return (
PIX *)ERROR_PTR(
"jpeg: no pix returned", __func__, NULL);
850 return (
PIX *)ERROR_PTR(
"png: no pix returned", __func__, NULL);
854 case IFF_TIFF_PACKBITS:
862 return (
PIX *)ERROR_PTR(
"tiff: no pix returned", __func__, NULL);
867 return (
PIX *)ERROR_PTR(
"pnm: no pix returned", __func__, NULL);
871 if ((pix = pixReadMemGif(data, size)) == NULL)
872 return (
PIX *)ERROR_PTR(
"gif: no pix returned", __func__, NULL);
876 if ((pix = pixReadMemJp2k(data, size, 1, NULL, 0, 0)) == NULL)
877 return (
PIX *)ERROR_PTR(
"jp2k: no pix returned", __func__, NULL);
881 if ((pix = pixReadMemWebP(data, size)) == NULL)
882 return (
PIX *)ERROR_PTR(
"webp: no pix returned", __func__, NULL);
886 L_ERROR(
"PostScript reading is not supported\n", __func__);
890 L_ERROR(
"Pdf reading is not supported\n", __func__);
895 return (
PIX *)ERROR_PTR(
"spix: no pix returned", __func__, NULL);
899 return (
PIX *)ERROR_PTR(
"Unknown format: no pix returned",
908 if (format == IFF_TIFF && pixGetDepth(pix) == 1)
909 format = IFF_TIFF_G4;
910 pixSetInputFormat(pix, format);
911 if ((cmap = pixGetColormap(pix))) {
915 return (
PIX *)ERROR_PTR(
"invalid colormap", __func__, NULL);
959 l_int32 format, ret, w, h, d, bps, spp, iscmap;
967 if (piscmap) *piscmap = 0;
968 if (pformat) *pformat = 0;
971 return ERROR_INT(
"data not defined", __func__, 1);
973 return ERROR_INT(
"size < 12", __func__, 1);
981 return ERROR_INT(
"bmp: pix not read", __func__, 1);
984 bps = (d == 32) ? 8 : d;
985 spp = (d == 32) ? 3 : 1;
992 return ERROR_INT(
"jpeg: no header info returned", __func__, 1);
998 return ERROR_INT(
"png: no header info returned", __func__, 1);
1002 case IFF_TIFF_PACKBITS:
1011 NULL, &iscmap, &format);
1013 return ERROR_INT(
"tiff: no header info returned", __func__, 1);
1019 return ERROR_INT(
"pnm: no header info returned", __func__, 1);
1023 if ((pix = pixReadMemGif(data, size)) == NULL)
1024 return ERROR_INT(
"gif: pix not read", __func__, 1);
1038 ret = readHeaderMemWebP(data, size, &w, &h, &spp);
1042 if (pformat) *pformat = format;
1043 return ERROR_INT(
"PostScript reading is not supported\n", __func__, 1);
1046 if (pformat) *pformat = format;
1047 return ERROR_INT(
"Pdf reading is not supported\n", __func__, 1);
1053 return ERROR_INT(
"pnm: no header info returned", __func__, 1);
1057 return ERROR_INT(
"unknown format; no data returned", __func__, 1);
1063 if (pbps) *pbps = bps;
1064 if (pspp) *pspp = spp;
1065 if (piscmap) *piscmap = iscmap;
1066 if (pformat) *pformat = format;
1074 extern const char *ImageFileFormatExtensions[];
1100 l_int32 w, h, d, wpl, count, npages, color;
1101 l_int32 format, bps, spp, iscmap, xres, yres, transparency;
1107 return ERROR_INT(
"filename not defined", __func__, 1);
1109 return ERROR_INT(
"stream not defined", __func__, 1);
1112 if (
pixReadHeader(filename, &format, &w, &h, &bps, &spp, &iscmap)) {
1113 L_ERROR(
"failure to read header of %s\n", __func__, filename);
1116 fprintf(fpout,
"===============================================\n"
1117 "Reading the header:\n");
1118 fprintf(fpout,
" input image format type: %s\n",
1119 ImageFileFormatExtensions[format]);
1120 fprintf(fpout,
" w = %d, h = %d, bps = %d, spp = %d, iscmap = %d\n",
1121 w, h, bps, spp, iscmap);
1124 if (format == IFF_JP2) {
1126 fgetJp2kResolution(fpin, &xres, &yres);
1128 fprintf(fpout,
" xres = %d, yres = %d\n", xres, yres);
1129 }
else if (format == IFF_PNG) {
1131 fgetPngResolution(fpin, &xres, &yres);
1133 fprintf(fpout,
" xres = %d, yres = %d\n", xres, yres);
1136 fgetPngColormapInfo(fpin, &cmap, &transparency);
1139 fprintf(fpout,
" colormap has transparency\n");
1141 fprintf(fpout,
" colormap does not have transparency\n");
1145 }
else if (format == IFF_JFIF_JPEG) {
1147 fgetJpegResolution(fpin, &xres, &yres);
1149 fprintf(fpout,
" xres = %d, yres = %d\n", xres, yres);
1157 fprintf(fpout,
"===============================================\n"
1158 "Reading the full image:\n");
1161 if (format == IFF_PNG && bps == 16)
1164 if ((pix =
pixRead(filename)) == NULL) {
1165 L_ERROR(
"failure to read full image of %s\n", __func__, filename);
1169 format = pixGetInputFormat(pix);
1171 wpl = pixGetWpl(pix);
1172 spp = pixGetSpp(pix);
1173 fprintf(fpout,
" input image format type: %s\n",
1174 ImageFileFormatExtensions[format]);
1175 fprintf(fpout,
" w = %d, h = %d, d = %d, spp = %d, wpl = %d\n",
1177 fprintf(fpout,
" xres = %d, yres = %d\n",
1178 pixGetXRes(pix), pixGetYRes(pix));
1182 fprintf(fpout,
" text: %s\n", text);
1184 cmap = pixGetColormap(pix);
1188 fprintf(fpout,
" colormap exists and has color values:");
1190 fprintf(fpout,
" colormap exists and has only gray values:");
1194 fprintf(fpout,
" colormap does not exist\n");
1196 if (format == IFF_TIFF || format == IFF_TIFF_G4 ||
1197 format == IFF_TIFF_G3 || format == IFF_TIFF_PACKBITS) {
1198 fprintf(fpout,
" Tiff header information:\n");
1203 fprintf(fpout,
" One page in file\n");
1205 fprintf(fpout,
" %d pages in file\n", npages);
1212 fprintf(fpout,
" 1 bpp: foreground pixel fraction ON/Total = %g\n",
1213 (l_float32)count / (l_float32)(w * h));
1215 fprintf(fpout,
"===============================================\n");
1221 if (pixGetSpp(pix) == 4) {
1223 pixDisplay(pixt, 100, 100);
1227 if (format == IFF_PNG && bps == 16)
1263 l_int32 w, h, d, depth, equal, problems;
1266 PIX *pixs, *pixc, *pix1, *pix2;
1270 return ERROR_INT(
"filename not defined", __func__, 1);
1273 if ((pix1 =
pixRead(filename)) == NULL)
1274 return ERROR_INT(
"pix1 not made", __func__, 1);
1276 if (w > 250 && h > 250) {
1277 box =
boxCreate(w / 2 - 125, h / 2 - 125, 250, 250);
1296 if (pixGetSpp(pixc) == 4)
1298 cmap = pixGetColormap(pixc);
1299 d = pixGetDepth(pixc);
1310 if (d == 1 || d == 8) {
1311 L_INFO(
"write/read bmp\n", __func__);
1312 pixWrite(FILE_BMP, pixc, IFF_BMP);
1320 L_INFO(
" **** bad bmp image: d = %d ****\n", __func__, d);
1327 if (d == 2 || d == 4 || d == 32) {
1328 L_INFO(
"write/read bmp\n", __func__);
1329 pixWrite(FILE_BMP, pixc, IFF_BMP);
1333 L_INFO(
" **** bad bmp image: d = %d ****\n", __func__, d);
1344 L_INFO(
"write/read png\n", __func__);
1345 pixWrite(FILE_PNG, pixc, IFF_PNG);
1349 L_INFO(
" **** bad png image: d = %d ****\n", __func__, d);
1368 L_INFO(
"write/read uncompressed tiff\n", __func__);
1369 pixWrite(FILE_TIFF, pixc, IFF_TIFF);
1373 L_INFO(
" **** bad tiff uncompressed image: d = %d ****\n",
1380 L_INFO(
"write/read lzw compressed tiff\n", __func__);
1381 pixWrite(FILE_LZW, pixc, IFF_TIFF_LZW);
1385 L_INFO(
" **** bad tiff lzw compressed image: d = %d ****\n",
1392 L_INFO(
"write/read zip compressed tiff\n", __func__);
1393 pixWrite(FILE_ZIP, pixc, IFF_TIFF_ZIP);
1397 L_INFO(
" **** bad tiff zip compressed image: d = %d ****\n",
1404 if (d == 8 || d == 32) {
1406 L_INFO(
"write/read jpeg compressed tiff\n", __func__);
1407 if (d == 8 && pixGetColormap(pixc)) {
1409 pixWrite(FILE_TIFF_JPEG, pixc1, IFF_TIFF_JPEG);
1410 if ((pix1 =
pixRead(FILE_TIFF_JPEG)) == NULL) {
1411 L_INFO(
" did not read FILE_TIFF_JPEG\n", __func__);
1416 pixWrite(FILE_TIFF_JPEG, pixc, IFF_TIFF_JPEG);
1417 pix1 =
pixRead(FILE_TIFF_JPEG);
1422 pixCompareRGB(pix1, pixc, L_COMPARE_ABS_DIFF, 0, NULL, &diff,
1426 L_INFO(
" **** bad tiff jpeg compressed image: "
1427 "d = %d, diff = %5.2f ****\n", __func__, d, diff);
1436 L_INFO(
"write/read g4 compressed tiff\n", __func__);
1437 pixWrite(FILE_G4, pixc, IFF_TIFF_G4);
1441 L_INFO(
" **** bad tiff g4 image ****\n", __func__);
1446 L_INFO(
"write/read g3 compressed tiff\n", __func__);
1447 pixWrite(FILE_G3, pixc, IFF_TIFF_G3);
1451 L_INFO(
" **** bad tiff g3 image ****\n", __func__);
1456 L_INFO(
"write/read rle compressed tiff\n", __func__);
1457 pixWrite(FILE_RLE, pixc, IFF_TIFF_RLE);
1461 L_INFO(
" **** bad tiff rle image: d = %d ****\n", __func__, d);
1466 L_INFO(
"write/read packbits compressed tiff\n", __func__);
1467 pixWrite(FILE_PB, pixc, IFF_TIFF_PACKBITS);
1471 L_INFO(
" **** bad tiff packbits image: d = %d ****\n",
1485 L_INFO(
"write/read pnm\n", __func__);
1486 pixWrite(FILE_PNM, pixc, IFF_PNM);
1494 L_INFO(
" **** bad pnm image: d = %d ****\n", __func__, d);
1503 if (d != 8 || !cmap)
1507 L_INFO(
"write/read gif\n", __func__);
1508 pixWrite(FILE_GIF, pix1, IFF_GIF);
1512 L_INFO(
" **** bad gif image: d = %d ****\n", __func__, d);
1526 depth = pixGetDepth(pix1);
1527 L_INFO(
"write/read jpeg\n", __func__);
1528 pixWrite(FILE_JPG, pix1, IFF_JFIF_JPEG);
1534 pixCompareRGB(pix1, pix2, L_COMPARE_ABS_DIFF, 0, NULL, &diff,
1538 L_INFO(
" **** bad jpeg image: d = %d, diff = %5.2f ****\n",
1539 __func__, depth, diff);
1549 if (cmap || d <= 16)
1553 depth = pixGetDepth(pix1);
1554 L_INFO(
"write/read webp\n", __func__);
1555 pixWrite(FILE_WEBP, pix1, IFF_WEBP);
1557 pixCompareRGB(pix1, pix2, L_COMPARE_ABS_DIFF, 0, NULL, &diff, NULL, NULL);
1559 L_INFO(
" **** bad webp image: d = %d, diff = %5.2f ****\n",
1560 __func__, depth, diff);
1574 depth = pixGetDepth(pix1);
1575 L_INFO(
"write/read jp2k\n", __func__);
1576 pixWrite(FILE_JP2K, pix1, IFF_JP2);
1582 pixCompareRGB(pix1, pix2, L_COMPARE_ABS_DIFF, 0, NULL, &diff,
1587 L_INFO(
" **** bad jp2k image: d = %d, diff = %5.2f ****\n",
1588 __func__, depth, diff);
1595 if (problems == FALSE)
1596 L_INFO(
"All formats read and written OK!\n", __func__);
PIX * pixReadMemBmp(const l_uint8 *cdata, size_t size)
pixReadMemBmp()
PIX * pixReadStreamBmp(FILE *fp)
pixReadStreamBmp()
void boxDestroy(BOX **pbox)
boxDestroy()
BOX * boxCreate(l_int32 x, l_int32 y, l_int32 w, l_int32 h)
boxCreate()
void pixcmapDestroy(PIXCMAP **pcmap)
pixcmapDestroy()
l_ok pixcmapHasColor(PIXCMAP *cmap, l_int32 *pcolor)
pixcmapHasColor()
l_ok pixcmapIsValid(const PIXCMAP *cmap, PIX *pix, l_int32 *pvalid)
pixcmapIsValid()
l_ok pixcmapWriteStream(FILE *fp, const PIXCMAP *cmap)
pixcmapWriteStream()
l_ok pixCompareRGB(PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff)
pixCompareRGB()
l_ok pixEqual(PIX *pix1, PIX *pix2, l_int32 *psame)
pixEqual()
l_ok pixCompareGray(PIX *pix1, PIX *pix2, l_int32 comptype, l_int32 plottype, l_int32 *psame, l_float32 *pdiff, l_float32 *prmsdiff, PIX **ppixdiff)
pixCompareGray()
PIX * pixReadStreamJpeg(FILE *fp, l_int32 cmapflag, l_int32 reduction, l_int32 *pnwarn, l_int32 hint)
pixReadStreamJpeg()
PIX * pixReadMemJpeg(const l_uint8 *data, size_t size, l_int32 cmflag, l_int32 reduction, l_int32 *pnwarn, l_int32 hint)
pixReadMemJpeg()
l_ok readHeaderMemJpeg(const l_uint8 *data, size_t size, l_int32 *pw, l_int32 *ph, l_int32 *pspp, l_int32 *pycck, l_int32 *pcmyk)
readHeaderMemJpeg()
l_ok readHeaderJpeg(const char *filename, l_int32 *pw, l_int32 *ph, l_int32 *pspp, l_int32 *pycck, l_int32 *pcmyk)
readHeaderJpeg()
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()
PIX * pixClone(PIX *pixs)
pixClone()
PIX * pixDisplayLayersRGBA(PIX *pixs, l_uint32 val, l_int32 maxw)
pixDisplayLayersRGBA()
l_ok pixSetPadBits(PIX *pix, l_int32 val)
pixSetPadBits()
l_ok pixCountPixels(PIX *pixs, l_int32 *pcount, l_int32 *tab8)
pixCountPixels()
PIX * pixClipRectangle(PIX *pixs, BOX *box, BOX **pboxc)
pixClipRectangle()
@ REMOVE_CMAP_BASED_ON_SRC
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
PIX * pixConvertTo32(PIX *pixs)
pixConvertTo32()
l_ok readHeaderPng(const char *filename, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap)
readHeaderPng()
PIX * pixReadMemPng(const l_uint8 *filedata, size_t filesize)
pixReadMemPng()
l_ok readHeaderMemPng(const l_uint8 *data, size_t size, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap)
readHeaderMemPng()
void l_pngSetReadStrip16To8(l_int32 flag)
l_pngSetReadStrip16To8()
PIX * pixReadStreamPng(FILE *fp)
pixReadStreamPng()
PIX * pixReadMemPnm(const l_uint8 *data, size_t size)
pixReadMemPnm()
PIX * pixReadStreamPnm(FILE *fp)
pixReadStreamPnm()
l_ok readHeaderPnm(const char *filename, l_int32 *pw, l_int32 *ph, l_int32 *pd, l_int32 *ptype, l_int32 *pbps, l_int32 *pspp)
readHeaderPnm()
l_ok readHeaderMemPnm(const l_uint8 *data, size_t size, l_int32 *pw, l_int32 *ph, l_int32 *pd, l_int32 *ptype, l_int32 *pbps, l_int32 *pspp)
readHeaderMemPnm()
PIXA * pixaReadFilesSA(SARRAY *sa)
pixaReadFilesSA()
l_ok pixReadHeader(const char *filename, l_int32 *pformat, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap)
pixReadHeader()
l_ok findFileFormat(const char *filename, l_int32 *pformat)
findFileFormat()
PIX * pixReadWithHint(const char *filename, l_int32 hint)
pixReadWithHint()
l_ok writeImageFileInfo(const char *filename, FILE *fpout, l_int32 headeronly)
writeImageFileInfo()
l_ok findFileFormatStream(FILE *fp, l_int32 *pformat)
findFileFormatStream()
PIXA * pixaReadFiles(const char *dirname, const char *substr)
pixaReadFiles()
l_ok findFileFormatBuffer(const l_uint8 *buf, l_int32 *pformat)
findFileFormatBuffer()
PIX * pixReadMem(const l_uint8 *data, size_t size)
pixReadMem()
PIX * pixRead(const char *filename)
pixRead()
PIX * pixReadIndexed(SARRAY *sa, l_int32 index)
pixReadIndexed()
l_ok ioFormatTest(const char *filename)
ioFormatTest()
l_int32 fileFormatIsTiff(FILE *fp)
fileFormatIsTiff()
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()
PIX * pixReadStream(FILE *fp, l_int32 hint)
pixReadStream()
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 * pixReadStreamSpix(FILE *fp)
pixReadStreamSpix()
PIX * pixReadMemSpix(const l_uint8 *data, size_t size)
pixReadMemSpix()
l_ok readHeaderSpix(const char *filename, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap)
readHeaderSpix()
l_ok sreadHeaderSpix(const l_uint32 *data, size_t size, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap)
sreadHeaderSpix()
l_ok fprintTiffInfo(FILE *fpout, const char *tiffile)
fprintTiffInfo()
l_ok readHeaderTiff(const char *filename, l_int32 n, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *pres, l_int32 *pcmap, l_int32 *pformat)
readHeaderTiff()
l_ok readHeaderMemTiff(const l_uint8 *cdata, size_t size, l_int32 n, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *pres, l_int32 *pcmap, l_int32 *pformat)
readHeaderMemTiff()
l_ok findTiffCompression(FILE *fp, l_int32 *pcomptype)
findTiffCompression()
PIX * pixReadMemTiff(const l_uint8 *cdata, size_t size, l_int32 n)
pixReadMemTiff()
PIX * pixReadStreamTiff(FILE *fp, l_int32 n)
pixReadStreamTiff()
l_ok tiffGetCount(FILE *fp, l_int32 *pn)
tiffGetCount()
void lept_stderr(const char *fmt,...)
lept_stderr()
l_ok lept_fclose(FILE *fp)
lept_fclose()
size_t fnbytesInFile(FILE *fp)
fnbytesInFile()
FILE * lept_fopen(const char *filename, const char *mode)
lept_fopen()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
FILE * fopenReadStream(const char *filename)
fopenReadStream()