int main(int argc, char **argv) { l_int32 success; PIX *pix; PIXA *pixa; L_REGPARAMS *rp; #if !HAVE_LIBGIF && !HAVE_LIBUNGIF fprintf(stderr, "gifio is not enabled\n" "libgif or libungif are required for gifio_reg\n" "See environ.h: #define HAVE_LIBGIF or HAVE_LIBUNGIF 1\n" "See prog/Makefile: link in -lgif or -lungif\n\n"); return 0; #endif /* abort */ if (regTestSetup(argc, argv, &rp)) return 1; /* Set up for display output */ pixa = (rp->display) ? pixaCreate(0) : NULL; lept_rmdir("lept/gif"); lept_mkdir("lept/gif"); /* ------------ Part 1: Test lossless r/w to file ------------*/ test_gif(FILE_1BPP, pixa, rp); test_gif(FILE_2BPP, pixa, rp); test_gif(FILE_4BPP, pixa, rp); test_gif(FILE_8BPP_1, pixa, rp); test_gif(FILE_8BPP_2, pixa, rp); test_gif(FILE_8BPP_3, pixa, rp); test_gif(FILE_16BPP, pixa, rp); test_gif(FILE_32BPP, pixa, rp); if (rp->success) { fprintf(stderr, "\n ****** Success on lossless r/w to file *****\n\n"); } else { fprintf(stderr, "\n ******* Failure on at least one r/w to file ******\n\n"); } if (rp->display) { pix = pixaDisplayTiledAndScaled(pixa, 32, 450, 3, 0, 20, 2); pixWrite("/tmp/lept/gif/giftest.jpg", pix, IFF_JFIF_JPEG); pixDisplay(pix, 100, 100); pixDestroy(&pix); pixaDestroy(&pixa); } /* ------------ Part 2: Test lossless r/w to memory ------------ */ success = TRUE; if (test_mem_gif(FILE_1BPP, 0)) success = FALSE; if (test_mem_gif(FILE_2BPP, 1)) success = FALSE; if (test_mem_gif(FILE_4BPP, 2)) success = FALSE; if (test_mem_gif(FILE_8BPP_1, 3)) success = FALSE; if (test_mem_gif(FILE_8BPP_2, 4)) success = FALSE; if (test_mem_gif(FILE_8BPP_3, 5)) success = FALSE; if (test_mem_gif(FILE_16BPP, 6)) success = FALSE; if (test_mem_gif(FILE_32BPP, 7)) success = FALSE; if (success) { fprintf(stderr, "\n ****** Success on lossless r/w to memory *****\n\n"); } else { fprintf(stderr, "\n ******* Failure on at least one r/w to memory ******\n\n"); } /* Success only if all tests are passed */ if (rp->success == TRUE) rp->success = success; return regTestCleanup(rp); }
int main(int argc, char **argv) { l_int32 success; L_REGPARAMS *rp; #if !HAVE_LIBGIF && !HAVE_LIBUNGIF fprintf(stderr, "gifio is not enabled\n" "libgif or libungif are required for gifio_reg\n" "See environ.h: #define HAVE_LIBGIF or HAVE_LIBUNGIF 1\n" "See prog/Makefile: link in -lgif or -lungif\n\n"); return 0; #endif /* abort */ if (regTestSetup(argc, argv, &rp)) return 1; pixDisplayWrite(NULL, -1); lept_rmdir("lept/gif"); lept_mkdir("lept/gif"); /* ------------ Part 1: Test lossless r/w to file ------------*/ test_gif(FILE_1BPP, rp); test_gif(FILE_2BPP, rp); test_gif(FILE_4BPP, rp); test_gif(FILE_8BPP_1, rp); test_gif(FILE_8BPP_2, rp); test_gif(FILE_8BPP_3, rp); test_gif(FILE_16BPP, rp); test_gif(FILE_32BPP, rp); if (rp->success) { fprintf(stderr, "\n ****** Success on lossless r/w to file *****\n\n"); } else { fprintf(stderr, "\n ******* Failure on at least one r/w to file ******\n\n"); } if (rp->display) { fprintf(stderr, "Writing to: /tmp/lept/gif/giftest.pdf\n"); pixDisplayMultiple(150, 1.0, "/tmp/lept/gif/giftest.pdf"); } /* ------------ Part 2: Test lossless r/w to memory ------------ */ success = TRUE; #if HAVE_FMEMOPEN pixDisplayWrite(NULL, -1); if (test_mem_gif(FILE_1BPP, 0)) success = FALSE; if (test_mem_gif(FILE_2BPP, 1)) success = FALSE; if (test_mem_gif(FILE_4BPP, 2)) success = FALSE; if (test_mem_gif(FILE_8BPP_1, 3)) success = FALSE; if (test_mem_gif(FILE_8BPP_2, 4)) success = FALSE; if (test_mem_gif(FILE_8BPP_3, 5)) success = FALSE; if (test_mem_gif(FILE_16BPP, 6)) success = FALSE; if (test_mem_gif(FILE_32BPP, 7)) success = FALSE; if (success) { fprintf(stderr, "\n ****** Success on lossless r/w to memory *****\n\n"); } else { fprintf(stderr, "\n ******* Failure on at least one r/w to memory ******\n\n"); } #else fprintf(stderr, "\n ***** r/w to memory not enabled *****\n\n"); #endif /* HAVE_FMEMOPEN */ /* Success only if all tests are passed */ if (rp->success == TRUE) rp->success = success; return regTestCleanup(rp); }