equal
deleted
inserted
replaced
|
1 #include <Text.h> |
|
2 |
|
3 void Text::getLines(Bitmap *map) |
|
4 { |
|
5 int map_height = map->get_height(); |
|
6 int linenum=0; |
|
7 int last_linenum=0; |
|
8 int lineSize; |
|
9 |
|
10 // FIXME: Comprovacions |
|
11 |
|
12 int line_top; |
|
13 int line_bottom; |
|
14 int lastline_top; |
|
15 int lastline_bottom; |
|
16 |
|
17 Lines.clear(); |
|
18 |
|
19 for (int i = 0; i < map_height; i++) |
|
20 { |
|
21 // Fins a trobar començament de línia |
|
22 while (i< map_height && |
|
23 map->points_per_row(i) < NoiseTolerance) |
|
24 i++; |
|
25 |
|
26 line_top = i++; |
|
27 // Fins a trobar final de línia |
|
28 while (i< map_height && |
|
29 map->points_per_row(i) > NoiseTolerance) |
|
30 i++; |
|
31 |
|
32 // If this line is less than MinVertSeparation away |
|
33 // from the last line. Join the two together. |
|
34 if (linenum > 0) |
|
35 { |
|
36 if (line_top - lastline_bottom < MinVertSeparation) |
|
37 lastline_bottom = i; |
|
38 } |
|
39 |
|
40 lineSize = i - line_top + 1; |
|
41 if (lineSize >= MinLineSize) |
|
42 { |
|
43 line_bottom = i; |
|
44 Lines.push_back(Rectangle(0,line_top, |
|
45 map->get_height(), line_bottom)); |
|
46 |
|
47 fprintf(stderr, "Line from %i to %i : %i.\n", line_top, |
|
48 line_bottom, line_bottom - line_top + 1); |
|
49 |
|
50 lastline_top = line_top; |
|
51 lastline_bottom = line_bottom; |
|
52 } |
|
53 } |
|
54 } |