Text.cc
changeset 0 6b8091ca909a
child 2 5cdb891abc1e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Text.cc	Thu May 18 23:12:51 2006 +0200
@@ -0,0 +1,54 @@
+#include <Text.h>
+
+void Text::getLines(Bitmap *map)
+{
+	int map_height = map->get_height();
+	int linenum=0;
+	int last_linenum=0;
+	int lineSize;
+
+	// FIXME: Comprovacions
+
+	int line_top;
+	int line_bottom;
+	int lastline_top;
+	int lastline_bottom;
+
+	Lines.clear();
+
+	for (int i = 0; i < map_height; i++)
+	{
+		// Fins a trobar començament de línia
+		while (i< map_height &&
+			map->points_per_row(i) < NoiseTolerance)
+			i++;
+
+		line_top = i++;
+		// Fins a trobar final de línia
+		while (i< map_height &&
+			map->points_per_row(i) > NoiseTolerance)
+			i++;
+
+		// If this line is less than MinVertSeparation away
+		//  from the last line.  Join the two together.
+		if (linenum > 0)
+		{
+			if (line_top - lastline_bottom < MinVertSeparation)
+				lastline_bottom = i;
+		}
+
+		lineSize = i - line_top + 1;
+		if (lineSize >= MinLineSize)
+		{
+			line_bottom = i;
+			Lines.push_back(Rectangle(0,line_top,
+				map->get_height(), line_bottom));
+
+			fprintf(stderr, "Line from %i to %i : %i.\n", line_top,
+				line_bottom, line_bottom - line_top + 1);
+
+			lastline_top = line_top;
+			lastline_bottom = line_bottom;
+		}
+	}
+}