mirror of
https://github.com/moparisthebest/Simba
synced 2024-12-01 05:12:16 -05:00
Fixed EPIC stuff.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@16 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
793e168a20
commit
babee3c3d2
@ -13,6 +13,10 @@ type
|
|||||||
B, G, R, A: Byte;
|
B, G, R, A: Byte;
|
||||||
end;
|
end;
|
||||||
PRGB32 = ^TRGB32;
|
PRGB32 = ^TRGB32;
|
||||||
|
TRetData = record
|
||||||
|
Ptr : PRGB32;
|
||||||
|
IncPtrWith : integer;
|
||||||
|
end;
|
||||||
|
|
||||||
TTargetWindowMode = (w_BMP, w_Window, w_HDC, w_ArrayPtr, w_XWindow);
|
TTargetWindowMode = (w_BMP, w_Window, w_HDC, w_ArrayPtr, w_XWindow);
|
||||||
TClickType = (mouse_Left, mouse_Right, mouse_Middle);
|
TClickType = (mouse_Left, mouse_Right, mouse_Middle);
|
||||||
|
@ -7,7 +7,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, mufasatypes,
|
Classes, SysUtils, mufasatypes,
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
,windows // For windows API
|
windows, // For windows API
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
graphics,
|
graphics,
|
||||||
LCLType,
|
LCLType,
|
||||||
@ -20,7 +20,7 @@ type
|
|||||||
{ TMWindow }
|
{ TMWindow }
|
||||||
|
|
||||||
TMWindow = class(TObject)
|
TMWindow = class(TObject)
|
||||||
function ReturnData(xs, ys, width, height: Integer): PRGB32;
|
function ReturnData(xs, ys, width, height: Integer): TRetData;
|
||||||
procedure FreeReturnData;
|
procedure FreeReturnData;
|
||||||
procedure GetDimensions(var W, H: Integer);
|
procedure GetDimensions(var W, H: Integer);
|
||||||
function CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap;
|
function CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap;
|
||||||
@ -53,6 +53,7 @@ type
|
|||||||
//Works on linux as well, test it out
|
//Works on linux as well, test it out
|
||||||
TargetDC : HDC;
|
TargetDC : HDC;
|
||||||
DrawBitmap : TBitmap;
|
DrawBitmap : TBitmap;
|
||||||
|
DrawBmpW,DrawBmpH : integer;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
@ -112,10 +113,11 @@ begin
|
|||||||
Self.Client := Client;
|
Self.Client := Client;
|
||||||
|
|
||||||
Self.ArrayPtr := nil;
|
Self.ArrayPtr := nil;
|
||||||
Self.ArraySize := Point(-1, -1);
|
Self.ArraySize := Classes.Point(-1, -1);
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
Self.DrawBitmap := TBitmap.Create;
|
Self.DrawBitmap := TBitmap.Create;
|
||||||
|
Self.DrawBitmap.PixelFormat:= pf32bit;
|
||||||
Self.TargetMode:= w_Window;
|
Self.TargetMode:= w_Window;
|
||||||
Self.TargetHandle:= windows.GetDesktopWindow;
|
Self.TargetHandle:= windows.GetDesktopWindow;
|
||||||
Self.TargetDC:= GetWindowDC(Self.TargetHandle);
|
Self.TargetDC:= GetWindowDC(Self.TargetHandle);
|
||||||
@ -156,9 +158,9 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMWindow.ReturnData(xs, ys, width, height: Integer): PRGB32;
|
function TMWindow.ReturnData(xs, ys, width, height: Integer): TRetData;
|
||||||
{$IFDEF LINUX}
|
|
||||||
var
|
var
|
||||||
|
{$IFDEF LINUX}
|
||||||
Old_Handler: TXErrorHandler;
|
Old_Handler: TXErrorHandler;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
TmpData: PRGB32;
|
TmpData: PRGB32;
|
||||||
@ -169,7 +171,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
BitBlt(Self.DrawBitmap.Canvas.Handle,0,0, width, height, Self.TargetDC, xs,ys, SRCCOPY);
|
BitBlt(Self.DrawBitmap.Canvas.Handle,0,0, width, height, Self.TargetDC, xs,ys, SRCCOPY);
|
||||||
Result := Self.DrawBmpDataPtr;
|
Result.Ptr:= Self.DrawBmpDataPtr;
|
||||||
|
Result.IncPtrWith:= DrawBmpW - Width;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
w_XWindow:
|
w_XWindow:
|
||||||
@ -189,7 +192,8 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
WriteLn(IntToStr(Self.XWindowImage^.width) + ', ' + IntToStr(Self.XWindowImage^.height));
|
WriteLn(IntToStr(Self.XWindowImage^.width) + ', ' + IntToStr(Self.XWindowImage^.height));
|
||||||
Result := PRGB32(Self.XWindowImage^.data);
|
Result.Ptr := PRGB32(Self.XWindowImage^.data);
|
||||||
|
Result.IncPtrWith := 0;
|
||||||
|
|
||||||
XSetErrorHandler(Old_Handler);
|
XSetErrorHandler(Old_Handler);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
@ -200,7 +204,9 @@ begin
|
|||||||
begin
|
begin
|
||||||
TmpData := Self.ArrayPtr;
|
TmpData := Self.ArrayPtr;
|
||||||
Inc(TmpData, ys * Height + xs);
|
Inc(TmpData, ys * Height + xs);
|
||||||
Result := TmpData;
|
Result.Ptr := TmpData;
|
||||||
|
Result.IncPtrWith:= Self.ArraySize.x - width;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -224,11 +230,11 @@ function TMWindow.CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap;
|
|||||||
var
|
var
|
||||||
w,h : Integer;
|
w,h : Integer;
|
||||||
ww, hh: Integer;
|
ww, hh: Integer;
|
||||||
|
Raw: TRawImage;
|
||||||
|
Bmp: TBitmap;
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
Old_Handler: TXErrorHandler;
|
Old_Handler: TXErrorHandler;
|
||||||
Img: PXImage;
|
Img: PXImage;
|
||||||
Raw: TRawImage;
|
|
||||||
Bmp: TBitmap;
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -308,6 +314,9 @@ var
|
|||||||
begin
|
begin
|
||||||
GetDimensions(w,h);
|
GetDimensions(w,h);
|
||||||
DrawBitmap.SetSize(w,h);
|
DrawBitmap.SetSize(w,h);
|
||||||
|
// DrawBitmap.PixelFormat:=
|
||||||
|
DrawBmpW := w;
|
||||||
|
DrawBmpH := h;
|
||||||
GetObject(DrawBitmap.Handle, SizeOf(BmpInfo), @BmpInfo);
|
GetObject(DrawBitmap.Handle, SizeOf(BmpInfo), @BmpInfo);
|
||||||
DrawBmpDataPtr := BmpInfo.bmBits;
|
DrawBmpDataPtr := BmpInfo.bmBits;
|
||||||
end;
|
end;
|
||||||
|
@ -7,18 +7,18 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
ctypes, // for cint, etc
|
ctypes, // for cint, etc
|
||||||
|
GraphType, // For TRawImage
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
x, xlib, // For X* stuff.
|
x, xlib, // For X* stuff.
|
||||||
GraphType, // For TRawImage
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
mufasatypes;
|
mufasatypes;
|
||||||
|
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
Procedure XImageToRawImage(XImg: PXImage; Var RawImage: TRawImage);
|
Procedure XImageToRawImage(XImg: PXImage; Var RawImage: TRawImage);
|
||||||
Procedure ArrDataToRawImage(Ptr: PRGB32; Size: TPoint; Var RawImage: TRawImage);
|
|
||||||
function MufasaXErrorHandler(para1:PDisplay; para2:PXErrorEvent):cint;cdecl;
|
function MufasaXErrorHandler(para1:PDisplay; para2:PXErrorEvent):cint;cdecl;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
Procedure ArrDataToRawImage(Ptr: PRGB32; Size: TPoint; Var RawImage: TRawImage);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 339
|
Left = 462
|
||||||
Height = 527
|
Height = 527
|
||||||
Top = 262
|
Top = 227
|
||||||
Width = 779
|
Width = 779
|
||||||
ActiveControl = Button1
|
ActiveControl = Button1
|
||||||
Caption = 'Form1'
|
Caption = 'Form1'
|
||||||
ClientHeight = 527
|
ClientHeight = 527
|
||||||
ClientWidth = 779
|
ClientWidth = 779
|
||||||
|
Position = poScreenCenter
|
||||||
LCLVersion = '0.9.29'
|
LCLVersion = '0.9.29'
|
||||||
object Button1: TButton
|
object Button1: TButton
|
||||||
Left = 69
|
Left = 69
|
||||||
|
11
testunit.lrs
11
testunit.lrs
@ -1,9 +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'S'#1#6'Height'#3#15#2#3'Top'#3#6#1#5'Widt'
|
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#206#1#6'Height'#3#15#2#3'Top'#3#227#0#5'W'
|
||||||
+'h'#3#11#3#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1'#12'ClientHei'
|
+'idth'#3#11#3#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1'#12'Client'
|
||||||
+'ght'#3#15#2#11'ClientWidth'#3#11#3#10'LCLVersion'#6#6'0.9.29'#0#7'TButton'#7
|
+'Height'#3#15#2#11'ClientWidth'#3#11#3#8'Position'#7#14'poScreenCenter'#10'L'
|
||||||
+'Button1'#4'Left'#2'E'#6'Height'#2#25#3'Top'#2' '#5'Width'#2'K'#7'Caption'#6
|
+'CLVersion'#6#6'0.9.29'#0#7'TButton'#7'Button1'#4'Left'#2'E'#6'Height'#2#25#3
|
||||||
+#7'Button1'#7'OnClick'#7#12'Button1Click'#8'TabOrder'#2#0#0#0#0
|
+'Top'#2' '#5'Width'#2'K'#7'Caption'#6#7'Button1'#7'OnClick'#7#12'Button1Clic'
|
||||||
|
+'k'#8'TabOrder'#2#0#0#0#0
|
||||||
]);
|
]);
|
||||||
|
44
testunit.pas
44
testunit.pas
@ -46,8 +46,9 @@ Var
|
|||||||
Client: TClient;
|
Client: TClient;
|
||||||
w,h, x, y, xx, yy, i:integer;
|
w,h, x, y, xx, yy, i:integer;
|
||||||
bmp: TBitmap;
|
bmp: TBitmap;
|
||||||
ptr: PRGB32;
|
ReturnData : TRetData;
|
||||||
arr: Array Of Integer;
|
arr: Array Of Integer;
|
||||||
|
LoopY,LoopX : integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
while (not Terminated) do
|
while (not Terminated) do
|
||||||
@ -59,26 +60,26 @@ begin
|
|||||||
Client.MWindow.GetDimensions(w, h);
|
Client.MWindow.GetDimensions(w, h);
|
||||||
writeln(inttostr(w) + ' , ' + inttostr(h));
|
writeln(inttostr(w) + ' , ' + inttostr(h));
|
||||||
Writeln('Setting target');
|
Writeln('Setting target');
|
||||||
//Client.MWindow.SetTarget(132840,w_window);
|
// Client.MWindow.SetTarget(67232,w_window);
|
||||||
|
|
||||||
SetLength(Arr, 9);
|
{ SetLength(Arr, 9);
|
||||||
for i := 0 to high(arr) do
|
for i := 0 to high(arr) do
|
||||||
arr[i] := $FFFFFF;
|
arr[i] := $FFFFFF;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
bmp.SaveToFile('c:\test.bmp');
|
bmp.SaveToFile('c:\test1.bmp');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
bmp.SaveToFile('/tmp/test.bmp');
|
bmp.SaveToFile('/tmp/test1.bmp');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
bmp.Free;
|
// bmp.Free;
|
||||||
|
|
||||||
//Sleep(1000);
|
//Sleep(1000);
|
||||||
Client.MInput.GetMousePos(x, y);
|
Client.MInput.GetMousePos(x, y);
|
||||||
@ -89,15 +90,30 @@ 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;
|
||||||
ptr := Client.MWindow.ReturnData(0, 0, w, h);
|
LoopY:= h div 2;
|
||||||
for yy := 0 to h - 1 do
|
bmp.SetSize(Loopx + 1, Loopy + 1);
|
||||||
for xx := 0 to w - 1 do
|
ReturnData := Client.MWindow.ReturnData(0, 0, Loopx + 1, Loopy + 1);
|
||||||
|
SetLength(Arr,(Loopy + 1) * (Loopx + 1));
|
||||||
|
for yy := 0 to Loopy do
|
||||||
|
begin;
|
||||||
|
for xx := 0 to Loopx do
|
||||||
begin
|
begin
|
||||||
{ Do comparison here }
|
{ Do comparison here }
|
||||||
inc(ptr);
|
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);
|
||||||
|
inc(ReturnData.Ptr);
|
||||||
end;
|
end;
|
||||||
|
Inc(ReturnData.Ptr,ReturnData.IncPtrWith);
|
||||||
|
end;
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
bmp.SaveToFile('c:\test2.bmp');
|
||||||
|
{$ENDIF}
|
||||||
|
{$IFDEF LINUX}
|
||||||
|
bmp.SaveToFile('/tmp/test2.bmp');
|
||||||
|
{$ENDIF}
|
||||||
|
Bmp.free;
|
||||||
|
// Client.MWIndow.SetTarget(PRGB32(@Arr[0]), Point(Loopx + 1, Loopy + 1));
|
||||||
Client.MWindow.FreeReturnData;
|
Client.MWindow.FreeReturnData;
|
||||||
|
|
||||||
Client.MInput.IsMouseButtonDown(mouse_Left);
|
Client.MInput.IsMouseButtonDown(mouse_Left);
|
||||||
|
Loading…
Reference in New Issue
Block a user