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 


I think CE7.1 can help me make a circular image and save it

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Tue Sep 15, 2020 9:23 am    Post subject: I think CE7.1 can help me make a circular image and save it Reply with quote

Like the effect in the example figure, how to turn a right angle image into a circular image, and then save it to disk


Circular image.png
 Description:
 Filesize:  761.29 KB
 Viewed:  1926 Time(s)

Circular image.png


Back to top
View user's profile Send private message
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Wed Sep 16, 2020 10:25 am    Post subject: Reply with quote

just use photoshop, I don't think you really can
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Thu Sep 17, 2020 4:44 am    Post subject: Reply with quote

This is not perfect and I don't know how to save the result to local disk, except creating and using circular crop TImage. Maybe someone else known it better, but who care about my opinion?. LOL!

Code:
if f then f.destroy() end

f = createForm()
f.setSize(400,400)
f.Position = 'poScreenCenter'
f.Color = 997002

p = createPanel(f)
p.setSize(380,380)
p.setPosition(10,10)

img = createImage(p)
img.setSize(380,380)
img.setPosition(0,0)
img.Stretch = true
img.Picture.loadFromStream(findTableFile('girl.png').stream)
img.OnMouseDown = function() f.dragNow() end

p.OnPaint = function()
 if ABitmap then ABitmap.Destroy() end
 ABitmap = createBitmap(p)
 ABitmap.Width = p.Width
 ABitmap.Height = p.Height
 ABitmap.Canvas.Brush.Color = 0
 ABitmap.Canvas.fillRect(0,0, p.Width, p.Height)
 ABitmap.Canvas.Brush.Color = 0xffffff
 ABitmap.Canvas.ellipse(0, 0, p.Width, p.Height)
 p.setShape(ABitmap)
end



Capture.JPG
 Description:
 Filesize:  38.04 KB
 Viewed:  1841 Time(s)

Capture.JPG



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Thu Sep 17, 2020 8:18 am    Post subject: Reply with quote

@Corroder
You can copy the image to a bitmap and save it to disk in the following way:
Code:
Canvas.CopyRect

Code:
ABitmap.SaveToFile([[C:\\bla.jpg]])



bitmap.png
 Description:
 Filesize:  7.96 KB
 Viewed:  1827 Time(s)

bitmap.png


Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Thu Sep 17, 2020 7:06 pm    Post subject: Reply with quote

@lua, yes I know. I can use copyRect, but that only copy and save the rect (in this case is ABitmap). What I mean is, save the rect including the picture image.

In C#/VB Net I can use graphic path, region and set clip to get the source image turn into circular crop and save it as new image. Idk how to do that in CE Lua.

And the other question is. How to make selection in CE Lua, to select an area of the screen. Using tag?. Then about SetBounds().

Example in Lazarus / free pascal:

Code:
Sel.Visible = true
Sel.SetBounds(prevX, prevY, X-prevX, y-prevY)

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Fri Sep 18, 2020 7:15 am    Post subject: Reply with quote

Ok. This is the work one. Change square image circle shape and save the result to local disk.

Note:
I don't know why it take about 1 minutes when do copyRect, before get the result.

Code:
if f then f.destroy() end

f = createForm()
f.setSize(800,400)
f.Position = 'poScreenCenter'

p = createPanel(f)
p.setSize(380,380)
p.setPosition(10,10)

img = createImage(p)
img.setSize(380,380)
img.setPosition(10,10)
img.Stretch = true
img.Picture.loadFromStream(findTableFile('girl.png').stream)

img2 = createImage(f)
img2.setSize(380,380)
img2.setPosition(400,10)
img2.Stretch = true

p.OnPaint = function()
 if ABitmap then ABitmap.Destroy() end
 ABitmap = createBitmap(p)
 ABitmap.Width = p.Width
 ABitmap.Height = p.Height
 ABitmap.Canvas.Brush.Color = 0
 ABitmap.Canvas.fillRect(0,0, p.Width, p.Height)
 ABitmap.Canvas.Brush.Color = 0xffffff
 ABitmap.Canvas.ellipse(0, 0, p.Width, p.Height)
 p.setShape(ABitmap)
 img2.Picture.Bitmap.Width= img2.Width
 img2.Picture.Bitmap.Height= img2.Height
 sc = img.getCanvas()
 img2.canvas.copyRect(0,0, img2.Width, img2.Height, sc, 0, 0, img2.Width, img2.Height)
 img2.Picture.SaveToFile('D:\\test.png')
 ABitmap.Destroy()
end



Capture.JPG
 Description:
Circular Shape Image
 Filesize:  52.21 KB
 Viewed:  1786 Time(s)

Capture.JPG



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Fri Sep 18, 2020 8:48 am    Post subject: Reply with quote

Corroder wrote:

Note:
I don't know why it take about 1 minutes when do copyRect, before get the result.
You should add the following to the function:
Code:
img.Transparent=true


Corroder wrote:
Ok. This is the work one. Change square image circle shape and save the result to local disk.
The color of the form will be used as the background color of img2. Now how to remove the background color and leave only the circular image, CE seems to have no function to cut the image.(Images on disk, not on forms)

Finally, does the Delphi code in the figure have reference value



DelphiCode.png
 Description:
 Filesize:  25.7 KB
 Viewed:  1753 Time(s)

DelphiCode.png



NopColor.png
 Description:
 Filesize:  320.91 KB
 Viewed:  1771 Time(s)

NopColor.png


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