 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25871 Location: The netherlands
|
Posted: Tue Mar 05, 2013 10:41 am Post subject: |
|
|
Yes. I recommend setting the doublebuffered property to true on the wincontrol as well. (new update)
Basically place a paintbox (or anything with an OnPaint event and a Canvas)
Create a bitmap object (preferably same size or bigger)
And in the OnPaint event call getClipRect() to get a rectangle of the piece that needs to be updated (e.g when a window just drags over it only partial updates)
and then call copyRect to draw the bitmap to the canvas
Then each time you have updated the bitmap and want it instantly shown call paintwindow.repaint() (control_repaint is not in as it's not required to be backwards compatible)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Tue Mar 05, 2013 4:15 pm Post subject: |
|
|
Nice. Any "onPaint" example ?
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25871 Location: The netherlands
|
Posted: Tue Mar 05, 2013 6:40 pm Post subject: |
|
|
get the latest svn as there was a problem with getting the Canvas from a Graphics object
anyhow, this code will show a window with random lines all over the place:
| Code: |
f=createForm(nil)
p=createPaintBox(f)
p.align="alClient" --or p.Align=alClient
f.show()
b=createBitmap(p.Width, p.Height)
b.Canvas.Brush.color=0x0000FF --red
b.Canvas.fillRect(0,0,b.Width, b.Height)
function paintstate(sender)
--if you're lazy, just do sender.Canvas.draw(0,0,b)
local r=sender.Canvas.getClipRect()
sender.Canvas.copyRect(r.Left, r.Top, r.Right, r.Bottom, b.Canvas, r.Left, r.Top, r.Right, r.Bottom) --only copy the region that needs to be refreshed
end
p.OnPaint=paintstate
function GraphicUpdateTimer(t)
--this timer function will render to the offscreen bitmap and call repaint each time
--clear the whole bitmap (you could also just clear specific parts, but it's easier)
b.Canvas.Brush.color=0x0000FF --red
b.Canvas.fillRect(0,0,b.Width, b.Height) --comment out for different effect
b.Canvas.Pen.color=math.random(2^24)
b.Canvas.line(math.random(b.Width), math.random(b.Height),math.random(b.Width), math.random(b.Height))
b.Canvas.Pen.color=math.random(2^24)
b.Canvas.line(math.random(b.Width), math.random(b.Height),math.random(b.Width), math.random(b.Height))
b.Canvas.Pen.color=math.random(2^24)
b.Canvas.line(math.random(b.Width), math.random(b.Height),math.random(b.Width), math.random(b.Height))
p.repaint()
end
t=createTimer(nil)
t.Interval=16 --60 fps...
t.OnTimer=GraphicUpdateTimer
|
Note that the only task of the onpaint function is to render the bitmap to the displayed canvas and not more. All rendering and other stuff is done in the other function
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Tue Mar 05, 2013 7:25 pm Post subject: |
|
|
Nice. I will try this tomorrow. It is similar to C# code now (get canvas and do DrawImageUnscaled).
Unfortunately I didn't find anything similar to "set AllPaintingInWmPaint and UserPaint style". Probably this is only for C# and VB. (http://www.google.pl/search?q=UserPaint+lazarus)
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25871 Location: The netherlands
|
Posted: Tue Mar 05, 2013 7:35 pm Post subject: |
|
|
No idea what that would even do.
OnPaint is directly called when receiving a WM_PAINT message, so you could say that with this code "AllPaintingInWmPaint" is true. (all painting is done when wmpaint is called and before it returns)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Tue Mar 05, 2013 7:41 pm Post subject: |
|
|
From MVS2010
AllPaintingInWmPaint Summary:
If true, the control ignores the window message WM_ERASEBKGND to reduce flicker.
This style should only be applied if the System.Windows.Forms.ControlStyles.UserPaint bit is set to true.
UserPaint Summary:
If true, the control paints itself rather than the operating system doing so.
If false, the System.Windows.Forms.Control.Paint event is not raised. This style only applies to classes derived from System.Windows.Forms.Control.
Or maybe we don't need this. As I said, I will check current SVN version tomorrow.
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25871 Location: The netherlands
|
Posted: Tue Mar 05, 2013 7:48 pm Post subject: |
|
|
Ok, if you still get flickering tomorrow when styles are off (didn't test that) then add this line after form creation:
| Code: |
f.DoubleBuffered=true
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Tue Mar 05, 2013 7:50 pm Post subject: |
|
|
OK, thanks. I'm off.
_________________
|
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Thu Mar 07, 2013 2:21 pm Post subject: |
|
|
OK, works great (DoubleBuffered stuff).
This inside onpaint
| Code: | | sender.Canvas.draw(0,0,b) |
works as should, it uses TransparentColor and Transparent property from bitmap.
So, my question is:
how to set "TransparentColor" and "Transparent" inside PaintBox onpaint event after "sender.Canvas.copyRect()"
Currently I'm using this:
| Code: | function paintstate(sender)
sender.Canvas.draw(0, currentY, Bitmap)
end |
This should be better, but there's transparent missing.
| Code: | function paintstate(sender)
local r=sender.Canvas.getClipRect()
sender.Canvas.copyRect(r.Left, r.Top, -- dest
r.Right, r.Bottom, -- dest
Bitmap.Canvas, -- source
r.Left, r.Top - currentY, -- source
r.Right, r.Bottom - currentY) -- source
end |
(function is in line 207, inside NFOWindow.lua)
| Description: |
| for CE6.2+ it requires "NFOWindow.lua" file |
|
 Download |
| Filename: |
nfoWindow Demo.ct |
| Filesize: |
7.81 KB |
| Downloaded: |
1002 Time(s) |
| Description: |
|
 Download |
| Filename: |
NFOWindow.lua |
| Filesize: |
13.76 KB |
| Downloaded: |
925 Time(s) |
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25871 Location: The netherlands
|
Posted: Thu Mar 07, 2013 6:16 pm Post subject: |
|
|
If draw isn't too slow you can use that.
Perhaps in LCL 1.2 it may be fixed: http://bugs.freepascal.org/view.php?id=20234
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Tue Mar 12, 2013 10:21 am Post subject: |
|
|
@DB, so "Canvas.draw" good, "Canvas.copyRect" not good
Just checked this under LCL.
1) canvas.Draw()
2) find declaration
3) find->procedure jump
4) And there is something like this:
canvas.inc
| Code: | {-----------------------------------------------}
{-- TCanvas.Draw --}
{-----------------------------------------------}
procedure TCanvas.Draw(X, Y: Integer; SrcGraphic: TGraphic);
var
ARect: TRect;
begin
if not Assigned(SrcGraphic) then exit;
ARect:=Bounds(X,Y,SrcGraphic.Width,SrcGraphic.Height);
StretchDraw(ARect,SrcGraphic);
end; |
and below
| Code: | {-----------------------------------------------}
{-- TCanvas.StretchDraw --}
{-----------------------------------------------}
procedure TCanvas.StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic);
begin
if not Assigned(SrcGraphic) then exit;
Changing;
RequiredState([csHandleValid]);
SrcGraphic.Draw(Self, DestRect); // TRasterImage.Draw
Changed;
end; |
5) after more digging:
rasterimage.inc
| Code: | procedure TRasterImage.Draw(DestCanvas: TCanvas; const DestRect: TRect);
var
UseMaskHandle: HBitmap;
SrcDC: hDC;
DestDC: hDC;
begin
if (Width=0) or (Height=0)
then Exit;
BitmapHandleNeeded;
if not BitmapHandleAllocated then Exit;
if Masked then
UseMaskHandle:=MaskHandle
else
UseMaskHandle:=0;
SrcDC := Canvas.GetUpdatedHandle([csHandleValid]);
DestCanvas.Changing;
DestDC := DestCanvas.GetUpdatedHandle([csHandleValid]);
StretchMaskBlt(DestDC,
DestRect.Left,DestRect.Top,
DestRect.Right-DestRect.Left,DestRect.Bottom-DestRect.Top,
SrcDC,0,0,Width,Height, UseMaskHandle,0,0,DestCanvas.CopyMode);
DestCanvas.Changed;
end; |
most important part:
| Code: | StretchMaskBlt(DestDC,
DestRect.Left,DestRect.Top,
DestRect.Right-DestRect.Left,DestRect.Bottom-DestRect.Top,
SrcDC,0,0,Width,Height, UseMaskHandle,0,0,DestCanvas.CopyMode); |
| Quote: |
StretchMaskBlt(DestDC, DX, DY, DWidth, DHeight,
SrcDC, SX, SY, SWidth, SHeight, UseMaskHandle, XMask, YMask, DestCanvas.CopyMode) |
So after few modification, I think, we are able to use it like "copyRect".
Can you override this problem with your own Draw procedure ?
Like you made "SimpleThread.pas" to fix fpc 2.6+ TThread bug.
Edit:
inside canvas.inc
| Code: | procedure TCanvas.CopyRect(const Dest: TRect; SrcCanvas: TCanvas;
const Source: TRect);
var
SH, SW, DH, DW: Integer;
Begin
if SrcCanvas= nil then exit;
SH := Source.Bottom - Source.Top;
SW := Source.Right - Source.Left;
if (SH=0) or (SW=0) then exit;
DH := Dest.Bottom - Dest.Top;
DW := Dest.Right - Dest.Left;
if (Dh=0) or (DW=0) then exit;
SrcCanvas.RequiredState([csHandleValid]);
Changing;
RequiredState([csHandleValid]);
//DebugLn('TCanvas.CopyRect ',ClassName,' SrcCanvas=',SrcCanvas.ClassName,' ',
// ' Src=',Source.Left,',',Source.Top,',',SW,',',SH,
// ' Dest=',Dest.Left,',',Dest.Top,',',DW,',',DH);
StretchBlt(FHandle, Dest.Left, Dest.Top, DW, DH,
SrcCanvas.FHandle, Source.Left, Source.Top, SW, SH, CopyMode);
Changed;
end; |
or maybe override CopyRect to use StretchMaskBlt instead of StretchBlt.
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25871 Location: The netherlands
|
Posted: Tue Mar 12, 2013 11:24 am Post subject: |
|
|
The problem is that I have a rule that everyone must be able to compile cheat engine without having to install external packages/libraries.
I might be able to override it by doing a complete copy/paste of the whole LCL graphical side and make that modification, but not a small one like the thread as canvas is buried deep throughout all graphical objects.
You could post this modification to the LCL bugtracker link I posted, and perhaps they'll apply the fix.
But for now draw will suffice. (It's really not that slow)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Tue Mar 12, 2013 5:50 pm Post subject: |
|
|
What you think about this:
http://pastebin.com/ZEKj1Hyj
It adds another lua canvas method - "drawWithMask"
And usage will be:
sender.Canvas.drawWithMask(r.Left, r.Top, r.Right, r.Bottom, bitmap, r.Left, r.Top, r.Right, r.Bottom)
instead of:
sender.Canvas.copyRect(r.Left, r.Top, r.Right, r.Bottom, bitmap.Canvas, r.Left, r.Top, r.Right, r.Bottom)
It works, but probably I miss something. Could you check above patch?
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25871 Location: The netherlands
|
Posted: Tue Mar 12, 2013 6:21 pm Post subject: |
|
|
Pastebin seems to be blocked from here, got any other place?
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|