chiark / gitweb /
antialiasing text conversion: canonimage has 0..AAMAXVAL
[ypp-sc-tools.db-test.git] / pctb / ocr.h
1 /*
2  * ocr.c forms a mostly-self-contained bit
3  * so we put its declarations in this separate file
4  */
5 /*
6  *  This is part of ypp-sc-tools, a set of third-party tools for assisting
7  *  players of Yohoho Puzzle Pirates.
8  * 
9  *  Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
10  * 
11  *  This program is free software: you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation, either version 3 of the License, or
14  *  (at your option) any later version.
15  * 
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  * 
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  * 
24  *  Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
25  *  are used without permission.  This program is not endorsed or
26  *  sponsored by Three Rings.
27  */
28
29 #ifndef OCR_H
30 #define OCR_H
31
32 #include "common.h"
33
34
35 #define AADEPTH 3
36 #define AAMAXVAL ((1<<AADEPTH)-1)
37
38
39 typedef uint32_t Pixcol;
40 #define PSPIXCOL(priscan) priscan##32
41
42 typedef struct {
43   const char *s; /* valid until next call to ocr() */
44   int l,r; /* column numbers */
45   int match; /* match context index */
46   unsigned ctxmap; /* possible match contexts */
47 } OcrResultGlyph;
48
49
50 typedef const struct OcrCellTypeInfo *OcrCellType;
51 extern const struct OcrCellTypeInfo ocr_celltype_text;
52 extern const struct OcrCellTypeInfo ocr_celltype_number;
53 const char *ocr_celltype_name(OcrCellType ct);
54
55
56 typedef struct OcrReader OcrReader;
57 OcrReader *ocr_init(int h);
58 void ocr_showcharsets(void);
59
60 OcrResultGlyph *ocr(OcrReader *rd, OcrCellType, int w, Pixcol cols[]);
61   /* return value is array terminated by {0,-1,-1}
62    * array is valid until next call to ocr()
63    */
64
65
66 extern const char *o_resolver;
67
68 FILE *resolve_start(void);
69 void resolve_finish(void);
70
71
72 #endif /*OCR_H*/