forked from aspotashev/tesseract-ocr-cmake
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrender.cpp
137 lines (118 loc) · 4.16 KB
/
render.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* -*-C-*-
********************************************************************************
*
* File: render.c (Formerly render.c)
* Description: Convert the various data type into line lists
* Author: Mark Seaman, OCR Technology
* Created: Fri Jul 28 13:14:48 1989
* Modified: Mon Jul 15 10:23:37 1991 (Mark Seaman) marks@hpgrlt
* Language: C
* Package: N/A
* Status: Experimental (Do Not Distribute)
*
* (c) Copyright 1989, Hewlett-Packard Company.
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
** http://www.apache.org/licenses/LICENSE-2.0
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*
*********************************************************************************/
#include "render.h"
#include "blobs.h"
#ifdef __UNIX__
#include <assert.h>
#endif
#include <math.h>
#include "vecfuncs.h"
// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
#include "config_auto.h"
#endif
/*----------------------------------------------------------------------
V a r i a b l e s
----------------------------------------------------------------------*/
ScrollView *blob_window = NULL;
C_COL color_list[] = {
Red, Cyan, Yellow, Blue, Green, White
};
BOOL_VAR(wordrec_display_all_blobs, 0, "Display Blobs");
BOOL_VAR(wordrec_display_all_words, 0, "Display Words");
BOOL_VAR(wordrec_blob_pause, 0, "Blob pause");
/*----------------------------------------------------------------------
F u n c t i o n s
----------------------------------------------------------------------*/
#ifndef GRAPHICS_DISABLED
/**********************************************************************
* display_blob
*
* Macro to display blob in a window.
**********************************************************************/
void display_blob(TBLOB *blob, C_COL color) {
/* Size of drawable */
if (blob_window == NULL) {
blob_window = c_create_window ("Blobs", 520, 10,
500, 256, -1000.0, 1000.0, 0.0, 256.0);
}
else {
c_clear_window(blob_window);
}
render_blob(blob_window, blob, color);
}
/**********************************************************************
* render_blob
*
* Create a list of line segments that represent the expanded outline
* that was supplied as input.
**********************************************************************/
void render_blob(void *window, TBLOB *blob, C_COL color) {
/* No outline */
if (!blob)
return;
render_outline (window, blob->outlines, color);
}
/**********************************************************************
* render_edgepts
*
* Create a list of line segments that represent the expanded outline
* that was supplied as input.
**********************************************************************/
void render_edgepts(void *window, EDGEPT *edgept, C_COL color) {
if (!edgept)
return;
float x = edgept->pos.x;
float y = edgept->pos.y;
EDGEPT *this_edge = edgept;
c_line_color_index(window, color);
c_move(window, x, y);
do {
this_edge = this_edge->next;
x = this_edge->pos.x;
y = this_edge->pos.y;
c_draw(window, x, y);
}
while (edgept != this_edge);
}
/**********************************************************************
* render_outline
*
* Create a list of line segments that represent the expanded outline
* that was supplied as input.
**********************************************************************/
void render_outline(void *window,
TESSLINE *outline,
C_COL color) {
/* No outline */
if (!outline)
return;
/* Draw Compact outline */
if (outline->loop)
render_edgepts (window, outline->loop, color);
/* Add on next outlines */
render_outline (window, outline->next, color);
}
#endif // GRAPHICS_DISABLED