Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Add an image / picture to CE trainer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Jul 09, 2015 10:03 pm    Post subject: Add an image / picture to CE trainer Reply with quote

Dear guys,

Code:

t1 = createForm()
t2 = createPanel(t1)
control_setSize(t1, 320, 183)
control_setCaption(t1,"Test Trainer")
x,y = control_getSize(t1)
control_setSize(t2, x,y)
-- Add image / picture
img = createImage(t1)



How to add a picture as background image by lua script ? (not by form designer)

Does anybody could give a hint / helps ?

Thanks
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Sat Jul 11, 2015 1:07 am    Post subject: Reply with quote

Check http://forum.cheatengine.org/viewtopic.php?t=579963 pls
_________________
- Retarded.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Jul 11, 2015 5:03 am    Post subject: Reply with quote

Thanks Panraven.

The function work properly. For now I just need adjustment image size same to form size.

Anyway maybe should find out to how set control for image / picture property (e.q stretch, size, etc) for the bitmap copy and paste to form with your function.

Code:

function attachBackground(wc,tblFile)
  local p = createPicture()
  p.loadFromStream(findTableFile(tblFile).Stream)
  wc.OnPaint = function(sender)
    local c = sender.getCanvas()
    local bitmap = p.getBitmap()
    c.draw(0,0,bitmap)
  end
end

t0 = createForm()
control_setSize(t0, 300, 200)
x,y = control_getSize(t0)
attachBackground(t0,[[batman1.png]])

--- trying find out how to scaling image loaded to t0 form
--- t2 = createImage(t0)
--- a = attachBackground(t2,[[batman1.png]])
--- t3 = setProperty("Picture", a)
--- control_setSize(t3, x,y)

t0.show()



test2.JPG
 Description:
 Filesize:  79.75 KB
 Viewed:  11214 Time(s)

test2.JPG


Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Sun Jul 12, 2015 5:14 am    Post subject: Reply with quote

oops, I overlooked the copyRect function.

here,

Code:
function attachBackground(wc,tblFile,xoff,yoff,w,h,BorderAdjust)
  if wc and wc.getCanvas then
    rawset(_G,'bmCache',rawget(_G,'bmCache') or {})
    if not bmCache[tblFile] then
      local p = createPicture()
      p.loadFromStream(findTableFile(tblFile).Stream)
      bmCache[tblFile] = p.getBitmap()
    end
    local b = bmCache[tblFile]
    xoff,yoff,w,h = xoff or 0,yoff or 0,w or b.Width, h or b.Height
    wc.OnPaint = function(sender)
      local c,bw=sender.Canvas,type(BorderAdjust) == 'number' and wc.BorderWidth + BorderAdjust or 0
      c.copyRect(bw,bw,wc.Width-bw,wc.Height-bw,b.Canvas,xoff,yoff,xoff+w,yoff+h)
    end
    return true
  else
    return false,'the object has no canvas'
  end
end

-- to draw with BorderAdjust (adder to BorderWidth of the wc) but not specific the bitmap xoff,yoff etc call like:
attachBackground(UDF1,[[soulhacker.png]],nil,nil,nil,nil,1) -- 1 pixel add to control border
-- otherwise if just not specific the bitmap xoff,yoff etc:
attachBackground(UDF1,[[soulhacker.png]])


...but seems not many control can be paint background this way.
I expected common control like button can be but seems not.

_________________
- Retarded.


Last edited by panraven on Mon Jul 13, 2015 6:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Jul 12, 2015 8:19 pm    Post subject: Reply with quote

Thank you very much Panraven. You are really very good.
It's done.

Regards



Capture.JPG
 Description:
 Filesize:  121.88 KB
 Viewed:  11065 Time(s)

Capture.JPG


Back to top
View user's profile Send private message
___obmib___
How do I cheat?
Reputation: 0

Joined: 03 Aug 2015
Posts: 5
Location: qatar

PostPosted: Sat Aug 22, 2015 9:38 pm    Post subject: Reply with quote

hey guys still having some problem in making an image on the trainer itself.do i need to create a udf form and put an image in the form designer...thanks in advance
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites