1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-24 18:22:25 -05:00
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@18 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2009-09-04 04:26:56 +00:00
parent a6a7f0b247
commit adc6d0b6f5
5 changed files with 703 additions and 682 deletions

View File

@ -187,7 +187,9 @@ begin
Writeln('ReturnData: XGetImage Error. Dumping data now:'); Writeln('ReturnData: XGetImage Error. Dumping data now:');
Writeln('xs, ys, width, height: ' + inttostr(xs) + ', ' + inttostr(ys) + Writeln('xs, ys, width, height: ' + inttostr(xs) + ', ' + inttostr(ys) +
', ' + inttostr(width) + ', ' + inttostr(height)); ', ' + inttostr(width) + ', ' + inttostr(height));
Result := nil; Result.Ptr := nil;
Result.IncPtrWith := 0;
XSetErrorHandler(Old_Handler); XSetErrorHandler(Old_Handler);
Exit; Exit;
end; end;
@ -226,6 +228,11 @@ begin
{$ENDIF} {$ENDIF}
end; end;
// Bugged. For params other than 0, 0, ClientWidth, ClientHeight
// if other type than w_XImage
// Also thread bugged
function TMWindow.CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap; function TMWindow.CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap;
var var
w,h : Integer; w,h : Integer;
@ -265,6 +272,7 @@ begin
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler); Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
Img := XGetImage(Self.XDisplay, Self.curWindow, xs, ys, ww, hh, AllPlanes, ZPixmap); Img := XGetImage(Self.XDisplay, Self.curWindow, xs, ys, ww, hh, AllPlanes, ZPixmap);
XImageToRawImage(Img, Raw);
Bmp := TBitmap.Create; Bmp := TBitmap.Create;
Bmp.LoadFromRawImage(Raw, False); Bmp.LoadFromRawImage(Raw, False);
@ -307,7 +315,6 @@ begin
{$ENDIF} {$ENDIF}
end; end;
{$IFDEF MSWINDOWS} //Probably need one for Linux as well {$IFDEF MSWINDOWS} //Probably need one for Linux as well
function TMWindow.UpdateDrawBitmap :boolean; function TMWindow.UpdateDrawBitmap :boolean;
var var

View File

