1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-28 12:02:15 -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:
Raymond 2009-09-04 03:43:50 +00:00
parent 793e168a20
commit babee3c3d2
6 changed files with 772 additions and 741 deletions

View File

@ -13,6 +13,10 @@ type
B, G, R, A: Byte;
end;
PRGB32 = ^TRGB32;
TRetData = record
Ptr : PRGB32;
IncPtrWith : integer;
end;
TTargetWindowMode = (w_BMP, w_Window, w_HDC, w_ArrayPtr, w_XWindow);
TClickType = (mouse_Left, mouse_Right, mouse_Middle);

View File

@ -7,7 +7,7 @@ interface
uses
Classes, SysUtils, mufasatypes,
{$IFDEF MSWINDOWS}
,windows // For windows API
windows, // For windows API
{$ENDIF}
graphics,
LCLType,
@ -20,7 +20,7 @@ type
{ TMWindow }
TMWindow = class(TObject)
function ReturnData(xs, ys, width, height: Integer): PRGB32;
function ReturnData(xs, ys, width, height: Integer): TRetData;
procedure FreeReturnData;
procedure GetDimensions(var W, H: Integer);
function CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap;
@ -53,6 +53,7 @@ type
//Works on linux as well, test it out
TargetDC : HDC;
DrawBitmap : TBitmap;
DrawBmpW,DrawBmpH : integer;
{$ENDIF}
{$IFDEF LINUX}
@ -112,10 +113,11 @@ begin
Self.Client := Client;
Self.ArrayPtr := nil;
Self.ArraySize := Point(-1, -1);
Self.ArraySize := Classes.Point(-1, -1);
{$IFDEF MSWINDOWS}
Self.DrawBitmap := TBitmap.Create;
Self.DrawBitmap.PixelFormat:= pf32bit;
Self.TargetMode:= w_Window;
Self.TargetHandle:= windows.GetDesktopWindow;
Self.TargetDC:= GetWindowDC(Self.TargetHandle);
@ -156,9 +158,9 @@ begin
inherited;
end;
function TMWindow.ReturnData(xs, ys, width, height: Integer): PRGB32;
{$IFDEF LINUX}
function TMWindow.ReturnData(xs, ys, width, height: Integer): TRetData;
var
{$IFDEF LINUX}
Old_Handler: TXErrorHandler;
{$ENDIF}
TmpData: PRGB32;
@ -169,7 +171,8 @@ begin
begin
{$IFDEF MSWINDOWS}
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}
end;
w_XWindow:
@ -189,7 +192,8 @@ begin
Exit;
end;
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);
{$ELSE}
@ -200,7 +204,9 @@ begin
begin
TmpData := Self.ArrayPtr;
Inc(TmpData, ys * Height + xs);
Result := TmpData;
Result.Ptr := TmpData;
Result.IncPtrWith:= Self.ArraySize.x - width;
end;
end;
end;
@ -224,11 +230,11 @@ function TMWindow.CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap;
var
w,h : Integer;
ww, hh: Integer;
Raw: TRawImage;
Bmp: TBitmap;
{$IFDEF LINUX}
Old_Handler: TXErrorHandler;
Img: PXImage;
Raw: TRawImage;
Bmp: TBitmap;
{$ENDIF}
begin
@ -308,6 +314,9 @@ var
begin
GetDimensions(w,h);
DrawBitmap.SetSize(w,h);
// DrawBitmap.PixelFormat:=
DrawBmpW := w;
DrawBmpH := h;
GetObject(DrawBitmap.Handle, SizeOf(BmpInfo), @BmpInfo);
DrawBmpDataPtr := BmpInfo.bmBits;
end;

View File

@ -7,18 +7,18 @@ interface
uses
Classes, SysUtils,
ctypes, // for cint, etc
GraphType, // For TRawImage
{$IFDEF LINUX}
x, xlib, // For X* stuff.
GraphType, // For TRawImage
{$ENDIF}
mufasatypes;
{$IFDEF LINUX}
Procedure XImageToRawImage(XImg: PXImage; Var RawImage: TRawImage);
Procedure ArrDataToRawImage(Ptr: PRGB32; Size: TPoint; Var RawImage: TRawImage);
function MufasaXErrorHandler(para1:PDisplay; para2:PXErrorEvent):cint;cdecl;
{$ENDIF}
Procedure ArrDataToRawImage(Ptr: PRGB32; Size: TPoint; Var RawImage: TRawImage);
implementation

View File

@ -1,12 +1,13 @@
object Form1: TForm1
Left = 339
Left = 462
Height = 527
Top = 262
Top = 227
Width = 779
ActiveControl = Button1
Caption = 'Form1'
ClientHeight = 527
ClientWidth = 779
Position = poScreenCenter
LCLVersion = '0.9.29'
object Button1: TButton
Left = 69

View File

@ -1,9 +1,10 @@
{ This is an automatically generated lazarus resource file }
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'
+'h'#3#11#3#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1'#12'ClientHei'
+'ght'#3#15#2#11'ClientWidth'#3#11#3#10'LCLVersion'#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'Button1Click'#8'TabOrder'#2#0#0#0#0
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#206#1#6'Height'#3#15#2#3'Top'#3#227#0#5'W'
+'idth'#3#11#3#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1'#12'Client'
+'Height'#3#15#2#11'ClientWidth'#3#11#3#8'Position'#7#14'poScreenCenter'#10'L'
+'CLVersion'#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'
+'k'#8'TabOrder'#2#0#0#0#0
]);

View File

@ -46,8 +46,9 @@ Var
Client: TClient;
w,h, x, y, xx, yy, i:integer;
bmp: TBitmap;
ptr: PRGB32;
ReturnData : TRetData;
arr: Array Of Integer;
LoopY,LoopX : integer;
begin
while (not Terminated) do
@ -59,26 +60,26 @@ begin
Client.MWindow.GetDimensions(w, h);
writeln(inttostr(w) + ' , ' + inttostr(h));
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
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);
Writeln('Copying BMP');
bmp := Client.MWindow.CopyClientToBitmap(0, 0, w, h);
{$IFDEF WINDOWS}
bmp.SaveToFile('c:\test.bmp');
bmp.SaveToFile('c:\test1.bmp');
{$ENDIF}
{$IFDEF LINUX}
bmp.SaveToFile('/tmp/test.bmp');
bmp.SaveToFile('/tmp/test1.bmp');
{$ENDIF}
bmp.Free;
// bmp.Free;
//Sleep(1000);
Client.MInput.GetMousePos(x, y);
@ -89,15 +90,30 @@ begin
writeln(inttostr(x) + ' , ' + inttostr(y));
Client.MInput.ClickMouse(60, 60, mouse_Right);
ptr := Client.MWindow.ReturnData(0, 0, w, h);
for yy := 0 to h - 1 do
for xx := 0 to w - 1 do
LoopX:= w div 2;
LoopY:= h div 2;
bmp.SetSize(Loopx + 1, Loopy + 1);
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
{ 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;
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.MInput.IsMouseButtonDown(mouse_Left);