1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-04 16:35:15 -05:00

Removed TMWindow.CopyClientToBitmap - please use

TMufasaBitmap.CopyClientToBitmap.
Added a "Set Client" feature to OCRBench, so you can test on runescape.
Also added TMufasaBitmap.ToTBitmap.



git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@325 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2009-12-23 18:45:03 +00:00
parent 00d53d8aed
commit a9f52ec1c7
8 changed files with 304 additions and 423 deletions

View File

@ -7,7 +7,7 @@
<TargetFileExt Value=""/>
<Icon Value="0"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="0"/>
<ActiveEditorIndexAtStart Value="1"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -31,12 +31,12 @@
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="15">
<Units Count="18">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="project1"/>
<UsageCount Value="50"/>
<UsageCount Value="59"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
@ -44,10 +44,10 @@
<ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
<CursorPos X="4" Y="127"/>
<TopLine Value="43"/>
<CursorPos X="48" Y="86"/>
<TopLine Value="90"/>
<EditorIndex Value="0"/>
<UsageCount Value="50"/>
<UsageCount Value="59"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
@ -75,17 +75,17 @@
<UnitName Value="Client"/>
<CursorPos X="25" Y="50"/>
<TopLine Value="31"/>
<EditorIndex Value="2"/>
<UsageCount Value="26"/>
<EditorIndex Value="3"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<UnitName Value="ocr"/>
<CursorPos X="66" Y="365"/>
<TopLine Value="341"/>
<EditorIndex Value="4"/>
<UsageCount Value="26"/>
<CursorPos X="10" Y="583"/>
<TopLine Value="375"/>
<EditorIndex Value="5"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
</Unit5>
<Unit6>
@ -93,17 +93,17 @@
<UnitName Value="bitmaps"/>
<CursorPos X="18" Y="81"/>
<TopLine Value="47"/>
<EditorIndex Value="8"/>
<UsageCount Value="25"/>
<EditorIndex Value="10"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
<UnitName Value="ocrutil"/>
<CursorPos X="54" Y="198"/>
<TopLine Value="115"/>
<EditorIndex Value="1"/>
<UsageCount Value="25"/>
<CursorPos X="45" Y="281"/>
<TopLine Value="249"/>
<EditorIndex Value="2"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
@ -117,8 +117,8 @@
<UnitName Value="tpa"/>
<CursorPos X="5" Y="557"/>
<TopLine Value="535"/>
<EditorIndex Value="7"/>
<UsageCount Value="23"/>
<EditorIndex Value="9"/>
<UsageCount Value="27"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
@ -126,8 +126,8 @@
<UnitName Value="mufasatypesutil"/>
<CursorPos X="23" Y="23"/>
<TopLine Value="1"/>
<EditorIndex Value="6"/>
<UsageCount Value="22"/>
<EditorIndex Value="7"/>
<UsageCount Value="26"/>
<Loaded Value="True"/>
</Unit10>
<Unit11>
@ -135,8 +135,8 @@
<UnitName Value="finder"/>
<CursorPos X="78" Y="455"/>
<TopLine Value="432"/>
<EditorIndex Value="3"/>
<UsageCount Value="19"/>
<EditorIndex Value="4"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
@ -156,131 +156,156 @@
<UnitName Value="files"/>
<CursorPos X="7" Y="103"/>
<TopLine Value="73"/>
<EditorIndex Value="5"/>
<UsageCount Value="16"/>
<EditorIndex Value="6"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit14>
<Unit15>
<Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<UnitName Value="colourpicker"/>
<CursorPos X="20" Y="56"/>
<TopLine Value="37"/>
<UsageCount Value="10"/>
</Unit15>
<Unit16>
<Filename Value="../../Units/MMLAddon/windowselector.pas"/>
<UnitName Value="windowselector"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="8"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit16>
<Unit17>
<Filename Value="../../Units/MMLCore/window.pas"/>
<UnitName Value="Window"/>
<CursorPos X="5" Y="433"/>
<TopLine Value="423"/>
<EditorIndex Value="1"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit17>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="588" Column="7" TopLine="575"/>
<Caret Line="597" Column="18" TopLine="576"/>
</Position1>
<Position2>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="585" Column="7" TopLine="563"/>
<Caret Line="601" Column="7" TopLine="576"/>
</Position2>
<Position3>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="64" Column="27" TopLine="49"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="581" Column="39" TopLine="564"/>
</Position3>
<Position4>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="65" Column="27" TopLine="49"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="594" Column="7" TopLine="574"/>
</Position4>
<Position5>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="583" Column="67" TopLine="551"/>
<Caret Line="622" Column="79" TopLine="588"/>
</Position5>
<Position6>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="597" Column="18" TopLine="576"/>
<Filename Value="unit1.pas"/>
<Caret Line="54" Column="20" TopLine="1"/>
</Position6>
<Position7>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="601" Column="7" TopLine="576"/>
<Filename Value="unit1.pas"/>
<Caret Line="53" Column="20" TopLine="15"/>
</Position7>
<Position8>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="581" Column="39" TopLine="564"/>
<Filename Value="unit1.pas"/>
<Caret Line="45" Column="65" TopLine="39"/>
</Position8>
<Position9>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="594" Column="7" TopLine="574"/>
<Filename Value="unit1.pas"/>
<Caret Line="119" Column="5" TopLine="93"/>
</Position9>
<Position10>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="622" Column="79" TopLine="588"/>
<Filename Value="unit1.pas"/>
<Caret Line="30" Column="68" TopLine="6"/>
</Position10>
<Position11>
<Filename Value="unit1.pas"/>
<Caret Line="54" Column="20" TopLine="1"/>
<Caret Line="105" Column="3" TopLine="73"/>
</Position11>
<Position12>
<Filename Value="unit1.pas"/>
<Caret Line="53" Column="20" TopLine="15"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="12" Column="77" TopLine="1"/>
</Position12>
<Position13>
<Filename Value="unit1.pas"/>
<Caret Line="45" Column="65" TopLine="39"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="37" Column="77" TopLine="26"/>
</Position13>
<Position14>
<Filename Value="unit1.pas"/>
<Caret Line="119" Column="5" TopLine="93"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="619" Column="28" TopLine="592"/>
</Position14>
<Position15>
<Filename Value="unit1.pas"/>
<Caret Line="30" Column="68" TopLine="6"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="527" Column="41" TopLine="496"/>
</Position15>
<Position16>
<Filename Value="unit1.pas"/>
<Caret Line="105" Column="3" TopLine="73"/>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
<Caret Line="57" Column="21" TopLine="37"/>
</Position16>
<Position17>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="12" Column="77" TopLine="1"/>
<Caret Line="467" Column="18" TopLine="448"/>
</Position17>
<Position18>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="37" Column="77" TopLine="26"/>
<Filename Value="../../Units/MMLAddon/tpa.pas"/>
<Caret Line="50" Column="33" TopLine="30"/>
</Position18>
<Position19>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="619" Column="28" TopLine="592"/>
<Filename Value="unit1.pas"/>
<Caret Line="111" Column="35" TopLine="97"/>
</Position19>
<Position20>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="527" Column="41" TopLine="496"/>
<Caret Line="468" Column="38" TopLine="445"/>
</Position20>
<Position21>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
<Caret Line="57" Column="21" TopLine="37"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="469" Column="26" TopLine="445"/>
</Position21>
<Position22>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="467" Column="18" TopLine="448"/>
<Caret Line="486" Column="18" TopLine="467"/>
</Position22>
<Position23>
<Filename Value="../../Units/MMLAddon/tpa.pas"/>
<Caret Line="50" Column="33" TopLine="30"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="634" Column="41" TopLine="293"/>
</Position23>
<Position24>
<Filename Value="unit1.pas"/>
<Caret Line="111" Column="35" TopLine="97"/>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="191" Column="50" TopLine="183"/>
</Position24>
<Position25>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="384" Column="34" TopLine="445"/>
<Filename Value="unit1.pas"/>
<Caret Line="9" Column="66" TopLine="1"/>
</Position25>
<Position26>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="468" Column="38" TopLine="445"/>
<Filename Value="unit1.pas"/>
<Caret Line="34" Column="16" TopLine="1"/>
</Position26>
<Position27>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="469" Column="26" TopLine="445"/>
<Filename Value="unit1.pas"/>
<Caret Line="149" Column="13" TopLine="117"/>
</Position27>
<Position28>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="486" Column="18" TopLine="467"/>
<Filename Value="unit1.pas"/>
<Caret Line="135" Column="69" TopLine="124"/>
</Position28>
<Position29>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="634" Column="41" TopLine="293"/>
<Caret Line="340" Column="78" TopLine="325"/>
</Position29>
<Position30>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="191" Column="50" TopLine="183"/>
<Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="62" Column="64" TopLine="46"/>
</Position30>
</JumpHistory>
</ProjectOptions>
@ -305,9 +330,7 @@
</Debugging>
</Linking>
<Other>
<CustomOptions Value="-dOCRDEBUG
-dOCRTPA
-dOCRSAVEBITMAP"/>
<CustomOptions Value="-dOCRDEBUG"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>