@ -38,7 +38,7 @@
<CursorPos X="1" Y="19"/> <CursorPos X="1" Y="19"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<UsageCount Value="51"/> <UsageCount Value="53"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -49,7 +49,7 @@
<UnitName Value="TestUnit"/> <UnitName Value="TestUnit"/>
<CursorPos X="33" Y="57"/> <CursorPos X="33" Y="57"/>
<TopLine Value="32"/> <TopLine Value="32"/>
<UsageCount Value="51"/> <UsageCount Value="53"/>
</Unit1> </Unit1>
<Unit2> <Unit2>
<Filename Value="client.pas"/> <Filename Value="client.pas"/>
@ -57,7 +57,7 @@
<UnitName Value="Client"/> <UnitName Value="Client"/>
<CursorPos X="18" Y="34"/> <CursorPos X="18" Y="34"/>
<TopLine Value="10"/> <TopLine Value="10"/>
<UsageCount Value="51"/> <UsageCount Value="53"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="../cogat/Units/CogatUnits/comptypes.pas"/> <Filename Value="../cogat/Units/CogatUnits/comptypes.pas"/>
@ -72,7 +72,7 @@
<UnitName Value="MufasaTypes"/> <UnitName Value="MufasaTypes"/>
<CursorPos X="52" Y="20"/> <CursorPos X="52" Y="20"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="51"/> <UsageCount Value="53"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="window.pas"/> <Filename Value="window.pas"/>
@ -80,7 +80,7 @@
<UnitName Value="Window"/> <UnitName Value="Window"/>
<CursorPos X="4" Y="100"/> <CursorPos X="4" Y="100"/>
<TopLine Value="85"/> <TopLine Value="85"/>
<UsageCount Value="51"/> <UsageCount Value="53"/>
</Unit5> </Unit5>
<Unit6> <Unit6>
<Filename Value="../Documents/fpc/rtl/inc/systemh.inc"/> <Filename Value="../Documents/fpc/rtl/inc/systemh.inc"/>
@ -94,7 +94,7 @@
<UnitName Value="Input"/> <UnitName Value="Input"/>
<CursorPos X="5" Y="20"/> <CursorPos X="5" Y="20"/>
<TopLine Value="15"/> <TopLine Value="15"/>
<UsageCount Value="50"/> <UsageCount Value="52"/>
</Unit7> </Unit7>
<Unit8> <Unit8>
<Filename Value="../cogat/Units/CogatUnits/compinput.pas"/> <Filename Value="../cogat/Units/CogatUnits/compinput.pas"/>
@ -109,7 +109,7 @@
<CursorPos X="46" Y="8"/> <CursorPos X="46" Y="8"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="5"/> <EditorIndex Value="5"/>
<UsageCount Value="22"/> <UsageCount Value="23"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit9> </Unit9>
<Unit10> <Unit10>
@ -118,35 +118,35 @@
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="6"/> <EditorIndex Value="6"/>
<UsageCount Value="22"/> <UsageCount Value="23"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit10> </Unit10>
<Unit11> <Unit11>
<Filename Value="Units/MMLCore/mufasatypes.pas"/> <Filename Value="Units/MMLCore/mufasatypes.pas"/>
<UnitName Value="MufasaTypes"/> <UnitName Value="MufasaTypes"/>
<CursorPos X="1" Y="18"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<UsageCount Value="22"/> <UsageCount Value="23"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<UnitName Value="Window"/> <UnitName Value="Window"/>
<CursorPos X="52" Y="394"/> <CursorPos X="5" Y="316"/>
<TopLine Value="394"/> <TopLine Value="291"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<UsageCount Value="22"/> <UsageCount Value="23"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="Units/MMLCore/windowutil.pas"/> <Filename Value="Units/MMLCore/windowutil.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="windowutil"/> <UnitName Value="windowutil"/>
<CursorPos X="53" Y="122"/> <CursorPos X="54" Y="20"/>
<TopLine Value="98"/> <TopLine Value="80"/>
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<UsageCount Value="43"/> <UsageCount Value="45"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit13> </Unit13>
<Unit14> <Unit14>
@ -182,10 +182,10 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="TestUnit"/> <UnitName Value="TestUnit"/>
<CursorPos X="41" Y="71"/> <CursorPos X="37" Y="112"/>
<TopLine Value="54"/> <TopLine Value="103"/>
<EditorIndex Value="4"/> <EditorIndex Value="4"/>
<UsageCount Value="19"/> <UsageCount Value="20"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit18> </Unit18>
<Unit19> <Unit19>
@ -287,123 +287,123 @@
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="215" Column="10" TopLine="205"/> <Caret Line="10" Column="10" TopLine="1"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="225" Column="19" TopLine="215"/> <Caret Line="367" Column="46" TopLine="353"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="239" Column="19" TopLine="229"/> <Caret Line="115" Column="36" TopLine="106"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="261" Column="17" TopLine="251"/> <Caret Line="114" Column="24" TopLine="99"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="testunit.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="68" Column="20" TopLine="53"/> <Caret Line="94" Column="26" TopLine="79"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="329" Column="14" TopLine="298"/> <Caret Line="58" Column="78" TopLine="45"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="10" Column="10" TopLine="1"/> <Caret Line="63" Column="37" TopLine="48"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="367" Column="46" TopLine="353"/> <Caret Line="69" Column="41" TopLine="68"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="115" Column="36" TopLine="106"/> <Caret Line="73" Column="37" TopLine="64"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="114" Column="24" TopLine="99"/> <Caret Line="26" Column="40" TopLine="11"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="94" Column="26" TopLine="79"/> <Caret Line="276" Column="28" TopLine="250"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="testunit.pas"/> <Filename Value="Units/MMLCore/windowutil.pas"/>
<Caret Line="58" Column="78" TopLine="45"/> <Caret Line="22" Column="5" TopLine="12"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="testunit.pas"/> <Filename Value="Units/MMLCore/windowutil.pas"/>
<Caret Line="63" Column="37" TopLine="48"/> <Caret Line="48" Column="39" TopLine="32"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="testunit.pas"/> <Filename Value="Units/MMLCore/windowutil.pas"/>
<Caret Line="69" Column="41" TopLine="68"/> <Caret Line="52" Column="50" TopLine="39"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="testunit.pas"/> <Filename Value="Units/MMLCore/windowutil.pas"/>
<Caret Line="73" Column="37" TopLine="64"/> <Caret Line="9" Column="10" TopLine="1"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/windowutil.pas"/>
<Caret Line="26" Column="40" TopLine="11"/> <Caret Line="10" Column="17" TopLine="1"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/windowutil.pas"/>
<Caret Line="276" Column="28" TopLine="250"/> <Caret Line="11" Column="3" TopLine="1"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="Units/MMLCore/windowutil.pas"/> <Filename Value="Units/MMLCore/windowutil.pas"/>
<Caret Line="22" Column="5" TopLine="12"/> <Caret Line="12" Column="13" TopLine="1"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="Units/MMLCore/windowutil.pas"/> <Filename Value="Units/MMLCore/windowutil.pas"/>
<Caret Line="48" Column="39" TopLine="32"/> <Caret Line="88" Column="1" TopLine="1"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="Units/MMLCore/windowutil.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="52" Column="50" TopLine="39"/> <Caret Line="275" Column="60" TopLine="251"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="Units/MMLCore/windowutil.pas"/> <Filename Value="Units/MMLCore/client.pas"/>
<Caret Line="9" Column="10" TopLine="1"/> <Caret Line="8" Column="46" TopLine="1"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="Units/MMLCore/windowutil.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="10" Column="17" TopLine="1"/> <Caret Line="419" Column="3" TopLine="390"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="Units/MMLCore/windowutil.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="11" Column="3" TopLine="1"/> <Caret Line="382" Column="66" TopLine="369"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="Units/MMLCore/windowutil.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="12" Column="13" TopLine="1"/> <Caret Line="202" Column="11" TopLine="187"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="Units/MMLCore/windowutil.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="88" Column="1" TopLine="1"/> <Caret Line="1" Column="1" TopLine="171"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="275" Column="60" TopLine="251"/> <Caret Line="180" Column="31" TopLine="175"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="Units/MMLCore/client.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="8" Column="46" TopLine="1"/> <Caret Line="190" Column="23" TopLine="175"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="419" Column="3" TopLine="390"/> <Caret Line="198" Column="65" TopLine="176"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="382" Column="66" TopLine="369"/> <Caret Line="26" Column="40" TopLine="6"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="Units/MMLCore/window.pas"/> <Filename Value="Units/MMLCore/window.pas"/>
<Caret Line="202" Column="11" TopLine="187"/> <Caret Line="27" Column="37" TopLine="1"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>

