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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/Projects/MufasaTests/project1.lpr b/trunk/Projects/MufasaTests/project1.lpr
index e20a754..c5b50ec 100644
--- a/trunk/Projects/MufasaTests/project1.lpr
+++ b/trunk/Projects/MufasaTests/project1.lpr
@@ -82,21 +82,26 @@ begin
end;
{ add your program here }
- C := TClient.Create;
+ C := TClient.Create('.');
+ C.MOCR.InitTOCR('/home/merlijn/Programs/mufasa/Fonts/');
- bmp := TMufasaBitmap.Create;
+ bmp := C.MOCR.TextToFontBitmap('Danke schon', 'SmallChars');
+
+ bmp.SaveToFile('/tmp/wat.bmp');
+
+{ bmp := TMufasaBitmap.Create;
bmp.SetSize(CW,CH);
Writeln(Format('Client W/H: %d, %d', [CW, CH]));
FillChar(bmp.FData[0],sizeof(trgb32)*CW*CH, 0);
Randomize;
for i := 0 to 500 do
- bmp.fastsetpixel(random(CW), random(CH), 255);
+ bmp.fastsetpixel(random(CW), random(CH), 255); }
{ bmp.FastSetPixel(8,8,255);
bmp.FastSetPixel(9,9,255);
bmp.FastSetPixel(7,7,255);
bmp.FastSetPixel(9,8,255);
bmp.FastSetPixel(8,9,255); }
- C.MWindow.SetTarget(bmp);
+// C.MWindow.SetTarget(bmp);
{ initdtm(dtm, 5);
@@ -110,7 +115,7 @@ begin
dtm.asz[1] := 1;
dtm.ash[1] := dtm_Rectangle; }
- dtm := randomdtm(10);
+ { dtm := randomdtm(10);
// setlength(p, 1);
C.MFinder.SetToleranceSpeed(1);
@@ -125,14 +130,14 @@ begin
writeln(inttostr(length(p))+ ' points found');
setlength(p,0);
- PrintpDTM(tdtmtopDTM(pDTMToTDTM(dtm)));
+ PrintpDTM(tdtmtopDTM(pDTMToTDTM(dtm))); }
{for i := 0 to high(p) do
writeln(format('%d: (%d, %d)', [i, p[i].x, p[i].y])); }
//bmp.OnDestroy:=nil;
- bmp.Free;
+ //bmp.Free;
C.Free;
// stop program loop
diff --git a/trunk/Projects/SAMufasaGUI/project1.lpi b/trunk/Projects/SAMufasaGUI/project1.lpi
index 0463ab5..807a915 100644
--- a/trunk/Projects/SAMufasaGUI/project1.lpi
+++ b/trunk/Projects/SAMufasaGUI/project1.lpi
@@ -10,7 +10,7 @@
-
+
@@ -38,7 +38,7 @@
-
+
@@ -54,83 +54,83 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -148,40 +148,40 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -189,7 +189,7 @@
-
+
@@ -222,21 +222,21 @@
-
+
-
+
-
+
@@ -251,14 +251,14 @@
-
+
-
+
@@ -266,7 +266,7 @@
-
+
@@ -275,72 +275,72 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -348,7 +348,7 @@
-
+
@@ -357,13 +357,13 @@
-
+
-
+
@@ -376,106 +376,106 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -489,45 +489,45 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -541,40 +541,40 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -589,7 +589,7 @@
-
+
@@ -604,7 +604,7 @@
-
+
@@ -614,7 +614,7 @@
-
+
@@ -628,21 +628,21 @@
-
+
-
+
-
+
@@ -657,20 +657,20 @@
-
+
-
+
-
+
@@ -685,132 +685,134 @@
-
+
-
+
-
+
-
-
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -825,35 +827,35 @@
-
+
-
+
-
+
-
+
-
+
@@ -863,20 +865,20 @@
-
+
-
+
-
+
@@ -892,60 +894,60 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -955,236 +957,236 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1201,37 +1203,37 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1239,202 +1241,202 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1450,7 +1452,7 @@
-
+
@@ -1483,99 +1485,101 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1585,54 +1589,56 @@
-
+
-
+
-
+
-
+
-
-
-
+
+
+
+
+
-
+
-
+
-
+
@@ -1640,68 +1646,68 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
@@ -1709,7 +1715,7 @@
-
+
@@ -1717,7 +1723,7 @@
-
+
@@ -1728,118 +1734,118 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1849,34 +1855,34 @@
-
+
-
+
-
+
-
+
-
+
@@ -1887,56 +1893,56 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1944,65 +1950,65 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
@@ -2010,15 +2016,15 @@
-
+
-
-
+
+
@@ -2026,14 +2032,14 @@
-
+
-
+
@@ -2041,21 +2047,21 @@
-
+
-
+
-
-
+
+
@@ -2063,48 +2069,145 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/Units/MMLCore/ocr.pas b/trunk/Units/MMLCore/ocr.pas
index ea2439f..458a6be 100644
--- a/trunk/Units/MMLCore/ocr.pas
+++ b/trunk/Units/MMLCore/ocr.pas
@@ -51,6 +51,11 @@ uses
procedure FilterShadowBitmap(bmp: TMufasaBitmap);
procedure FilterCharsBitmap(bmp: TMufasaBitmap);
+ function GetTextAt(atX, atY, font, minspacing, maxspacing, color, len: integer): string;
+ function TextToFontTPA(Text, font: String; var w, h: integer): TPointArray;
+ function TextToFontBitmap(Text, font: String): TMufasaBitmap;
+
+
{$IFDEF OCRDEBUG}
procedure DebugToBmp(bmp: TMufasaBitmap; hmod,h: integer);
{$ENDIF}
@@ -695,5 +700,71 @@ begin
result := GetUpTextAtEx(atX, atY, false);
end;
+function TMOCR.GetTextAt(atX, atY, font, minspacing, maxspacing, color, len: integer): string;
+
+begin
+
+end;
+
+function TMOCR.TextToFontTPA(Text, font: String; var w, h: integer): TPointArray;
+
+var
+ fontD: TOcrData;
+ c, i, x, y, off: Integer;
+ d: TocrGlyphMetric;
+ an: integer;
+
+begin
+ fontD := Fonts.GetFont(font);
+ c := 0;
+ off := 0;
+ setlength(result, 0);
+
+ for i := 1 to length(text) do
+ begin
+ writeln(text[i]);
+ an := Ord(text[i]);
+ if not InRange(an, 0, 255) then
+ begin
+ writeln('WARNING: Invalid character passed to TextToFontTPA');
+ continue;
+ end;
+ d := fontD.ascii[an];
+ {writeln(format('xoff, yoff: %d, %d', [d.xoff, d.yoff]));
+ writeln(format('bmp w,h: %d, %d', [d.width, d.height]));
+ writeln(format('font w,h: %d, %d', [fontD.width, fontD.height])); }
+ setlength(result, c+d.width*d.height);
+ for y := 0 to fontD.height - 1 do
+ for x := 0 to fontD.width - 1 do
+ begin
+ if fontD.pos[fontD.ascii[an].index][x + y * fontD.width] = 1 then
+ // if fontD.pos[an][x + y * fontD.width] = 1 then
+ begin
+ result[c] := Point(x + off +d.xoff, y+d.yoff);
+ inc(c);
+ end;
+ end;
+ setlength(result, c);
+ off := off + d.width;
+ end;
+ w := off;
+ h := d.height;
+ { writeln('C: ' + inttostr(c)); }
+end;
+
+function TMOCR.TextToFontBitmap(Text, font: String): TMufasaBitmap;
+var
+ TPA: TPointArray;
+ w,h: integer;
+ bmp: TMufasaBitmap;
+begin
+ TPA := TextToFontTPA(text, font, w, h);
+ bmp := TMufasaBitmap.Create;
+ writeln(format('b: %d, %d', [w, h]));
+ bmp.SetSize(w, h);
+ bmp.DrawTPA(TPA, clWhite);
+ result := bmp;
+end;
+
end.
diff --git a/trunk/Units/MMLCore/ocrutil.pas b/trunk/Units/MMLCore/ocrutil.pas
index 3154839..a568e6c 100644
--- a/trunk/Units/MMLCore/ocrutil.pas
+++ b/trunk/Units/MMLCore/ocrutil.pas
@@ -233,7 +233,8 @@ begin
begin
result.pos[i][c]:= 1;
inc(pos);
- end;
+ end else
+ result.pos[i][c] := 0;
end;
end;
for c:= 0 to size-1 do