View File

@ -50,6 +50,15 @@ object Form1: TForm1
Caption = 'Shadow?'
TabOrder = 3
end
object ClientButton: TToggleBox
Left = 512
Height = 23
Top = 144
Width = 88
Caption = 'Set Client'
OnMouseDown = SelectClient
TabOrder = 4
end
object OCRFileOpen: TOpenDialog
Filter = '.bmp'
left = 416

View File

@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Client, MufasaTypes, Bitmaps, ocr;
StdCtrls, ExtCtrls, Client, MufasaTypes, Bitmaps, ocr, windowselector,window;
type
@ -19,14 +19,20 @@ type
OCRButton: TButton;
Image1: TImage;
OCRFileOpen: TOpenDialog;
ClientButton: TToggleBox;
UpCharsDialog: TSelectDirectoryDialog;
procedure BitmapButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure OCRButtonClick(Sender: TObject);
procedure PathButtonClick(Sender: TObject);
procedure SelectClient(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
BitmapPath: String;
FontPath: String;
CliW: TMWindow;
UseClient: Boolean;
{ private declarations }
public
{ public declarations }
@ -52,7 +58,7 @@ Var
t: dword;
begin
if not FileExists(BitmapPath) then
if not FileExists(BitmapPath) and not UseClient then
begin
MessageBox(0,pchar('You did not set a valid bitmap'), Pchar('Bitmap Error'),
MB_OK);
@ -75,7 +81,10 @@ begin
// create and init client
C := TClient.Create;
bmp := TMufasaBitmap.Create;
bmp.LoadFromFile(BitmapPath);
if UseClient then
C.MWindow.SetWindow(CliW)
else
bmp.LoadFromFile(BitmapPath);
C.MWindow.SetTarget(bmp);
Shadow :=FShadow.Checked;
@ -84,13 +93,13 @@ begin
// only.
C.MOCR.InitTOCR(FontPath + DS, Shadow);
{$IFDEF OCRDEBUG}
t:=gettickcount;
{$ENDIF}
s := C.MOCR.GetUpTextAtEx(7, 7, Shadow);
{$IFDEF OCRDEBUG}
s := C.MOCR.GetUpTextAtEx(5, 5, Shadow);
writeln(inttostr(gettickcount-t));
{$ENDIF}
// write to debugbmp
{$IFDEF OCRDEBUG}
@ -119,13 +128,17 @@ end;
procedure TForm1.BitmapButtonClick(Sender: TObject);
begin
if OCRFileOpen.Execute then
begin
BitmapPath := OCRFileOpen.FileName;
UseClient:=False;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
{BitmapPath := '/home/merlijn/Programs/mufasa/pics/uptext4.bmp';
FontPath := '/home/merlijn/Programs/mufasa/Fonts/';}
UseClient := False;
{BitmapPath := '/home/merlijn/Programs/mufasa/pics/uptext4.bmp'; }
FontPath := '/home/merlijn/Programs/mufasa/Fonts/';
end;
procedure TForm1.PathButtonClick(Sender: TObject);
@ -134,6 +147,19 @@ begin
FontPath := UpCharsDialog.FileName;
end;
procedure TForm1.SelectClient(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
Var
WS: TMWindowSelector;
begin
UseClient := True;
if not assigned(CliW) then
CliW := TMWindow.Create;
WS := TMWindowSelector.Create(CliW);
CliW.SetTarget(WS.Drag);
end;
initialization
{$I unit1.lrs}

View File

@ -10,7 +10,7 @@
<TargetFileExt Value=""/>
<Title Value="Mufasa Stand Alone"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="7"/>
<ActiveEditorIndexAtStart Value="15"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -43,7 +43,7 @@
<UnitName Value="project1"/>
<CursorPos X="100" Y="21"/>
<TopLine Value="6"/>
<EditorIndex Value="15"/>
<EditorIndex Value="17"/>
<UsageCount Value="205"/>
<Loaded Value="True"/>
</Unit0>
@ -110,14 +110,14 @@
<UnitName Value="Graphics"/>
<CursorPos X="15" Y="1287"/>
<TopLine Value="1272"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit9>
<Unit10>
<Filename Value="../cogat/Units/CogatUnits/compbitmaps.pas"/>
<UnitName Value="CompBitmaps"/>
<CursorPos X="1" Y="109"/>
<TopLine Value="92"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit10>
<Unit11>
<Filename Value="../Documents/lazarus/lcl/include/rasterimage.inc"/>
@ -196,8 +196,8 @@
<Filename Value="../../Units/MMLCore/client.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Client"/>
<CursorPos X="48" Y="33"/>
<TopLine Value="13"/>
<CursorPos X="101" Y="48"/>
<TopLine Value="48"/>
<EditorIndex Value="1"/>
<UsageCount Value="201"/>
<Loaded Value="True"/>
@ -206,8 +206,8 @@
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="MufasaTypes"/>
<CursorPos X="47" Y="27"/>
<TopLine Value="27"/>
<CursorPos X="32" Y="100"/>
<TopLine Value="147"/>
<EditorIndex Value="0"/>
<UsageCount Value="201"/>
<Loaded Value="True"/>
@ -231,8 +231,8 @@
<Filename Value="../../Units/MMLCore/window.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Window"/>
<CursorPos X="49" Y="283"/>
<TopLine Value="405"/>
<CursorPos X="22" Y="63"/>
<TopLine Value="44"/>
<EditorIndex Value="3"/>
<UsageCount Value="201"/>
<Loaded Value="True"/>
@ -249,7 +249,7 @@
<UnitName Value="windowutil"/>
<CursorPos X="23" Y="8"/>
<TopLine Value="1"/>
<EditorIndex Value="19"/>
<EditorIndex Value="21"/>
<UsageCount Value="89"/>
<Loaded Value="True"/>
</Unit27>
@ -266,7 +266,7 @@
<UnitName Value="finder"/>
<CursorPos X="58" Y="23"/>
<TopLine Value="1"/>
<EditorIndex Value="10"/>
<EditorIndex Value="12"/>
<UsageCount Value="201"/>
<Loaded Value="True"/>
</Unit29>
@ -288,11 +288,9 @@
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="mmlpsthread"/>
<CursorPos X="89" Y="13"/>
<TopLine Value="1"/>
<EditorIndex Value="20"/>
<CursorPos X="59" Y="27"/>
<TopLine Value="5"/>
<UsageCount Value="202"/>
<Loaded Value="True"/>
</Unit32>
<Unit33>
<Filename Value="../../Units/PascalScript/uPSComponent.pas"/>
@ -352,7 +350,7 @@
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<CursorPos X="117" Y="32"/>
<TopLine Value="4"/>
<EditorIndex Value="17"/>
<EditorIndex Value="19"/>
<UsageCount Value="100"/>
<Loaded Value="True"/>
</Unit41>
@ -372,8 +370,8 @@
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="bitmaps"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<CursorPos X="14" Y="82"/>
<TopLine Value="63"/>
<EditorIndex Value="2"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
@ -539,9 +537,11 @@
</Unit68>
<Unit69>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/other.inc"/>
<CursorPos X="1" Y="78"/>
<TopLine Value="1"/>
<CursorPos X="56" Y="46"/>
<TopLine Value="25"/>
<EditorIndex Value="9"/>
<UsageCount Value="41"/>
<Loaded Value="True"/>
</Unit69>
<Unit70>
<Filename Value="../../Units/PascalScript/uPSCompiler.pas"/>
@ -654,7 +654,7 @@
<UnitName Value="dtm"/>
<CursorPos X="62" Y="135"/>
<TopLine Value="1"/>
<EditorIndex Value="16"/>
<EditorIndex Value="18"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
</Unit86>
@ -669,9 +669,9 @@
<Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="colourpicker"/>
<CursorPos X="65" Y="243"/>
<TopLine Value="134"/>
<EditorIndex Value="13"/>
<CursorPos X="93" Y="170"/>
<TopLine Value="155"/>
<EditorIndex Value="15"/>
<UsageCount Value="201"/>
<Loaded Value="True"/>
</Unit88>
@ -698,7 +698,7 @@
<UnitName Value="windowselector"/>
<CursorPos X="54" Y="139"/>
<TopLine Value="116"/>
<EditorIndex Value="12"/>
<EditorIndex Value="14"/>
<UsageCount Value="201"/>
<Loaded Value="True"/>
</Unit91>
@ -734,7 +734,7 @@
<UnitName Value="dtmutil"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="151"/>
<EditorIndex Value="14"/>
<EditorIndex Value="16"/>
<UsageCount Value="206"/>
<Loaded Value="True"/>
</Unit96>
@ -749,7 +749,7 @@
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
<CursorPos X="33" Y="34"/>
<TopLine Value="30"/>
<EditorIndex Value="18"/>
<EditorIndex Value="20"/>
<UsageCount Value="48"/>
<Loaded Value="True"/>
</Unit98>
@ -794,21 +794,21 @@
<UnitName Value="Classes"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit104>
<Unit105>
<Filename Value="../../../Documents/fpc/rtl/unix/sysutils.pp"/>
<UnitName Value="sysutils"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit105>
<Unit106>
<Filename Value="../../../Documents/lazarus/lcl/lclintf.pas"/>
<UnitName Value="LCLIntf"/>
<CursorPos X="51" Y="261"/>
<TopLine Value="251"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit106>
<Unit107>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
@ -816,7 +816,7 @@
<UnitName Value="ocr"/>
<CursorPos X="51" Y="251"/>
<TopLine Value="14"/>
<EditorIndex Value="8"/>
<EditorIndex Value="10"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
</Unit107>
@ -825,7 +825,7 @@
<UnitName Value="uPSR_extctrls"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit108>
<Unit109>
<Filename Value="../../../Documents and Settings/Raymond/Bureaublad/project.pas"/>
@ -885,9 +885,11 @@
</Unit117>
<Unit118>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/window.inc"/>
<CursorPos X="34" Y="35"/>
<TopLine Value="31"/>
<UsageCount Value="9"/>
<CursorPos X="50" Y="41"/>
<TopLine Value="18"/>
<EditorIndex Value="8"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit118>
<Unit119>
<Filename Value="../../../FPC/FPCCheckout/rtl/objpas/classes/compon.inc"/>
@ -947,14 +949,14 @@
<UnitName Value="LazHelpHTML"/>
<CursorPos X="39" Y="89"/>
<TopLine Value="81"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit127>
<Unit128>
<Filename Value="../../../lazarus/lcl/lazhelpintf.pas"/>
<UnitName Value="LazHelpIntf"/>
<CursorPos X="3" Y="455"/>
<TopLine Value="447"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit128>
<Unit129>
<Filename Value="../../../lazarus/components/codetools/codetoolsstrconsts.pas"/>
@ -1137,7 +1139,7 @@
<ComponentName Value="ScriptFrame"/>
<ResourceBaseClass Value="Frame"/>
<UnitName Value="framescript"/>
<CursorPos X="40" Y="103"/>
<CursorPos X="50" Y="108"/>
<TopLine Value="91"/>
<EditorIndex Value="7"/>
<UsageCount Value="200"/>
@ -1280,13 +1282,13 @@
<Filename Value="../../../fpc/rtl/inc/threadh.inc"/>
<CursorPos X="11" Y="135"/>
<TopLine Value="139"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit172>
<Unit173>
<Filename Value="../../../fpc/rtl/inc/thread.inc"/>
<CursorPos X="28" Y="155"/>
<TopLine Value="152"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit173>
<Unit174>
<Filename Value="../../../lazarus/lcl/widgetset/wsextctrls.pp"/>
@ -1307,44 +1309,44 @@
<UnitName Value="GtkWSExtCtrls"/>
<CursorPos X="67" Y="557"/>
<TopLine Value="569"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit176>
<Unit177>
<Filename Value="../../../fpc/rtl/inc/objpash.inc"/>
<CursorPos X="21" Y="184"/>
<TopLine Value="172"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit177>
<Unit178>
<Filename Value="../../../fpc/rtl/objpas/sysutils/osutilsh.inc"/>
<CursorPos X="11" Y="25"/>
<TopLine Value="13"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit178>
<Unit179>
<Filename Value="../../../fpc/rtl/unix/sysutils.pp"/>
<UnitName Value="sysutils"/>
<CursorPos X="3" Y="1075"/>
<TopLine Value="1069"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit179>
<Unit180>
<Filename Value="../../../fpc/rtl/unix/bunxh.inc"/>
<CursorPos X="13" Y="81"/>
<TopLine Value="78"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit180>
<Unit181>
<Filename Value="../../../fpc/rtl/objpas/sysutils/datih.inc"/>
<CursorPos X="11" Y="179"/>
<TopLine Value="158"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit181>
<Unit182>
<Filename Value="../../../fpc/rtl/objpas/sysutils/dati.inc"/>
<CursorPos X="12" Y="258"/>
<TopLine Value="254"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit182>
<Unit183>
<Filename Value="../../../lazarus/lcl/interfaces/wince/wincewsextctrls.pp"/>
@ -1357,13 +1359,13 @@
<Filename Value="../../../fpc/rtl/objpas/classes/classesh.inc"/>
<CursorPos X="21" Y="1436"/>
<TopLine Value="1424"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit184>
<Unit185>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/ocr.inc"/>
<CursorPos X="55" Y="5"/>
<TopLine Value="1"/>
<EditorIndex Value="9"/>
<EditorIndex Value="11"/>
<UsageCount Value="36"/>
<Loaded Value="True"/>
</Unit185>
@ -1371,7 +1373,7 @@
<Filename Value="../../../Documents/lazarus/lcl/interfaces/gtk/gtkwidgetset.inc"/>
<CursorPos X="1" Y="1291"/>
<TopLine Value="1276"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit186>
<Unit187>
<Filename Value="../../../lazarus/ide/lazarusidestrconsts.pas"/>
@ -1413,7 +1415,7 @@
<UnitName Value="SynEditMiscClasses"/>
<CursorPos X="3" Y="193"/>
<TopLine Value="182"/>
<UsageCount Value="0"/>
<UsageCount Value="10"/>
</Unit192>
<Unit193>
<Filename Value="../../Units/Linux/xtest.pas"/>
@ -1817,7 +1819,7 @@
<UnitName Value="ocrutil"/>
<CursorPos X="57" Y="165"/>
<TopLine Value="145"/>
<EditorIndex Value="11"/>
<EditorIndex Value="13"/>
<UsageCount Value="36"/>
<Loaded Value="True"/>
</Unit250>
@ -1891,123 +1893,123 @@
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="testunit.pas"/>
<Caret Line="357" Column="10" TopLine="341"/>
<Caret Line="356" Column="10" TopLine="341"/>
</Position1>
<Position2>
<Filename Value="testunit.pas"/>
<Caret Line="356" Column="10" TopLine="341"/>
<Caret Line="360" Column="101" TopLine="349"/>
</Position2>
<Position3>
<Filename Value="testunit.pas"/>
<Caret Line="355" Column="10" TopLine="341"/>
<Caret Line="346" Column="106" TopLine="343"/>
</Position3>
<Position4>
<Filename Value="testunit.pas"/>
<Caret Line="358" Column="10" TopLine="341"/>
<Caret Line="352" Column="64" TopLine="334"/>
</Position4>
<Position5>
<Filename Value="testunit.pas"/>
<Caret Line="357" Column="10" TopLine="341"/>
<Caret Line="344" Column="35" TopLine="340"/>
</Position5>
<Position6>
<Filename Value="testunit.pas"/>
<Caret Line="356" Column="10" TopLine="341"/>
<Caret Line="367" Column="9" TopLine="356"/>
</Position6>
<Position7>
<Filename Value="testunit.pas"/>
<Caret Line="355" Column="10" TopLine="341"/>
<Caret Line="251" Column="76" TopLine="240"/>
</Position7>
<Position8>
<Filename Value="testunit.pas"/>
<Caret Line="358" Column="10" TopLine="341"/>
<Caret Line="349" Column="59" TopLine="340"/>
</Position8>
<Position9>
<Filename Value="testunit.pas"/>
<Caret Line="357" Column="10" TopLine="341"/>
<Caret Line="346" Column="50" TopLine="334"/>
</Position9>
<Position10>
<Filename Value="testunit.pas"/>
<Caret Line="356" Column="10" TopLine="341"/>
<Caret Line="349" Column="53" TopLine="334"/>
</Position10>
<Position11>
<Filename Value="testunit.pas"/>
<Caret Line="355" Column="10" TopLine="341"/>
<Caret Line="352" Column="38" TopLine="340"/>
</Position11>
<Position12>
<Filename Value="testunit.pas"/>
<Caret Line="358" Column="10" TopLine="341"/>
</Position12>
<Position13>
<Filename Value="testunit.pas"/>
<Caret Line="357" Column="10" TopLine="341"/>
</Position13>
<Position14>
<Filename Value="testunit.pas"/>
<Caret Line="356" Column="10" TopLine="341"/>
</Position14>
<Position15>
<Filename Value="testunit.pas"/>
<Caret Line="355" Column="10" TopLine="341"/>
</Position15>
<Position16>
<Filename Value="testunit.pas"/>
<Caret Line="358" Column="10" TopLine="341"/>
</Position16>
<Position17>
<Filename Value="testunit.pas"/>
<Caret Line="357" Column="10" TopLine="341"/>
</Position17>
<Position18>
<Filename Value="testunit.pas"/>
<Caret Line="356" Column="10" TopLine="341"/>
</Position18>
<Position19>
<Filename Value="testunit.pas"/>
<Caret Line="360" Column="101" TopLine="349"/>
</Position19>
<Position20>
<Filename Value="testunit.pas"/>
<Caret Line="346" Column="106" TopLine="343"/>
</Position20>
<Position21>
<Filename Value="testunit.pas"/>
<Caret Line="352" Column="64" TopLine="334"/>
</Position21>
<Position22>
<Filename Value="testunit.pas"/>
<Caret Line="344" Column="35" TopLine="340"/>
</Position22>
<Position23>
<Filename Value="testunit.pas"/>
<Caret Line="367" Column="9" TopLine="356"/>
</Position23>
<Position24>
<Filename Value="testunit.pas"/>
<Caret Line="251" Column="76" TopLine="240"/>
</Position24>
<Position25>
<Filename Value="testunit.pas"/>
<Caret Line="349" Column="59" TopLine="340"/>
</Position25>
<Position26>
<Filename Value="testunit.pas"/>
<Caret Line="346" Column="50" TopLine="334"/>
</Position26>
<Position27>
<Filename Value="testunit.pas"/>
<Caret Line="349" Column="53" TopLine="334"/>
</Position27>
<Position28>
<Filename Value="testunit.pas"/>
<Caret Line="352" Column="38" TopLine="340"/>
</Position28>
<Position29>
<Filename Value="framescript.pas"/>
<Caret Line="107" Column="24" TopLine="95"/>
</Position29>
<Position30>
</Position12>
<Position13>
<Filename Value="framescript.pas"/>
<Caret Line="108" Column="38" TopLine="91"/>
</Position13>
<Position14>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/other.inc"/>
<Caret Line="52" Column="15" TopLine="25"/>
</Position14>
<Position15>
<Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="243" Column="65" TopLine="134"/>
</Position15>
<Position16>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<Caret Line="47" Column="48" TopLine="27"/>
</Position16>
<Position17>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<Caret Line="58" Column="53" TopLine="27"/>
</Position17>
<Position18>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<Caret Line="62" Column="13" TopLine="27"/>
</Position18>
<Position19>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<Caret Line="45" Column="47" TopLine="27"/>
</Position19>
<Position20>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<Caret Line="80" Column="56" TopLine="63"/>
</Position20>
<Position21>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<Caret Line="94" Column="36" TopLine="63"/>
</Position21>
<Position22>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<Caret Line="99" Column="17" TopLine="63"/>
</Position22>
<Position23>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="24" Column="85" TopLine="1"/>
</Position23>
<Position24>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="43" Column="19" TopLine="24"/>
</Position24>
<Position25>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="55" Column="68" TopLine="24"/>
</Position25>
<Position26>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="56" Column="66" TopLine="24"/>
</Position26>
<Position27>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="57" Column="42" TopLine="24"/>
</Position27>
<Position28>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="58" Column="38" TopLine="24"/>
</Position28>
<Position29>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="82" Column="50" TopLine="48"/>
</Position29>
<Position30>
<Filename Value="../../Units/MMLAddon/colourpicker.pas"/>
<Caret Line="188" Column="50" TopLine="166"/>
</Position30>
</JumpHistory>
</ProjectOptions>

View File

@ -30,7 +30,7 @@ interface
uses
Classes, SysUtils, LCLIntf,LCLType,InterfaceBase,Forms,Controls,ExtCtrls,
Graphics,
Window,MufasaTypes, colourhistory
Window,MufasaTypes, colourhistory,bitmaps
{$IFNDEF PICKER_CLIENT}
{$IFDEF LINUX}
@ -105,6 +105,7 @@ var
OldWindow: HWND;
{$ENDIF}
{$ENDIF}
bmp: TMufasaBitmap;
begin
{ Disable both of the color pick buttons }
@ -183,7 +184,10 @@ begin
ImageMain.OnMouseMove:=@ImageMainMouseMove;
{ Copy the client to ImageMain }
ImageMain.Picture.Bitmap := Window.CopyClientToBitmap(0, 0, w - 1, h - 1);
bmp:=TMufasaBitmap.Create;
bmp.CopyClientToBitmap(Window, true, 0, 0, w-1, h-1);
ImageMain.Picture.Bitmap := bmp.ToTBitmap;
bmp.Free;
{ Set up handles and events }
ImageHandle:= ImageMain.Canvas.Handle;

View File

@ -79,6 +79,7 @@ type
procedure Posterize(TargetBitmap : TMufasaBitmap; Po : integer);overload;
procedure Posterize(Po : integer);overload;
function Copy: TMufasaBitmap;
function ToTBitmap: TBitmap;
function CreateTMask : TMask;
constructor Create;
destructor Destroy;override;
@ -385,6 +386,18 @@ begin
Move(self.FData[0], Result.FData[0],self.w * self.h * SizeOf(TRGB32));
end;
function TMufasaBitmap.ToTBitmap: TBitmap;
var
tr:TRawImage;
begin
Result := TBitmap.Create;
Result.SetSize(self.Width, self.Height);
ArrDataToRawImage(Self.Fdata, point(self.width,self.height), tr);
Result.LoadFromRawImage(tr, false);
end;
procedure TMufasaBitmap.FastSetPixel(x, y: integer; Color: TColor);
begin
ValidatePoint(x,y);

View File

@ -648,118 +648,6 @@ begin
else
result := GetUpTextAtEx(atX, atY, false);
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?');
t:=MakeTPAString('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[1]);
writeln(result);
end; }
{
function TMOCR.GetUpTextAt(atX, atY: integer): string;
var
bmp: TMufasaBitmap;
n: TNormArray;
p: prgb32;
w,h,ww,hh,len,i: integer;
begin
result := '';
TClient(Client).MWindow.GetDimensions(w, h);
ww := 450;
hh := 20;
if ww + atX > w then
ww := w - atX;
if hh + atY > h then
hh := h - atY;
{writeln('ww and hh: ' + inttostr(ww) + ', ' + inttostr(hh));}
bmp := TMufasaBitmap.Create;
bmp.SetSize(ww, hh);
bmp.CopyClientToBitmap(TClient(Client).MWindow, False, atX, atY, atX + ww - 1,
atY + hh - 1);
//bmp.SaveToFile('.' + DS + 'output.bmp');
bmp.Posterize(127);
//bmp.SaveToFile('.' + DS + 'posterize.bmp');
bmp.Contrast(127);
//bmp.SaveToFile('.' + DS + 'posterizecontrast.bmp');
{bmp.Brightness(-20);
bmp.SaveToFile('.' + DS + 'posterizecontrastbrightness.bmp'); }
{writeln('bmp.w / bmp.h: ' + inttostr(bmp.Width) + ', ' + inttostr(bmp.height));
writeln('wwhh: ' + inttostr(ww * hh));
writeln('widhei: ' + inttostr(bmp.width * bmp.height));}
bmp.SaveToFile('.' + DS + 'final.bmp');
p := bmp.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;
{ n := ExtractText(bmp.FData, bmp.Width, bmp.Height); }
{writeln('n: ' + inttostr(length(n))); }
Result := ocrDetect(n, bmp.Width, bmp.Height, OCRData[0]);
bmp.Free;
end;
}
end.

View File

@ -60,7 +60,6 @@ type
procedure FreeReturnData;
procedure GetDimensions(out W, H: Integer);
function GetDimensionBox(out Box : TBox) : boolean;
function CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap;
procedure ActivateClient;
{$IFDEF LINUX}
function SetTarget(XWindow: x.TWindow): integer; overload;
@ -433,89 +432,6 @@ begin
Self.FreezeState:=False;
end;
//Remove?
function TMWindow.CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap;
var
w,h: Integer;
ww, hh: Integer;
Raw: TRawImage;
Bmp: TBitmap;
y : integer;
TempData : PRGB32;
{$IFDEF LINUX}
Old_Handler: TXErrorHandler;
Img: PXImage;
{$ENDIF}
begin
Self.GetDimensions(w, h);
ww := xe-xs;
hh := ye-ys;
if(xs < 0) or (ys < 0) or (xe >= W) or (ye >= H) then
Raise Exception.CreateFMT('CopyClientToBitmap TMWindow: Faulty coordinates (%d,%d)(%d,%d); Width/Height is (%d,%d)',[xs,ys,xe,ye,w,h]);
if Self.Frozen then
begin;
TempData:= GetMem((ww + 1) * (hh + 1) * sizeof(TRGB32));
for y := ys to ye do
Move(Self.FrozenData[y*Self.FrozenSize.x],TempData[(y-ys) * (ww+1)],(ww+1) * SizeOf(TRGB32));
ArrDataToRawImage(TempData,Classes.Point(ww + 1,hh + 1),Raw);
Bmp := TBitmap.Create;
Bmp.LoadFromRawImage(Raw,true);
Result := bmp;
end else
case Self.TargetMode Of
w_Window:
begin
{$IFDEF MSWINDOWS}
Result := TBitmap.Create;
Result.SetSize(ww+1,hh+1);
BitBlt(result.canvas.handle,0,0,ww+1,hh+1,
self.TargetDC,xs,ys, SRCCOPY);
{$ENDIF}
end;
w_XWindow:
begin
{$IFDEF LINUX}
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
Img := XGetImage(Self.XDisplay, Self.curWindow, xs, ys, ww+1, hh+1, AllPlanes, ZPixmap);
XImageToRawImage(Img, Raw);
Bmp := TBitmap.Create;
Bmp.LoadFromRawImage(Raw, False);
Result := Bmp;
XDestroyImage(Img);
XSetErrorHandler(Old_Handler);
{$ELSE}
raise Exception.createFMT('CopyClientToBitmap: You cannot use ' +
'the XImage mode on Windows.', []);
{$ENDIF}
end;
w_ArrayPtr:
begin
TempData:= GetMem((ww + 1) * (hh + 1) * sizeof(trgb32));
for y := ys to ye do
Move(Self.ArrayPtr[y*Self.ArraySize.x],TempData[(y-ys) * (ww+1)],(ww+1) * SizeOf(TRGB32));
ArrDataToRawImage(TempData,Classes.Point(ww+1,hh+1),Raw);
Bmp := TBitmap.Create;
Bmp.LoadFromRawImage(Raw,true);
Result := bmp;
end;
w_BMP:
begin
TempData:= GetMem((ww + 1) * (hh + 1) * sizeof(trgb32));
for y := ys to ye do
Move(TargetBitmap.FData[y*w],TempData[(y-ys) * (ww+1)],(ww+1) * SizeOf(TRGB32));
ArrDataToRawImage(TempData,Classes.Point(ww+1,hh+1),Raw);
Bmp := TBitmap.Create;
Bmp.LoadFromRawImage(Raw,true);
Result := bmp;
end;
end;
end;
// Set's input focus on Linux, does not mean the window will look `active', but
// it surely is. Try typing something after ActivateClient.
procedure TMWindow.ActivateClient;