diff --git a/Projects/MufasaTests/project1.lpi b/Projects/MufasaTests/project1.lpi
index 523cbdc..2401ae3 100644
--- a/Projects/MufasaTests/project1.lpi
+++ b/Projects/MufasaTests/project1.lpi
@@ -35,10 +35,10 @@
-
-
+
+
-
+
@@ -54,7 +54,7 @@
-
+
@@ -70,7 +70,7 @@
-
+
@@ -79,7 +79,7 @@
-
+
@@ -88,7 +88,7 @@
-
+
@@ -97,7 +97,7 @@
-
+
@@ -106,16 +106,16 @@
-
+
-
-
+
+
-
+
@@ -141,10 +141,10 @@
-
-
+
+
-
+
@@ -179,7 +179,7 @@
-
+
@@ -188,7 +188,7 @@
-
+
@@ -197,7 +197,7 @@
-
+
@@ -206,7 +206,7 @@
-
+
@@ -215,7 +215,7 @@
-
+
@@ -241,123 +241,123 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
diff --git a/Projects/MufasaTests/project1.lpr b/Projects/MufasaTests/project1.lpr
index c88826b..3be1f92 100644
--- a/Projects/MufasaTests/project1.lpr
+++ b/Projects/MufasaTests/project1.lpr
@@ -54,10 +54,20 @@ end;
procedure MufasaTests.DoRun;
+
const
- ocr_Limit_High = 192;
+ ocr_Limit_High = 191;
ocr_Limit_Low = 65;
+ ocr_White = 16777215;
+ ocr_Green = 65280;
+ ocr_Red = 255;
+ ocr_Yellow = 65535;
+ ocr_Blue = 16776960;
+ ocr_ItemC = 16744447;
+
+ ocr_Purple = 8388736;
+
var
ErrorMsg: String;
Time: DWord;
@@ -66,7 +76,6 @@ var
dtm: pdtm;
p:tpointarray;
bmp, bmprs: TMufasaBitmap;
- cyan, itemc:integer;
r,g,b:integer;
t:Dword;
@@ -86,16 +95,22 @@ begin
Exit;
end;
+
+ { clOlive = false point }
+ { clSilver = false shadow }
+ { clLime = false shadow}
+
{ add your program here }
- cyan := rgbtocolor(0,255,255);
bmprs := TMufasaBitmap.Create;
- bmprs.LoadFromFile('/home/merlijn/Programs/mufasa/pics/uptext7.png');
+ bmprs.LoadFromFile('/home/merlijn/Programs/mufasa/pics/16.bmp');
C := TClient.Create;
C.MWindow.SetTarget(bmprs);
C.MWindow.GetDimensions(w, h);
+ writeln(inttostr(clpurple));
+
bmp := TMufasaBitmap.Create;
bmp.CopyClientToBitmap(C.MWindow, True, 0, 0, 450, 50);
@@ -108,66 +123,111 @@ begin
// the abs(g-b) < 15 seems to help heaps when taking out crap points
if (r > ocr_Limit_High) and (g > ocr_Limit_High) and (b > ocr_Limit_High){ and (abs(g-b) < 15)} then
begin
- bmp.fastsetpixel(x,y,clwhite);
+ bmp.fastsetpixel(x,y,ocr_White);
continue;
end;
if (r < ocr_Limit_Low) and (g > ocr_Limit_High) and (b > ocr_Limit_High) then
begin
- bmp.fastsetpixel(x,y,cyan);
+ bmp.fastsetpixel(x,y,ocr_Blue);
continue;
end;
if (r < ocr_Limit_Low) and (g > ocr_Limit_High) and (b < ocr_Limit_Low) then
begin
- bmp.fastsetpixel(x,y,rgbtocolor(0,255,0));
+ bmp.fastsetpixel(x,y,ocr_Green);
continue;
end;
- if(r > ocr_Limit_High) and (g > 100) and (g < ocr_Limit_High) and (b > 30) and (b < 90) then
+
+ // false results with fire
+ if(r > ocr_Limit_High) and (g > 100) and (g < ocr_Limit_High) and (b > 40) and (b < 90) then
begin
- bmp.fastsetpixel(x,y,rgbtocolor(255,127,0));
+ bmp.fastsetpixel(x,y,ocr_ItemC);
continue;
end;
if(r > ocr_Limit_High) and (g > ocr_Limit_High) and (b < ocr_Limit_Low) then
begin
- bmp.fastsetpixel(x,y,rgbtocolor(255,255,0));
+ bmp.fastsetpixel(x,y,ocr_Yellow);
continue;
end;
// better use g < 40 than ocr_Limit_Low imo
if (r > ocr_Limit_High) and (g < ocr_Limit_Low) and (b < ocr_Limit_Low) then
begin
- bmp.fastsetpixel(x,y,rgbtocolor(255,0,0));
+ bmp.fastsetpixel(x,y,ocr_Red);
+ continue;
+ end;
+
+ if (r < ocr_Limit_Low) and (g < ocr_Limit_Low) and (b < ocr_Limit_Low) then
+ begin
+ bmp.FastSetPixel(x,y, ocr_Purple);
continue;
end;
bmp.fastsetpixel(x,y,0);
end;
+
+ // increase height by 1, so our algo works better. (shadow)
+ bmp.SetSize(Bmp.Width, Bmp.Height+1);
+ for x := 0 to bmp.width -1 do
+ bmp.fastsetpixel(x,bmp.height-1,0);
+
+ for y := 0 to bmp.Height - 2 do
+ for x := 0 to bmp.Width - 2 do
+ begin
+ if bmp.fastgetpixel(x,y) = clPurple then
+ continue;
+ if bmp.fastgetpixel(x,y) = clBlack then
+ continue;
+ if (bmp.fastgetpixel(x,y) <> bmp.fastgetpixel(x+1,y+1)) and (bmp.fastgetpixel(x+1,y+1) <> clpurple) then
+ bmp.fastsetpixel(x,y,{clAqua}0);
+ end;
+
+ { Optional - remove false shadow }
+ for y := bmp.Height - 1 downto 1 do
+ for x := bmp.Width - 1 downto 1 do
+ begin
+ if bmp.fastgetpixel(x,y) <> clPurple then
+ continue;
+ if bmp.fastgetpixel(x,y) = bmp.fastgetpixel(x-1,y-1) then
+ begin
+ bmp.fastsetpixel(x,y,clSilver);
+ continue;
+ end;
+ if bmp.fastgetpixel(x-1,y-1) = 0 then
+ bmp.fastsetpixel(x,y,clLime);
+ end;
+
+ { remove bad points }
+ for y := bmp.Height - 2 downto 1 do
+ for x := bmp.Width - 2 downto 1 do
+ begin
+ if bmp.fastgetpixel(x,y) = clPurple then
+ continue;
+ if bmp.fastgetpixel(x,y) = clBlack then
+ continue;
+ if (bmp.fastgetpixel(x,y) = bmp.fastgetpixel(x+1,y+1) ) then
+ continue;
+
+ if bmp.fastgetpixel(x+1,y+1) <> clPurple then
+ begin
+ bmp.fastsetpixel(x,y,clOlive);
+ continue;
+ end;
+ end;
+
+ { Dangerous removes all pixels that had no pixels on x-1 or x+1}
+ { for y := 0 to bmp.Height - 2 do
+ for x := 1 to bmp.Width - 2 do
+ begin
+ if bmp.fastgetpixel(x,y) = clBlack then continue;
+ if bmp.fastgetpixel(x,y) = clPurple then continue;
+ if bmp.fastgetpixel(x,y) = clOlive then continue;
+ if bmp.fastgetpixel(x,y) = clSilver then continue;
+ if bmp.fastgetpixel(x,y) = clLime then continue;
+ if (bmp.fastgetpixel(x,y) <> bmp.fastgetpixel(x+1,y) ) and
+ (bmp.fastgetpixel(x,y) <> bmp.fastgetpixel(x-1,y) ) then
+ bmp.fastsetpixel(x,y,clFuchsia);
+ end; }
+
writeln(inttostr(gettickcount-t));
- {
- bmp.Posterize(130); // ~ 3
- // bmp.Contrast(3);
-
- for y := 0 to bmp.Height - 1 do
- for x := 0 to bmp.Width - 1 do
- begin
- if bmp.FastGetPixel(x, y) = clWhite then
- continue;
- //cyan
- if bmp.FastGetPixel(x, y) = rgbtocolor(0,255,255) then
- continue;
- //green
- if bmp.FastGetPixel(x, y) = rgbtocolor(0,255,0) then
- continue;
-
- //item // TODO -> 5.bmp = not OK
- if bmp.FastGetPixel(x, y) = rgbtocolor(255,130,0) then
- continue;
-
- //yellow, interact
- if bmp.FastGetPixel(x, y) = rgbtocolor(255,255,0) then
- continue;
-
- bmp.fastsetpixel(x,y,0);
- end;
- }
diff --git a/Projects/SAMufasaGUI/colourhistory.pas b/Projects/SAMufasaGUI/colourhistory.pas
index ca3aa5c..d980d7f 100644
--- a/Projects/SAMufasaGUI/colourhistory.pas
+++ b/Projects/SAMufasaGUI/colourhistory.pas
@@ -83,7 +83,8 @@ begin
if autoName then
begin
Inc(Colour_Count);
- c.Name := 'Untitled (' + IntToStr(Colour_Count) + ')';
+ // TODO: Proper name
+ c.Name := IntToStr(c.Colour) + ' (' + IntToStr(Colour_Count) + ')';
end;
Self.AddColObj(c);
end;
diff --git a/Projects/SAMufasaGUI/debugimage.lrs b/Projects/SAMufasaGUI/debugimage.lrs
index c6a15a0..5a4a408 100644
--- a/Projects/SAMufasaGUI/debugimage.lrs
+++ b/Projects/SAMufasaGUI/debugimage.lrs
@@ -1,4 +1,4 @@
-{ Este es un archivo de recurso de Lazarus generado automáticamente }
+{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TDebugImgForm','FORMDATA',[
'TPF0'#13'TDebugImgForm'#12'DebugImgForm'#4'Left'#3#235#1#6'Height'#3','#1#3
diff --git a/Projects/SAMufasaGUI/project1.lpi b/Projects/SAMufasaGUI/project1.lpi
index def84a9..38f3fd6 100644
--- a/Projects/SAMufasaGUI/project1.lpi
+++ b/Projects/SAMufasaGUI/project1.lpi
@@ -10,7 +10,7 @@
-
+
@@ -36,14 +36,14 @@
-
+
-
+
@@ -168,8 +168,8 @@
-
-
+
+
@@ -225,8 +225,8 @@
-
-
+
+
@@ -235,8 +235,8 @@
-
-
+
+
@@ -278,8 +278,8 @@
-
-
+
+
@@ -317,9 +317,9 @@
-
-
-
+
+
+
@@ -388,7 +388,7 @@
-
+
@@ -408,8 +408,8 @@
-
-
+
+
@@ -715,7 +715,7 @@
-
+
@@ -732,7 +732,7 @@
-
+
@@ -793,7 +793,7 @@
-
+
@@ -808,8 +808,8 @@
-
-
+
+
@@ -873,9 +873,11 @@
-
-
+
+
+
+
@@ -1003,7 +1005,7 @@
-
+
@@ -1202,7 +1204,7 @@
-
+
@@ -1518,7 +1520,7 @@
-
+
@@ -1769,7 +1771,7 @@
-
+
@@ -1783,7 +1785,7 @@
-
+
@@ -1792,7 +1794,7 @@
-
+
@@ -1804,7 +1806,7 @@
-
+
@@ -1873,127 +1875,149 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/Projects/SAMufasaGUI/testunit.lfm b/Projects/SAMufasaGUI/testunit.lfm
index 9ed5954..88e284b 100644
--- a/Projects/SAMufasaGUI/testunit.lfm
+++ b/Projects/SAMufasaGUI/testunit.lfm
@@ -1,11 +1,11 @@
object Form1: TForm1
Left = 274
Height = 557
- Top = 121
+ Top = 233
Width = 731
ActiveControl = ScriptPanel
Caption = 'THA FUKING MUFASA'
- ClientHeight = 528
+ ClientHeight = 532
ClientWidth = 731
KeyPreview = True
Menu = MainMenu1
@@ -167,7 +167,7 @@ object Form1: TForm1
object StatusBar: TStatusBar
Left = 0
Height = 21
- Top = 507
+ Top = 511
Width = 731
Panels = <
item
@@ -185,7 +185,7 @@ object Form1: TForm1
object PanelMemo: TPanel
Left = 0
Height = 154
- Top = 353
+ Top = 357
Width = 731
Align = alBottom
ClientHeight = 154
@@ -205,25 +205,25 @@ object Form1: TForm1
Cursor = crVSplit
Left = 0
Height = 5
- Top = 348
+ Top = 352
Width = 731
Align = alBottom
ResizeAnchor = akBottom
end
object ScriptPanel: TPanel
Left = 0
- Height = 324
+ Height = 328
Top = 24
Width = 731
Align = alClient
BevelOuter = bvNone
Caption = 'ScriptPanel'
- ClientHeight = 324
+ ClientHeight = 328
ClientWidth = 731
TabOrder = 4
object PageControl1: TPageControl
Left = 0
- Height = 289
+ Height = 293
Top = 0
Width = 731
Align = alClient
@@ -241,7 +241,7 @@ object Form1: TForm1
object SearchPanel: TPanel
Left = 0
Height = 35
- Top = 289
+ Top = 293
Width = 731
Align = alBottom
BevelOuter = bvSpace
@@ -337,7 +337,7 @@ object Form1: TForm1
end
object LabeledEditSearch: TLabeledEdit
Left = 104
- Height = 25
+ Height = 27
Top = 6
Width = 174
EditLabel.AnchorSideLeft.Control = LabeledEditSearch
@@ -345,10 +345,10 @@ object Form1: TForm1
EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = LabeledEditSearch
EditLabel.AnchorSideBottom.Control = LabeledEditSearch
- EditLabel.Left = 65
+ EditLabel.Left = 67
EditLabel.Height = 18
- EditLabel.Top = 9
- EditLabel.Width = 36
+ EditLabel.Top = 10
+ EditLabel.Width = 34
EditLabel.Caption = 'Find: '
EditLabel.ParentColor = False
LabelPosition = lpLeft
@@ -361,9 +361,9 @@ object Form1: TForm1
end
object CheckBoxMatchCase: TCheckBox
Left = 320
- Height = 20
+ Height = 22
Top = 7
- Width = 96
+ Width = 97
Caption = 'Match case'
OnClick = CheckBoxMatchCaseClick
TabOrder = 1
diff --git a/Projects/SAMufasaGUI/testunit.lrs b/Projects/SAMufasaGUI/testunit.lrs
index 11efbe8..86fc834 100644
--- a/Projects/SAMufasaGUI/testunit.lrs
+++ b/Projects/SAMufasaGUI/testunit.lrs
@@ -1,69 +1,69 @@
-{ Este es un archivo de recurso de Lazarus generado automáticamente }
+{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[
- 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#18#1#6'Height'#3'-'#2#3'Top'#2'y'#5'Width'
- +#3#219#2#13'ActiveControl'#7#11'ScriptPanel'#7'Caption'#6#17'THA FUKING MUFA'
- +'SA'#12'ClientHeight'#3#16#2#11'ClientWidth'#3#219#2#10'KeyPreview'#9#4'Menu'
- +#7#9'MainMenu1'#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreate'#9'OnD'
- +'estroy'#7#11'FormDestroy'#10'OnShortCut'#7#13'FormShortCuts'#8'Position'#7
- +#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.29'#7'Visible'#9#0#8'TToolBar'#8
- +'ToolBar1'#4'Left'#2#0#6'Height'#2#24#3'Top'#2#0#5'Width'#3#219#2#7'Caption'
- +#6#8'ToolBar1'#6'Images'#7#17'Mufasa_Image_List'#14'ParentShowHint'#8#8'Show'
- +'Hint'#9#8'TabOrder'#2#0#0#11'TToolButton'#6'TB_Run'#4'Left'#2'`'#4'Hint'#6#3
- +'Run'#3'Top'#2#2#6'Action'#7#15'ActionRunScript'#10'ImageIndex'#2#6#0#0#11'T'
- +'ToolButton'#8'TB_Pause'#4'Left'#2'w'#4'Hint'#6#5'Pause'#3'Top'#2#2#6'Action'
- +#7#17'ActionPauseScript'#7'Enabled'#8#10'ImageIndex'#2#5#0#0#11'TToolButton'
- +#7'TB_Stop'#4'Left'#3#142#0#4'Hint'#6#4'Stop'#3'Top'#2#2#6'Action'#7#16'Acti'
- +'onStopScript'#7'Enabled'#8#10'ImageIndex'#2#7#0#0#11'TToolButton'#11'ToolBu'
- +'tton1'#4'Left'#3#165#0#3'Top'#2#2#5'Width'#2#3#7'Caption'#6#11'ToolButton1'
- +#5'Style'#7#10'tbsDivider'#0#0#11'TToolButton'#9'TB_NewTab'#4'Left'#3#168#0#4
- +'Hint'#6#7'Add tab'#3'Top'#2#2#6'Action'#7#12'ActionNewTab'#0#0#11'TToolButt'
- +'on'#11'TB_CloseTab'#4'Left'#3#191#0#4'Hint'#6#9'Close tab'#3'Top'#2#2#6'Act'
- +'ion'#7#14'ActionCloseTab'#0#0#11'TToolButton'#11'ToolButton4'#4'Left'#3#214
- +#0#3'Top'#2#2#5'Width'#2#3#7'Caption'#6#11'ToolButton4'#5'Style'#7#10'tbsDiv'
- +'ider'#0#0#11'TToolButton'#13'TB_ClearDebug'#4'Left'#3#217#0#4'Hint'#6#15'Cl'
- +'ear debug box'#3'Top'#2#2#6'Action'#7#16'ActionClearDebug'#0#0#11'TToolButt'
- +'on'#13'TB_PickColour'#4'Left'#3#240#0#4'Hint'#6#12'Pick a color'#3'Top'#2#2
- +#7'Caption'#6#13'TB_PickColour'#10'ImageIndex'#2#0#7'OnClick'#7#15'ButtonPic'
- +'kClick'#0#0#11'TToolButton'#15'TB_SelectClient'#4'Left'#3#7#1#4'Hint'#6#15
- +'Select a client'#3'Top'#2#2#7'Caption'#6#15'TB_SelectClient'#10'ImageIndex'
- +#2#2#11'OnMouseDown'#7#18'ButtonSelectorDown'#0#0#11'TToolButton'#11'ToolBut'
- +'ton8'#4'Left'#3#30#1#3'Top'#2#2#5'Width'#2#3#7'Caption'#6#11'ToolButton8'#5
- +'Style'#7#10'tbsDivider'#0#0#11'TToolButton'#10'TB_Convert'#4'Left'#3'!'#1#3
- +'Top'#2#2#7'Caption'#6#10'TB_Convert'#7'Enabled'#8#10'ImageIndex'#2#1#0#0#11
- +'TToolButton'#16'TB_ReloadPlugins'#4'Left'#3'8'#1#4'Hint'#6#14'Reload plugin'
- +'s'#3'Top'#2#2#7'Caption'#6#16'TB_ReloadPlugins'#7'Enabled'#8#10'ImageIndex'
- +#2#13#0#0#11'TToolButton'#7'TB_Tray'#4'Left'#3'O'#1#4'Hint'#6#16'Minimize to'
- +' tray'#3'Top'#2#2#7'Caption'#6#7'TB_Tray'#10'ImageIndex'#2#17#7'OnClick'#7
- +#15'ButtonTrayClick'#0#0#11'TToolButton'#6'TB_New'#4'Left'#2#1#4'Hint'#6#3'N'
- +'ew'#3'Top'#2#2#6'Action'#7#15'ActionNewScript'#14'ParentShowHint'#8#8'ShowH'
- +'int'#9#0#0#11'TToolButton'#11'ToolButton2'#4'Left'#2']'#3'Top'#2#2#5'Width'
+ 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#18#1#6'Height'#3'-'#2#3'Top'#3#233#0#5'Wi'
+ +'dth'#3#219#2#13'ActiveControl'#7#11'ScriptPanel'#7'Caption'#6#17'THA FUKING'
+ +' MUFASA'#12'ClientHeight'#3#20#2#11'ClientWidth'#3#219#2#10'KeyPreview'#9#4
+ +'Menu'#7#9'MainMenu1'#7'OnClose'#7#9'FormClose'#8'OnCreate'#7#10'FormCreate'
+ +#9'OnDestroy'#7#11'FormDestroy'#10'OnShortCut'#7#13'FormShortCuts'#8'Positio'
+ +'n'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.29'#7'Visible'#9#0#8'TToolBa'
+ +'r'#8'ToolBar1'#4'Left'#2#0#6'Height'#2#24#3'Top'#2#0#5'Width'#3#219#2#7'Cap'
+ +'tion'#6#8'ToolBar1'#6'Images'#7#17'Mufasa_Image_List'#14'ParentShowHint'#8#8
+ +'ShowHint'#9#8'TabOrder'#2#0#0#11'TToolButton'#6'TB_Run'#4'Left'#2'`'#4'Hint'
+ +#6#3'Run'#3'Top'#2#2#6'Action'#7#15'ActionRunScript'#10'ImageIndex'#2#6#0#0
+ +#11'TToolButton'#8'TB_Pause'#4'Left'#2'w'#4'Hint'#6#5'Pause'#3'Top'#2#2#6'Ac'
+ +'tion'#7#17'ActionPauseScript'#7'Enabled'#8#10'ImageIndex'#2#5#0#0#11'TToolB'
+ +'utton'#7'TB_Stop'#4'Left'#3#142#0#4'Hint'#6#4'Stop'#3'Top'#2#2#6'Action'#7
+ +#16'ActionStopScript'#7'Enabled'#8#10'ImageIndex'#2#7#0#0#11'TToolButton'#11
+ +'ToolButton1'#4'Left'#3#165#0#3'Top'#2#2#5'Width'#2#3#7'Caption'#6#11'ToolBu'
+ +'tton1'#5'Style'#7#10'tbsDivider'#0#0#11'TToolButton'#9'TB_NewTab'#4'Left'#3
+ +#168#0#4'Hint'#6#7'Add tab'#3'Top'#2#2#6'Action'#7#12'ActionNewTab'#0#0#11'T'
+ +'ToolButton'#11'TB_CloseTab'#4'Left'#3#191#0#4'Hint'#6#9'Close tab'#3'Top'#2
+ +#2#6'Action'#7#14'ActionCloseTab'#0#0#11'TToolButton'#11'ToolButton4'#4'Left'
+ +#3#214#0#3'Top'#2#2#5'Width'#2#3#7'Caption'#6#11'ToolButton4'#5'Style'#7#10
+ +'tbsDivider'#0#0#11'TToolButton'#13'TB_ClearDebug'#4'Left'#3#217#0#4'Hint'#6
+ +#15'Clear debug box'#3'Top'#2#2#6'Action'#7#16'ActionClearDebug'#0#0#11'TToo'
+ +'lButton'#13'TB_PickColour'#4'Left'#3#240#0#4'Hint'#6#12'Pick a color'#3'Top'
+ +#2#2#7'Caption'#6#13'TB_PickColour'#10'ImageIndex'#2#0#7'OnClick'#7#15'Butto'
+ +'nPickClick'#0#0#11'TToolButton'#15'TB_SelectClient'#4'Left'#3#7#1#4'Hint'#6
+ +#15'Select a client'#3'Top'#2#2#7'Caption'#6#15'TB_SelectClient'#10'ImageInd'
+ +'ex'#2#2#11'OnMouseDown'#7#18'ButtonSelectorDown'#0#0#11'TToolButton'#11'Too'
+ +'lButton8'#4'Left'#3#30#1#3'Top'#2#2#5'Width'#2#3#7'Caption'#6#11'ToolButton'
+ +'8'#5'Style'#7#10'tbsDivider'#0#0#11'TToolButton'#10'TB_Convert'#4'Left'#3'!'
+ +#1#3'Top'#2#2#7'Caption'#6#10'TB_Convert'#7'Enabled'#8#10'ImageIndex'#2#1#0#0
+ +#11'TToolButton'#16'TB_ReloadPlugins'#4'Left'#3'8'#1#4'Hint'#6#14'Reload plu'
+ +'gins'#3'Top'#2#2#7'Caption'#6#16'TB_ReloadPlugins'#7'Enabled'#8#10'ImageInd'
+ +'ex'#2#13#0#0#11'TToolButton'#7'TB_Tray'#4'Left'#3'O'#1#4'Hint'#6#16'Minimiz'
+ +'e to tray'#3'Top'#2#2#7'Caption'#6#7'TB_Tray'#10'ImageIndex'#2#17#7'OnClick'
+ +#7#15'ButtonTrayClick'#0#0#11'TToolButton'#6'TB_New'#4'Left'#2#1#4'Hint'#6#3
+ +'New'#3'Top'#2#2#6'Action'#7#15'ActionNewScript'#14'ParentShowHint'#8#8'Show'
+ +'Hint'#9#0#0#11'TToolButton'#11'ToolButton2'#4'Left'#2']'#3'Top'#2#2#5'Width'
+#2#3#7'Caption'#6#11'ToolButton2'#5'Style'#7#10'tbsDivider'#0#0#11'TToolButt'
+'on'#7'TB_Open'#4'Left'#2#24#4'Hint'#6#4'Open'#3'Top'#2#2#6'Action'#7#16'Act'
+'ionOpenScript'#14'ParentShowHint'#8#8'ShowHint'#9#0#0#11'TToolButton'#7'TB_'
+'Save'#4'Left'#2'/'#4'Hint'#6#4'Save'#3'Top'#2#2#6'Action'#7#16'ActionSaveSc'
+'ript'#0#0#11'TToolButton'#10'TB_SaveAll'#4'Left'#2'F'#4'Hint'#6#8'Save all'
+#3'Top'#2#2#6'Action'#7#13'ActionSaveAll'#7'Enabled'#8#0#0#0#10'TStatusBar'#9
- +'StatusBar'#4'Left'#2#0#6'Height'#2#21#3'Top'#3#251#1#5'Width'#3#219#2#6'Pan'
+ +'StatusBar'#4'Left'#2#0#6'Height'#2#21#3'Top'#3#255#1#5'Width'#3#219#2#6'Pan'
+'els'#14#1#5'Width'#2'<'#0#1#4'Text'#6#8'Untitled'#5'Width'#3#150#0#0#1#5'Wi'
+'dth'#2'2'#0#0#11'SimplePanel'#8#0#0#6'TPanel'#9'PanelMemo'#4'Left'#2#0#6'He'
- +'ight'#3#154#0#3'Top'#3'a'#1#5'Width'#3#219#2#5'Align'#7#8'alBottom'#12'Clie'
+ +'ight'#3#154#0#3'Top'#3'e'#1#5'Width'#3#219#2#5'Align'#7#8'alBottom'#12'Clie'
+'ntHeight'#3#154#0#11'ClientWidth'#3#219#2#8'TabOrder'#2#2#0#5'TMemo'#5'Memo'
+'1'#4'Left'#2#1#6'Height'#3#152#0#3'Top'#2#1#5'Width'#3#217#2#5'Align'#7#8'a'
+'lClient'#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#0#0#0#0#9'TSplitter'
+#19'SplitterMemoSynedit'#6'Cursor'#7#8'crVSplit'#4'Left'#2#0#6'Height'#2#5#3
- +'Top'#3'\'#1#5'Width'#3#219#2#5'Align'#7#8'alBottom'#12'ResizeAnchor'#7#8'ak'
- +'Bottom'#0#0#6'TPanel'#11'ScriptPanel'#4'Left'#2#0#6'Height'#3'D'#1#3'Top'#2
+ +'Top'#3'`'#1#5'Width'#3#219#2#5'Align'#7#8'alBottom'#12'ResizeAnchor'#7#8'ak'
+ +'Bottom'#0#0#6'TPanel'#11'ScriptPanel'#4'Left'#2#0#6'Height'#3'H'#1#3'Top'#2
+#24#5'Width'#3#219#2#5'Align'#7#8'alClient'#10'BevelOuter'#7#6'bvNone'#7'Cap'
- +'tion'#6#11'ScriptPanel'#12'ClientHeight'#3'D'#1#11'ClientWidth'#3#219#2#8'T'
- +'abOrder'#2#4#0#12'TPageControl'#12'PageControl1'#4'Left'#2#0#6'Height'#3'!'
+ +'tion'#6#11'ScriptPanel'#12'ClientHeight'#3'H'#1#11'ClientWidth'#3#219#2#8'T'
+ +'abOrder'#2#4#0#12'TPageControl'#12'PageControl1'#4'Left'#2#0#6'Height'#3'%'
+#1#3'Top'#2#0#5'Width'#3#219#2#5'Align'#7#8'alClient'#6'Images'#7#17'Mufasa_'
+'Image_List'#9'PopupMenu'#7#8'TabPopup'#8'TabOrder'#2#0#8'OnChange'#7#18'Pag'
+'eControl1Change'#10'OnChanging'#7#20'PageControl1Changing'#14'OnContextPopu'
+'p'#7#24'PageControl1ContextPopup'#10'OnDragDrop'#7#20'PageControl1DragDrop'
+#10'OnDragOver'#7#20'PageControl1DragOver'#11'OnMouseDown'#7#21'PageControl1'
+'MouseDown'#13'OnPageChanged'#7#18'PageControl1Change'#0#0#6'TPanel'#11'Sear'
- +'chPanel'#4'Left'#2#0#6'Height'#2'#'#3'Top'#3'!'#1#5'Width'#3#219#2#5'Align'
+ +'chPanel'#4'Left'#2#0#6'Height'#2'#'#3'Top'#3'%'#1#5'Width'#3#219#2#5'Align'
+#7#8'alBottom'#10'BevelOuter'#7#7'bvSpace'#12'ClientHeight'#2'#'#11'ClientWi'
,'dth'#3#219#2#8'TabOrder'#2#1#7'Visible'#8#0#12'TSpeedButton'#17'SpeedButton'
+'Search'#4'Left'#2' '#6'Height'#2#19#3'Top'#2#7#5'Width'#2#16#5'Color'#7#9'c'
@@ -132,18 +132,18 @@ LazarusResources.Add('TForm1','FORMDATA',[
,#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
+#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#9
+'NumGlyphs'#2#0#7'OnClick'#7#22'SpeedButtonSearchClick'#0#0#12'TLabeledEdit'
- +#17'LabeledEditSearch'#4'Left'#2'h'#6'Height'#2#25#3'Top'#2#6#5'Width'#3#174
+ +#17'LabeledEditSearch'#4'Left'#2'h'#6'Height'#2#27#3'Top'#2#6#5'Width'#3#174
+#0' EditLabel.AnchorSideLeft.Control'#7#17'LabeledEditSearch'#31'EditLabel.A'
+'nchorSideTop.Control'#7#17'LabeledEditSearch'#28'EditLabel.AnchorSideTop.Si'
+'de'#7#9'asrCenter!EditLabel.AnchorSideRight.Control'#7#17'LabeledEditSearch'
+'"EditLabel.AnchorSideBottom.Control'#7#17'LabeledEditSearch'#14'EditLabel.L'
- +'eft'#2'A'#16'EditLabel.Height'#2#18#13'EditLabel.Top'#2#9#15'EditLabel.Widt'
- +'h'#2'$'#17'EditLabel.Caption'#6#6'Find: '#21'EditLabel.ParentColor'#8#13'La'
- +'belPosition'#7#6'lpLeft'#8'TabOrder'#2#0#8'OnChange'#7#16'EditSearchChange'
+ +'eft'#2'C'#16'EditLabel.Height'#2#18#13'EditLabel.Top'#2#10#15'EditLabel.Wid'
+ +'th'#2'"'#17'EditLabel.Caption'#6#6'Find: '#21'EditLabel.ParentColor'#8#13'L'
+ +'abelPosition'#7#6'lpLeft'#8'TabOrder'#2#0#8'OnChange'#7#16'EditSearchChange'
+#7'OnEnter'#7#22'LabeledEditSearchEnter'#6'OnExit'#7#21'LabeledEditSearchExi'
+'t'#9'OnKeyDown'#7#24'LabeledEditSearchKeyDown'#10'OnKeyPress'#7#25'LabeledE'
+'ditSearchKeyPress'#0#0#9'TCheckBox'#17'CheckBoxMatchCase'#4'Left'#3'@'#1#6
- +'Height'#2#20#3'Top'#2#7#5'Width'#2'`'#7'Caption'#6#10'Match case'#7'OnClick'
+ +'Height'#2#22#3'Top'#2#7#5'Width'#2'a'#7'Caption'#6#10'Match case'#7'OnClick'
+#7#22'CheckBoxMatchCaseClick'#8'TabOrder'#2#1#0#0#0#0#9'TMainMenu'#9'MainMen'
+'u1'#4'left'#3#16#2#0#9'TMenuItem'#8'MenuFile'#7'Caption'#6#5'&File'#13'SubM'
+'enuImages'#7#17'Mufasa_Image_List'#0#9'TMenuItem'#11'MenuItemNew'#6'Action'
diff --git a/Projects/SAMufasaGUI/testunit.pas b/Projects/SAMufasaGUI/testunit.pas
index 2a326e5..966ade6 100644
--- a/Projects/SAMufasaGUI/testunit.pas
+++ b/Projects/SAMufasaGUI/testunit.pas
@@ -398,7 +398,8 @@ begin
ScriptThread.Client.MWindow.SetWindow(Self.Window);
// we MUST set the OCR Path
- writeln(IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)) + DS + 'Fonts' + DS);
+ writeln(IncludeTrailingPathDelimiter(
+ ExpandFileName('TestUnit: OCR Path... ' + MainDir +DS + '..' + DS + '..' + ds)) + DS + 'Fonts' + DS);
ScriptThread.Client.MOCR.InitTOCR(IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)) + 'Fonts' + DS);
ScriptThread.OnTerminate:=@ScriptThreadTerminate;
diff --git a/Units/MMLCore/ocr.pas b/Units/MMLCore/ocr.pas
index f9c2eee..21cedbb 100644
--- a/Units/MMLCore/ocr.pas
+++ b/Units/MMLCore/ocr.pas
@@ -38,7 +38,7 @@ uses
constructor Create(Owner: TObject);
destructor Destroy; override;
function InitTOCR(path: string): boolean;
-
+ function getTextPointsIn(sx, sy, w, h: Integer): TNormArray;
function GetUpTextAt(atX, atY: integer): string;
private
Client: TObject;
@@ -50,7 +50,187 @@ uses
implementation
uses
- client;
+ colour_conv, client, files;
+
+const
+ ocr_Limit_High = 191;
+ ocr_Limit_Low = 65;
+
+ ocr_White = 16777215;
+ ocr_Green = 65280;
+ ocr_Red = 255;
+ ocr_Yellow = 65535;
+ ocr_Blue = 16776960;
+ ocr_ItemC = 16744447;
+
+ ocr_Purple = 8388736;
+
+
+{
+ Non optimised. ;-)
+}
+
+function TMOCR.getTextPointsIn(sx, sy, w, h: Integer): TNormArray;
+var
+ bmp: TMufasaBitmap;
+ x,y: integer;
+ r,g,b: integer;
+ n: TNormArray;
+
+begin
+ bmp := TMufasaBitmap.Create;
+ bmp.CopyClientToBitmap(TClient(Client).MWindow, True, sx, sy, sx + w - 1, sy + h - 1);
+
+ bmp.SaveToFile('/tmp/ocrinit.bmp');
+ for y := 0 to bmp.Height - 1 do
+ for x := 0 to bmp.Width - 1 do
+ begin
+ colortorgb(bmp.fastgetpixel(x,y),r,g,b);
+ // the abs(g-b) < 15 seems to help heaps when taking out crap points
+ if (r > ocr_Limit_High) and (g > ocr_Limit_High) and (b > ocr_Limit_High){ and (abs(g-b) < 15)} then
+ begin
+ bmp.fastsetpixel(x,y,ocr_White);
+ continue;
+ end;
+ if (r < ocr_Limit_Low) and (g > ocr_Limit_High) and (b > ocr_Limit_High) then
+ begin
+ bmp.fastsetpixel(x,y,ocr_Blue);
+ continue;
+ end;
+ if (r < ocr_Limit_Low) and (g > ocr_Limit_High) and (b < ocr_Limit_Low) then
+ begin
+ bmp.fastsetpixel(x,y,ocr_Green);
+ continue;
+ end;
+
+ // false results with fire
+ if(r > ocr_Limit_High) and (g > 100) and (g < ocr_Limit_High) and (b > 40) and (b < 90) then
+ begin
+ bmp.fastsetpixel(x,y,ocr_ItemC);
+ continue;
+ end;
+ if(r > ocr_Limit_High) and (g > ocr_Limit_High) and (b < ocr_Limit_Low) then
+ begin
+ bmp.fastsetpixel(x,y,ocr_Yellow);
+ continue;
+ end;
+ // better use g < 40 than ocr_Limit_Low imo
+ if (r > ocr_Limit_High) and (g < ocr_Limit_Low) and (b < ocr_Limit_Low) then
+ begin
+ bmp.fastsetpixel(x,y,ocr_Red);
+ continue;
+ end;
+
+ if (r < ocr_Limit_Low) and (g < ocr_Limit_Low) and (b < ocr_Limit_Low) then
+ begin
+ bmp.FastSetPixel(x,y, ocr_Purple);
+ continue;
+ end;
+
+ bmp.fastsetpixel(x,y,0);
+ end;
+
+ // increase height by 1, so our algo works better.
+ bmp.SetSize(Bmp.Width, Bmp.Height+1);
+ for x := 0 to bmp.width -1 do
+ bmp.fastsetpixel(x,bmp.height-1,0);
+
+ bmp.SaveToFile('/tmp/ocrcol.bmp');
+
+ for y := 0 to bmp.Height - 2 do
+ for x := 0 to bmp.Width - 2 do
+ begin
+ if bmp.fastgetpixel(x,y) = clPurple then
+ continue;
+ if bmp.fastgetpixel(x,y) = clBlack then
+ continue;
+ if (bmp.fastgetpixel(x,y) <> bmp.fastgetpixel(x+1,y+1)) and (bmp.fastgetpixel(x+1,y+1) <> clpurple) then
+ bmp.fastsetpixel(x,y,{clAqua}0);
+ end;
+
+ { Optional - remove false shadow }
+ for y := bmp.Height - 1 downto 1 do
+ for x := bmp.Width - 1 downto 1 do
+ begin
+ if bmp.fastgetpixel(x,y) <> clPurple then
+ continue;
+ if bmp.fastgetpixel(x,y) = bmp.fastgetpixel(x-1,y-1) then
+ begin
+ bmp.fastsetpixel(x,y,clSilver);
+ continue;
+ end;
+ if bmp.fastgetpixel(x-1,y-1) = 0 then
+ bmp.fastsetpixel(x,y,clSilver);
+ end;
+
+ { remove bad points }
+ for y := bmp.Height - 2 downto 1 do
+ for x := bmp.Width - 2 downto 1 do
+ begin
+ if bmp.fastgetpixel(x,y) = clPurple then
+ continue;
+ if bmp.fastgetpixel(x,y) = clBlack then
+ continue;
+ if (bmp.fastgetpixel(x,y) = bmp.fastgetpixel(x+1,y+1) ) then
+ continue;
+
+ if bmp.fastgetpixel(x+1,y+1) <> clPurple then
+ begin
+ bmp.fastsetpixel(x,y,clOlive);
+ continue;
+ end;
+ end;
+
+ { remove debug ;) }
+
+ for y := 0 to bmp.Height - 1 do
+ for x := 0 to bmp.Width - 1 do
+ begin
+ if bmp.fastgetpixel(x,y) = clPurple then
+ begin
+ bmp.FastSetPixel(x,y,0);
+ continue;
+ end;
+ if bmp.fastgetpixel(x,y) = clOlive then
+ begin
+ bmp.FastSetPixel(x,y,0);
+ continue;
+ end;
+ if bmp.fastgetpixel(x,y) = clSilver then
+ begin
+ bmp.FastSetPixel(x,y,0);
+ continue;
+ end;
+ end;
+
+ setlength(n, bmp.Height * bmp.Width);
+
+ for y := 0 to bmp.Height - 1 do
+ for x := 0 to bmp.Width - 1 do
+ begin
+ if bmp.fastgetpixel(x,y) > 0 then
+ n[x + y * bmp.width] := 1
+ else
+ n[x + y * bmp.width] := 0;
+ end;
+
+ result := n;
+ bmp.SaveToFile('/tmp/ocrfinal.bmp');
+ bmp.Free;
+ { Dangerous removes all pixels that had no pixels on x-1 or x+1}
+ { for y := 0 to bmp.Height - 2 do
+ for x := 1 to bmp.Width - 2 do
+ begin
+ if bmp.fastgetpixel(x,y) = clBlack then continue;
+ if bmp.fastgetpixel(x,y) = clPurple then continue;
+ if bmp.fastgetpixel(x,y) = clOlive then continue;
+ if bmp.fastgetpixel(x,y) = clSilver then continue;
+ if bmp.fastgetpixel(x,y) = clLime then continue;
+ if (bmp.fastgetpixel(x,y) <> bmp.fastgetpixel(x+1,y) ) and
+ (bmp.fastgetpixel(x,y) <> bmp.fastgetpixel(x-1,y) ) then
+ bmp.fastsetpixel(x,y,clFuchsia);
+ end; }
+end;
constructor TMOCR.Create(Owner: TObject);
@@ -63,7 +243,7 @@ begin
SetLength(OCRData, 0);
- //files := GetFiles('/home/merlijn/Programs/mufasa/UpText/upchars', 'bmp');
+ //files := GetFiles('/home/merlijn/Programs/mufasa/ben/upchars', 'bmp');
end;
@@ -91,6 +271,65 @@ end;
function TMOCR.GetUpTextAt(atX, atY: integer): string;
+var
+ n:Tnormarray;
+ ww, hh: integer;
+
+begin
+ ww := 400;
+ hh := 20;
+
+ n := getTextPointsIn(atX, atY, ww, hh);
+ Result := ocrDetect(n, ww, hh, OCRData[0]);
+ writeln(result);
+end;
+{
+function TMOCR.GetUpTextAt(atX, atY: integer): string;
+
+var
+ t: tpointarray;
+ b: TMufasaBitmap;
+ i,len,ww,hh: integer;
+ p:Prgb32;
+ n:Tnormarray;
+
+begin
+ t:=MakeTPAString('01:44 < mixster> Wizzup: Lies! How can my laptop handle that as well as playing music if even ownage machines suffer from it?');
+ writeln(inttostr(length(t)));
+ b := TMufasaBitmap.Create;
+ b.SetSize(1000,1000);
+ for i := 0 to high(t) do
+ b.FastSetPixel(t[i].x, t[i].y, clwhite);
+ b.SaveToFile('/tmp/hoi.bmp');
+
+ ww := b.width;
+ hh := b.height;
+
+ p := b.FData;
+ len := ww * hh;
+ setlength(n, ww * hh);
+
+ for i := 0 to len - 1 do
+ begin
+ if((p^.R = 255) and (p^.B = 255) and (p^.G = 255)) //white
+ or((p^.R = 255) and (p^.B < 2) and (p^.G < 2)) //red
+ or((p^.R = 0) and (p^.B = 255) and (p^.G = 255)) //cyan
+ or((p^.R = 255) and (p^.B = 0) and (p^.G = 255)) //yellow
+ or((p^.R = 0) and (p^.B = 0) and (p^.G = 255)) then //green
+ n[i] := 1
+ else
+ n[i] := 0;
+ Inc(P);
+ end;
+
+ Result := ocrDetect(n, b.Width, b.Height, OCRData[0]);
+ writeln(result);
+
+
+end; }
+ {
+function TMOCR.GetUpTextAt(atX, atY: integer): string;
+
var
bmp: TMufasaBitmap;
n: TNormArray;
@@ -155,6 +394,6 @@ begin
bmp.Free;
end;
-
+ }
end.
diff --git a/Units/MMLCore/ocrutil.pas b/Units/MMLCore/ocrutil.pas
index b55279a..5944b71 100644
--- a/Units/MMLCore/ocrutil.pas
+++ b/Units/MMLCore/ocrutil.pas
@@ -60,6 +60,7 @@ type
function ImageToNorm(src: tRGBArray; w,h: integer): TNormArray;
function ocrDetect(txt: TNormArray; w,h: integer; var ocrdata: TocrData): string;
function ExtractText(colors: PRGB32;{colors: tRGBArray;} w,h: integer): TNormArray;
+ function MakeTPAString(str: string): TpointArray;
implementation
uses
@@ -581,5 +582,32 @@ begin
result:= norm;
end;
+function MakeTPAString(str: string): TpointArray;
+var
+ i,j,c,off: integer;
+ bmp: array of Tbmp;
+begin
+ raise Exception.Create('MakeTPAString sucks ass, don''t use it.');
+ c:= 0;
+ off:= 0;
+ SetLength(bmp,length(str));
+ for i:= 0 to length(str)-1 do
+ begin
+ bmp[i]:= ReadBmp('/home/merlijn/Programs/mufasa/Fonts/UpChars/' + inttostr(ord(str[i+1])) + '.bmp');
+ SetLength(result,c+bmp[i].width*bmp[i].height);
+ for j:= 0 to bmp[i].width*bmp[i].height - 1 do
+ begin
+ if bmp[i].data[j].g = 255 then
+ begin
+ result[c].x:= j mod bmp[i].width + off;
+ result[c].y:= j div bmp[i].width;
+ inc(c);
+ end;
+ end;
+ off:= off + bmp[i].width;
+ SetLength(result,c);
+ end;
+end;
+
end.