View File

@ -1,7 +1,7 @@
object Form1: TForm1 object Form1: TForm1
Left = 462 Left = 320
Height = 527 Height = 527
Top = 227 Top = 238
Width = 779 Width = 779
ActiveControl = Button1 ActiveControl = Button1
Caption = 'Form1' Caption = 'Form1'

View File

@ -1,10 +1,10 @@
{ This is an automatically generated lazarus resource file } { This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[ LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#206#1#6'Height'#3#15#2#3'Top'#3#227#0#5'W' 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'@'#1#6'Height'#3#15#2#3'Top'#3#238#0#5'Wi'
+'idth'#3#11#3#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1'#12'Client' +'dth'#3#11#3#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1'#12'ClientH'
+'Height'#3#15#2#11'ClientWidth'#3#11#3#8'Position'#7#14'poScreenCenter'#10'L' +'eight'#3#15#2#11'ClientWidth'#3#11#3#8'Position'#7#14'poScreenCenter'#10'LC'
+'CLVersion'#6#6'0.9.29'#0#7'TButton'#7'Button1'#4'Left'#2'E'#6'Height'#2#25#3 +'LVersion'#6#6'0.9.29'#0#7'TButton'#7'Button1'#4'Left'#2'E'#6'Height'#2#25#3
+'Top'#2' '#5'Width'#2'K'#7'Caption'#6#7'Button1'#7'OnClick'#7#12'Button1Clic' +'Top'#2' '#5'Width'#2'K'#7'Caption'#6#7'Button1'#7'OnClick'#7#12'Button1Clic'
+'k'#8'TabOrder'#2#0#0#0#0 +'k'#8'TabOrder'#2#0#0#0#0
]); ]);

