reference/ocr-simple/bitmap.cc
changeset 0 6b8091ca909a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reference/ocr-simple/bitmap.cc	Thu May 18 23:12:51 2006 +0200
@@ -0,0 +1,47 @@
+#include "bitmap.h"
+#include "stdio.h"
+
+Bitmap::Bitmap(char* b, int h, int w)
+{
+  bits = b;
+  height = h;
+  width = w;
+}
+
+Bitmap::Bitmap(char* filename)
+{
+}
+
+void Bitmap::WriteToFile(char* filename)
+{
+  FILE* fileout;
+  if(! (fileout = fopen(filename, "w+")))
+    {
+      printf("Error while trying to write bitmap to %s\n", filename);
+      exit(1);
+    }
+  else
+    {
+      fprintf(fileout, "#define %s_width %d\n", filename, width);
+      fprintf(fileout, "#define %s_height %d\n", filename, height);
+      fprintf(fileout, "static char %s_bits[] = {\n", filename);
+      for(int row_counter = 0; row_counter < height; row_counter++)
+	{
+	  for(int column_counter = 0; (8 * column_counter) < width; column_counter++)
+	    {
+	      fprintf(fileout, "%c,", bits[row_counter * width + column_counter]);
+	      if((column_counter % 16) == 0)
+		fprintf(fileout, "\n");   /* put a newline once in a while */
+	    }
+	}
+      fprintf(fileout, "};\n");
+      fclose(fileout);
+    } 
+}
+  
+
+
+
+
+
+