1 /*====================================================================*
2  -  Copyright (C) 2001 Leptonica.  All rights reserved.
3  -
4  -  Redistribution and use in source and binary forms, with or without
5  -  modification, are permitted provided that the following conditions
6  -  are met:
7  -  1. Redistributions of source code must retain the above copyright
8  -     notice, this list of conditions and the following disclaimer.
9  -  2. Redistributions in binary form must reproduce the above
10  -     copyright notice, this list of conditions and the following
11  -     disclaimer in the documentation and/or other materials
12  -     provided with the distribution.
13  -
14  -  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  -  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  -  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  -  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ANY
18  -  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  -  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  -  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  -  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  -  OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  -  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  -  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *====================================================================*/
26 
27 /*
28  * livre_orient.c
29  *
30  *    This generates an image of the set of 4 HMT Sels that are
31  *    used for counting ascenders and descenders to detect
32  *    text orientation.
33  */
34 
35 #include "allheaders.h"
36 
37 static const char *textsel1 = "x  oo "
38                               "x oOo "
39                               "x  o  "
40                               "x     "
41                               "xxxxxx";
42 
43 static const char *textsel2 = " oo  x"
44                               " oOo x"
45                               "  o  x"
46                               "     x"
47                               "xxxxxx";
48 
49 static const char *textsel3 = "xxxxxx"
50                               "x     "
51                               "x  o  "
52                               "x oOo "
53                               "x  oo ";
54 
55 static const char *textsel4 = "xxxxxx"
56                               "     x"
57                               "  o  x"
58                               " oOo x"
59                               " oo  x";
60 
main(int argc,char ** argv)61 int main(int    argc,
62          char **argv)
63 {
64 PIX   *pix1;
65 SEL   *sel1, *sel2, *sel3, *sel4;
66 SELA  *sela;
67 
68     setLeptDebugOK(1);
69     lept_mkdir("lept/livre");
70 
71     sel1 = selCreateFromString(textsel1, 5, 6, NULL);
72     sel2 = selCreateFromString(textsel2, 5, 6, NULL);
73     sel3 = selCreateFromString(textsel3, 5, 6, NULL);
74     sel4 = selCreateFromString(textsel4, 5, 6, NULL);
75 
76     sela = selaCreate(4);
77     selaAddSel(sela, sel1, "textsel1", L_INSERT);
78     selaAddSel(sela, sel2, "textsel2", L_INSERT);
79     selaAddSel(sela, sel3, "textsel3", L_INSERT);
80     selaAddSel(sela, sel4, "textsel4", L_INSERT);
81 
82     pix1 = selaDisplayInPix(sela, 28, 3, 30, 4);
83     pixWrite("/tmp/lept/livre/orient.png", pix1, IFF_PNG);
84     pixDisplay(pix1, 1200, 1200);
85 
86     pixDestroy(&pix1);
87     selaDestroy(&sela);
88     return 0;
89 }
90 
91