View File

@ -69,9 +69,11 @@ begin
Client.MWIndow.SetTarget(PRGB32(@Arr[0]), Point(3, 3)); } Client.MWIndow.SetTarget(PRGB32(@Arr[0]), Point(3, 3)); }
// Client.MWindow.ActivateClient; // Client.MWindow.ActivateClient;
Client.MWindow.GetDimensions(w, h); Client.MWindow.GetDimensions(w, h);
Writeln('Copying BMP'); Writeln('Copying BMP');
bmp := Client.MWindow.CopyClientToBitmap(0, 0, w, h); bmp := Client.MWindow.CopyClientToBitmap(0, 0, w, h);
Writeln('Saving BMP');
{$IFDEF WINDOWS} {$IFDEF WINDOWS}
bmp.SaveToFile('c:\test1.bmp'); bmp.SaveToFile('c:\test1.bmp');
@ -79,6 +81,8 @@ begin
{$IFDEF LINUX} {$IFDEF LINUX}
bmp.SaveToFile('/tmp/test1.bmp'); bmp.SaveToFile('/tmp/test1.bmp');
{$ENDIF} {$ENDIF}
writeln('Copied Bitmap');
// bmp.Free; // bmp.Free;
//Sleep(1000); //Sleep(1000);
@ -90,22 +94,31 @@ begin
writeln(inttostr(x) + ' , ' + inttostr(y)); writeln(inttostr(x) + ' , ' + inttostr(y));
Client.MInput.ClickMouse(60, 60, mouse_Right); Client.MInput.ClickMouse(60, 60, mouse_Right);
LoopX:= w div 2; LoopX:= w div 2;
LoopY:= h div 2; LoopY:= h div 2;
bmp.SetSize(Loopx + 1, Loopy + 1); bmp.SetSize(Loopx + 1, Loopy + 1);
ReturnData := Client.MWindow.ReturnData(0, 0, Loopx + 1, Loopy + 1); ReturnData := Client.MWindow.ReturnData(0, 0, Loopx + 1, Loopy + 1);
SetLength(Arr,(Loopy + 1) * (Loopx + 1)); SetLength(Arr,(Loopy + 1) * (Loopx + 1));
for yy := 0 to Loopy do for yy := 0 to Loopy do
begin; begin;
for xx := 0 to Loopx do for xx := 0 to Loopx do
begin begin
{ Do comparison here } { Do comparison here }
Arr[yy * (loopx + 1) + xx] :=RGBToColor(ReturnData.Ptr^.B,ReturnData.Ptr^.G,ReturnData.Ptr^.R); Arr[yy * (loopx + 1) + xx] :=RGBToColor(ReturnData.Ptr^.B,ReturnData.Ptr^.G,ReturnData.Ptr^.R);
Bmp.Canvas.Pixels[xx,yy] := clwhite xor RGBToColor(ReturnData.Ptr^.R,ReturnData.Ptr^.G,ReturnData.Ptr^.B);
// not thread stable on linux.
//Bmp.Canvas.Pixels[xx,yy] := RGBToColor(ReturnData.Ptr^.R,ReturnData.Ptr^.G,ReturnData.Ptr^.B);
inc(ReturnData.Ptr); inc(ReturnData.Ptr);
end; end;
Inc(ReturnData.Ptr,ReturnData.IncPtrWith); Inc(ReturnData.Ptr,ReturnData.IncPtrWith);
end; end;
{$IFDEF WINDOWS} {$IFDEF WINDOWS}
bmp.SaveToFile('c:\test2.bmp'); bmp.SaveToFile('c:\test2.bmp');
{$ENDIF} {$ENDIF}
@ -113,6 +126,7 @@ begin
bmp.SaveToFile('/tmp/test2.bmp'); bmp.SaveToFile('/tmp/test2.bmp');
{$ENDIF} {$ENDIF}
Bmp.free; Bmp.free;
// Client.MWIndow.SetTarget(PRGB32(@Arr[0]), Point(Loopx + 1, Loopy + 1)); // Client.MWIndow.SetTarget(PRGB32(@Arr[0]), Point(Loopx + 1, Loopy + 1));
Client.MWindow.FreeReturnData; Client.MWindow.FreeReturnData;