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 @@ <UseXPManifest Value="True"/> - <ActiveEditorIndexAtStart Value="7"/> + <ActiveEditorIndexAtStart Value="8"/> </General> <VersionInfo> <ProjectVersion Value=""/> @@ -36,14 +36,14 @@ <PackageName Value="LCL"/> </Item2> </RequiredPackages> - <Units Count="260"> + <Units Count="263"> <Unit0> <Filename Value="project1.lpr"/> <IsPartOfProject Value="True"/> <UnitName Value="project1"/> <CursorPos X="100" Y="21"/> <TopLine Value="6"/> - <EditorIndex Value="10"/> + <EditorIndex Value="12"/> <UsageCount Value="205"/> <Loaded Value="True"/> </Unit0> @@ -168,8 +168,8 @@ <ResourceBaseClass Value="Form"/> <UnitName Value="TestUnit"/> <ComponentState Value="1"/> - <CursorPos X="55" Y="46"/> - <TopLine Value="1"/> + <CursorPos X="1" Y="403"/> + <TopLine Value="380"/> <EditorIndex Value="4"/> <UsageCount Value="202"/> <Loaded Value="True"/> @@ -225,8 +225,8 @@ <Filename Value="../../Units/MMLCore/client.pas"/> <IsPartOfProject Value="True"/> <UnitName Value="Client"/> - <CursorPos X="51" Y="41"/> - <TopLine Value="15"/> + <CursorPos X="19" Y="69"/> + <TopLine Value="34"/> <EditorIndex Value="1"/> <UsageCount Value="201"/> <Loaded Value="True"/> @@ -235,8 +235,8 @@ <Filename Value="../../Units/MMLCore/mufasatypes.pas"/> <IsPartOfProject Value="True"/> <UnitName Value="MufasaTypes"/> - <CursorPos X="49" Y="92"/> - <TopLine Value="77"/> + <CursorPos X="47" Y="27"/> + <TopLine Value="27"/> <EditorIndex Value="0"/> <UsageCount Value="201"/> <Loaded Value="True"/> @@ -278,8 +278,8 @@ <UnitName Value="windowutil"/> <CursorPos X="23" Y="8"/> <TopLine Value="1"/> - <EditorIndex Value="14"/> - <UsageCount Value="63"/> + <EditorIndex Value="16"/> + <UsageCount Value="64"/> <Loaded Value="True"/> </Unit31> <Unit32> @@ -317,9 +317,9 @@ <Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/> <IsPartOfProject Value="True"/> <UnitName Value="mmlpsthread"/> - <CursorPos X="44" Y="386"/> - <TopLine Value="358"/> - <EditorIndex Value="15"/> + <CursorPos X="63" Y="188"/> + <TopLine Value="298"/> + <EditorIndex Value="17"/> <UsageCount Value="202"/> <Loaded Value="True"/> </Unit36> @@ -388,7 +388,7 @@ <Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/> <CursorPos X="117" Y="32"/> <TopLine Value="4"/> - <EditorIndex Value="12"/> + <EditorIndex Value="14"/> <UsageCount Value="100"/> <Loaded Value="True"/> </Unit46> @@ -408,8 +408,8 @@ <Filename Value="../../Units/MMLCore/bitmaps.pas"/> <IsPartOfProject Value="True"/> <UnitName Value="bitmaps"/> - <CursorPos X="70" Y="896"/> - <TopLine Value="52"/> + <CursorPos X="6" Y="916"/> + <TopLine Value="888"/> <EditorIndex Value="2"/> <UsageCount Value="200"/> <Loaded Value="True"/> @@ -715,7 +715,7 @@ <UnitName Value="dtm"/> <CursorPos X="62" Y="135"/> <TopLine Value="1"/> - <EditorIndex Value="11"/> + <EditorIndex Value="13"/> <UsageCount Value="200"/> <Loaded Value="True"/> </Unit95> @@ -732,7 +732,7 @@ <UnitName Value="colourpicker"/> <CursorPos X="65" Y="243"/> <TopLine Value="86"/> - <EditorIndex Value="8"/> + <EditorIndex Value="10"/> <UsageCount Value="201"/> <Loaded Value="True"/> </Unit97> @@ -793,7 +793,7 @@ <UnitName Value="dtmutil"/> <CursorPos X="1" Y="1"/> <TopLine Value="151"/> - <EditorIndex Value="9"/> + <EditorIndex Value="11"/> <UsageCount Value="206"/> <Loaded Value="True"/> </Unit105> @@ -808,8 +808,8 @@ <Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/> <CursorPos X="33" Y="34"/> <TopLine Value="30"/> - <EditorIndex Value="13"/> - <UsageCount Value="22"/> + <EditorIndex Value="15"/> + <UsageCount Value="23"/> <Loaded Value="True"/> </Unit107> <Unit108> @@ -873,9 +873,11 @@ <Filename Value="../../Units/MMLCore/ocr.pas"/> <IsPartOfProject Value="True"/> <UnitName Value="ocr"/> - <CursorPos X="54" Y="645"/> - <TopLine Value="633"/> + <CursorPos X="59" Y="79"/> + <TopLine Value="58"/> + <EditorIndex Value="8"/> <UsageCount Value="200"/> + <Loaded Value="True"/> </Unit116> <Unit117> <Filename Value="../../Units/PascalScript/uPSR_extctrls.pas"/> @@ -1003,7 +1005,7 @@ <UnitName Value="web"/> <CursorPos X="1" Y="1"/> <TopLine Value="1"/> - <UsageCount Value="171"/> + <UsageCount Value="174"/> </Unit136> <Unit137> <Filename Value="../../../lazarus/lcl/lazhelphtml.pas"/> @@ -1202,7 +1204,7 @@ <UnitName Value="framescript"/> <CursorPos X="106" Y="190"/> <TopLine Value="180"/> - <UsageCount Value="164"/> + <UsageCount Value="167"/> </Unit161> <Unit162> <Filename Value="framesynedit.lrs"/> @@ -1518,7 +1520,7 @@ <CursorPos X="72" Y="21"/> <TopLine Value="13"/> <EditorIndex Value="5"/> - <UsageCount Value="101"/> + <UsageCount Value="104"/> <Loaded Value="True"/> </Unit208> <Unit209> @@ -1769,7 +1771,7 @@ <UnitName Value="about"/> <CursorPos X="44" Y="21"/> <TopLine Value="4"/> - <UsageCount Value="64"/> + <UsageCount Value="67"/> </Unit245> <Unit246> <Filename Value="../../Units/MMLAddon/PSInc/Wrappers/file.inc"/> @@ -1783,7 +1785,7 @@ <UnitName Value="internets"/> <CursorPos X="87" Y="3"/> <TopLine Value="1"/> - <UsageCount Value="58"/> + <UsageCount Value="61"/> </Unit247> <Unit248> <Filename Value="debugimageform.pas"/> @@ -1792,7 +1794,7 @@ <UnitName Value="debugimageform"/> <CursorPos X="20" Y="1"/> <TopLine Value="1"/> - <UsageCount Value="45"/> + <UsageCount Value="48"/> </Unit248> <Unit249> <Filename Value="debugimage.pas"/> @@ -1804,7 +1806,7 @@ <CursorPos X="87" Y="39"/> <TopLine Value="20"/> <EditorIndex Value="6"/> - <UsageCount Value="44"/> + <UsageCount Value="47"/> <Loaded Value="True"/> </Unit249> <Unit250> @@ -1873,127 +1875,149 @@ <UsageCount Value="10"/> <SyntaxHighlighter Value="XML"/> </Unit259> + <Unit260> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <UnitName Value="ocrutil"/> + <CursorPos X="36" Y="338"/> + <TopLine Value="318"/> + <EditorIndex Value="9"/> + <UsageCount Value="11"/> + <Loaded Value="True"/> + </Unit260> + <Unit261> + <Filename Value="../../../../Documents/fpc/rtl/objpas/sysutils/filutilh.inc"/> + <CursorPos X="25" Y="87"/> + <TopLine Value="62"/> + <UsageCount Value="10"/> + </Unit261> + <Unit262> + <Filename Value="../../../../Documents/lazarus/lcl/graphics.pp"/> + <UnitName Value="Graphics"/> + <CursorPos X="69" Y="249"/> + <TopLine Value="236"/> + <UsageCount Value="10"/> + </Unit262> </Units> <JumpHistory Count="30" HistoryIndex="29"> <Position1> - <Filename Value="testunit.pas"/> - <Caret Line="993" Column="49" TopLine="736"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="584" Column="53" TopLine="572"/> </Position1> <Position2> - <Filename Value="testunit.pas"/> - <Caret Line="817" Column="39" TopLine="23"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="24" Column="43" TopLine="2"/> </Position2> <Position3> - <Filename Value="testunit.pas"/> - <Caret Line="24" Column="53" TopLine="1"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="108" Column="70" TopLine="85"/> </Position3> <Position4> - <Filename Value="colourhistory.pas"/> - <Caret Line="7" Column="88" TopLine="1"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="71" Column="34" TopLine="64"/> </Position4> <Position5> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="162" Column="14" TopLine="132"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="168" Column="40" TopLine="148"/> </Position5> <Position6> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="47" Column="69" TopLine="36"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="589" Column="26" TopLine="570"/> </Position6> <Position7> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="51" Column="33" TopLine="36"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="155" Column="24" TopLine="145"/> </Position7> <Position8> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="153" Column="37" TopLine="133"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="226" Column="29" TopLine="201"/> </Position8> <Position9> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="111" Column="51" TopLine="92"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="602" Column="13" TopLine="574"/> </Position9> <Position10> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="180" Column="19" TopLine="160"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="604" Column="35" TopLine="575"/> </Position10> <Position11> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="182" Column="30" TopLine="160"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="99" Column="31" TopLine="67"/> </Position11> <Position12> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="179" Column="65" TopLine="152"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="102" Column="16" TopLine="79"/> </Position12> <Position13> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="180" Column="9" TopLine="152"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="605" Column="23" TopLine="579"/> </Position13> <Position14> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="182" Column="25" TopLine="152"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="63" Column="64" TopLine="37"/> </Position14> <Position15> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="183" Column="8" TopLine="152"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="588" Column="21" TopLine="572"/> </Position15> <Position16> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="184" Column="8" TopLine="152"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="48" Column="44" TopLine="25"/> </Position16> <Position17> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="202" Column="10" TopLine="182"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="106" Column="30" TopLine="94"/> </Position17> <Position18> - <Filename Value="../../Units/MMLAddon/colourpicker.pas"/> - <Caret Line="240" Column="10" TopLine="220"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="100" Column="25" TopLine="80"/> </Position18> <Position19> - <Filename Value="../../Units/MMLCore/bitmaps.pas"/> - <Caret Line="376" Column="10" TopLine="358"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="178" Column="1" TopLine="138"/> </Position19> <Position20> - <Filename Value="../../Units/MMLCore/bitmaps.pas"/> - <Caret Line="49" Column="28" TopLine="29"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="99" Column="17" TopLine="90"/> </Position20> <Position21> - <Filename Value="../../Units/MMLCore/bitmaps.pas"/> - <Caret Line="376" Column="16" TopLine="356"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="110" Column="9" TopLine="90"/> </Position21> <Position22> - <Filename Value="../../Units/MMLCore/bitmaps.pas"/> - <Caret Line="389" Column="18" TopLine="356"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="97" Column="9" TopLine="91"/> </Position22> <Position23> - <Filename Value="../../Units/MMLCore/bitmaps.pas"/> - <Caret Line="396" Column="16" TopLine="376"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="111" Column="24" TopLine="91"/> </Position23> <Position24> - <Filename Value="../../Units/MMLCore/bitmaps.pas"/> - <Caret Line="408" Column="18" TopLine="376"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="130" Column="60" TopLine="103"/> </Position24> <Position25> - <Filename Value="../../Units/MMLCore/bitmaps.pas"/> - <Caret Line="448" Column="16" TopLine="428"/> + <Filename Value="../../Units/MMLCore/ocrutil.pas"/> + <Caret Line="61" Column="23" TopLine="49"/> </Position25> <Position26> - <Filename Value="../../Units/MMLCore/finder.pas"/> - <Caret Line="581" Column="23" TopLine="566"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="177" Column="3" TopLine="158"/> </Position26> <Position27> - <Filename Value="../../Units/MMLCore/finder.pas"/> - <Caret Line="548" Column="15" TopLine="544"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="241" Column="38" TopLine="218"/> </Position27> <Position28> - <Filename Value="../../Units/MMLCore/finder.pas"/> - <Caret Line="856" Column="14" TopLine="854"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="229" Column="60" TopLine="146"/> </Position28> <Position29> - <Filename Value="../../Units/MMLCore/finder.pas"/> - <Caret Line="848" Column="22" TopLine="836"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="241" Column="41" TopLine="161"/> </Position29> <Position30> - <Filename Value="../../Units/MMLCore/finder.pas"/> - <Caret Line="856" Column="37" TopLine="837"/> + <Filename Value="../../Units/MMLCore/ocr.pas"/> + <Caret Line="200" Column="34" TopLine="178"/> </Position30> </JumpHistory> </ProjectOptions> 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.