Leptonica 1.68
C Image Processing Library
|
00001 /*====================================================================* 00002 - Copyright (C) 2001 Leptonica. All rights reserved. 00003 - This software is distributed in the hope that it will be 00004 - useful, but with NO WARRANTY OF ANY KIND. 00005 - No author or distributor accepts responsibility to anyone for the 00006 - consequences of using this software, or for whether it serves any 00007 - particular purpose or works at all, unless he or she says so in 00008 - writing. Everyone is granted permission to copy, modify and 00009 - redistribute this source code, for commercial or non-commercial 00010 - purposes, with the following restrictions: (1) the origin of this 00011 - source code must not be misrepresented; (2) modified versions must 00012 - be plainly marked as such; and (3) this notice may not be removed 00013 - or altered from any source or modified source distribution. 00014 *====================================================================*/ 00015 00016 /* 00017 * selio_reg.c 00018 * 00019 * Runs a number of tests on reading and writing of Sels 00020 * 00021 */ 00022 00023 #include <string.h> 00024 #include "allheaders.h" 00025 00026 static const char *textsel1 = "x oo " 00027 "x oOo " 00028 "x o " 00029 "x " 00030 "xxxxxx"; 00031 static const char *textsel2 = " oo x" 00032 " oOo x" 00033 " o x" 00034 " x" 00035 "xxxxxx"; 00036 static const char *textsel3 = "xxxxxx" 00037 "x " 00038 "x o " 00039 "x oOo " 00040 "x oo "; 00041 static const char *textsel4 = "xxxxxx" 00042 " x" 00043 " o x" 00044 " oOo x" 00045 " oo x"; 00046 00047 00048 main(int argc, 00049 char **argv) 00050 { 00051 PIX *pix; 00052 SEL *sel; 00053 SELA *sela1, *sela2; 00054 L_REGPARAMS *rp; 00055 00056 if (regTestSetup(argc, argv, &rp)) 00057 return 1; 00058 00059 /* selaRead() / selaWrite() */ 00060 sela1 = selaAddBasic(NULL); 00061 selaWrite("/tmp/sel.0.sela", sela1); 00062 regTestCheckFile(rp, "/tmp/sel.0.sela"); /* 0 */ 00063 sela2 = selaRead("/tmp/sel.0.sela"); 00064 selaWrite("/tmp/sel.1.sela", sela2); 00065 regTestCheckFile(rp, "/tmp/sel.1.sela"); /* 1 */ 00066 regTestCompareFiles(rp, 0, 1); /* 2 */ 00067 selaDestroy(&sela1); 00068 selaDestroy(&sela2); 00069 00070 /* Create from file and display result */ 00071 sela1 = selaCreateFromFile("flipsels.txt"); 00072 pix = selaDisplayInPix(sela1, 31, 3, 15, 4); 00073 regTestWritePixAndCheck(rp, pix, IFF_PNG); /* 3 */ 00074 pixDisplayWithTitle(pix, 100, 100, NULL, rp->display); 00075 selaWrite("/tmp/sel.3.sela", sela1); 00076 regTestCheckFile(rp, "/tmp/sel.3.sela"); /* 4 */ 00077 pixDestroy(&pix); 00078 selaDestroy(&sela1); 00079 00080 /* Create the same set of Sels from compiled strings and compare */ 00081 sela2 = selaCreate(4); 00082 sel = selCreateFromString(textsel1, 5, 6, "textsel1"); 00083 selaAddSel(sela2, sel, NULL, 0); 00084 sel = selCreateFromString(textsel2, 5, 6, "textsel2"); 00085 selaAddSel(sela2, sel, NULL, 0); 00086 sel = selCreateFromString(textsel3, 5, 6, "textsel3"); 00087 selaAddSel(sela2, sel, NULL, 0); 00088 sel = selCreateFromString(textsel4, 5, 6, "textsel4"); 00089 selaAddSel(sela2, sel, NULL, 0); 00090 selaWrite("/tmp/sel.4.sela", sela2); 00091 regTestCheckFile(rp, "/tmp/sel.4.sela"); /* 5 */ 00092 regTestCompareFiles(rp, 4, 5); /* 6 */ 00093 selaDestroy(&sela2); 00094 00095 regTestCleanup(rp); 00096 return 0; 00097 } 00098