|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Thu Sep 24, 2020 6:11 am Post subject: How Zoom In Out An Image Proportional Using TrackBar? |
|
|
I have done by using mouseScrollUp / mouseScrollDown event.
How to do it using trackbar?
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25294 Location: The netherlands
|
Posted: Thu Sep 24, 2020 6:28 am Post subject: |
|
|
set trackbar min to 0, max to 10, and position to 5
then when the position is smaller than 5 you zoom out, and if bigger than 5 you zoom in
e.g trackbar.Position:
0=0.01 zoom
1=0.2 zoom
2=0.4 zoom
3=0.6 zoom
4=0.8 zoom
5=1 zoom
6=1.2 zoom
7=1.4 zoom
8=1.6 zoom
9=1.8 zoom
10=2 zoom
Use the OnChange method to apply the zoom
( you can of course use other ranges as well )
_________________
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 |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Thu Sep 24, 2020 7:18 am Post subject: |
|
|
Thanks DB. I did use trackbar, like this.
Code: | if f then f.destroy() end
f = createForm()
f.Position = 'poScreenCenter'
f.setSize(600, 600)
TrackBar1 = createTrackBar(f)
TrackBar1.Left = 10
TrackBar1.Top = 550
TrackBar1.Width = 200
TrackBar1.Min = 0
TrackBar1.Max = 100
TrackBar1.Position = 50
TrackBar1.Frequency = 10
Image1 = createImage(f)
Image1.setSize(400,400)
Image1.setPosition(0,0)
Image1.Picture.LoadFromStream(findTableFile('myimage.jpg').stream)
Image1.Stretch = true
--Image1.Left = math.floor(f.Width - Image1.Picture.Bitmap.Width) / 2
--Image1.Top = math.floor(f.Height - Image1.Picture.Bitmap.Height) / 2
local CenterX, CenterY, SizeX, SizeY
SizeX = Image1.Width
SizeY = Image1.Height
CenterX = Image1.Left + (SizeX / 2)
CenterY = Image1.Top + (SizeY / 2)
function TrackBar1Change(sender)
local NewSizeX, NewSizeY
NewSizeX = math.ceil(TrackBar1.Position / 100 * SizeX)
NewSizeY = math.ceil(TrackBar1.Position / 100 * SizeY)
Image1.Left = CenterX - (NewSizeX / 2)
Image1.Top = CenterY - (NewSizeY / 2)
Image1.Width = NewSizeX
Image1.Height = NewSizeY
end
TrackBar1.OnChange = TrackBar1Change
|
Now, I will try to implementing your method / suggestion.
EDIT: Done with DB method / suggestion.
Code: | if f then f.Destroy() end
f = createForm()
f.setSize(1000,800)
f.Position = 'poScreenCenter'
Image1 = createImage(f)
Image1.setSize(400,350)
Image1.stretch = true
Image1.setPosition(0,0)
Image1.Picture.loadFromStream(findTableFile('test.jpg').Stream)
t = createTrackBar(f)
t.left = 20
t.top = f.height - 60
t.width = 200
t.height = 30
t.Max = 10
t.Min = 0
t.Step = 1
t.position = 5
t.TickSyle = 'tsAuto'
local w,h = Image1.getSize()
local newW, newH
local zoom = {0.01, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2}
function TrackBar1Change(sender)
local tpos = t.position
if tpos == 0 then return end
newW = w * zoom[tpos]
newH = h * zoom[tpos]
Image1.Width = newW
Image1.Height = newH
end
f.show()
t.onChange = TrackBar1Change
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Thu Sep 24, 2020 2:47 pm Post subject: |
|
|
Panel2 sometimes falls under panel1.
I think it can be edited.
May be good for multi-panel (Imege).
Code: | if f then f.destroy() end
f = createForm()
f.Position=poDesktopCenter f.Width=420
local p2=createPanel(f)
p2.Height=170 p2.Left=20 p2.Top=20 p2.Width=170
p2.caption="Click Select"
local p3=createPanel(f)
p3.Height=180 p3.Left=220 p3.Top=15 p3.Width=180
p3.caption="Click Select"
local tb1=createTrackBar(f)
tb1.Width=f.Width - 20 tb1.left=10 tb1.Top=f.Height - 35
tb1.visible=false
local itemsP=2
local iH=""
local iW=""
local iL=""
local iT=""
function ImageEffect(item, hy, wx, hy1, wx1)
item.Height=tonumber(tb1.Position)
item.Width=tonumber(tb1.Position)
local lft = wx - tonumber(item.Width)
local tp = hy - tonumber(item.Height)
print(lft.." - "..tp)
local lft1 = lft / 2
local tp1 = tp / 2
item.Left=wx1 + lft1
item.Top=hy1 + tp1
end
p2.OnClick=function()
itemsP=1
iH = tonumber(p2.Height)
iW = tonumber(p2.Width)
iL = tonumber(p2.Left)
iT = tonumber(p2.Top)
trackbar_setMax(tb1, tonumber(p2.Width))
tb1.Position=tonumber(p2.Width)
tb1.visible=true
end
p3.OnClick=function()
itemsP=2
iH = tonumber(p3.Height)
iW = tonumber(p3.Width)
iL = tonumber(p3.Left)
iT = tonumber(p3.Top)
trackbar_setMax(tb1, tonumber(p3.Width))
tb1.Position=tonumber(p3.Width)
tb1.visible=true
end
tb1.OnChange=function()
if itemsP==1 then
p2.caption=tonumber(tb1.Position)
ImageEffect(p2, iH, iW, iL, iT) end
if itemsP==2 then
p3.caption=tonumber(tb1.Position)
ImageEffect(p3, iH, iW, iL, iT) end
end |
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Thu Sep 24, 2020 7:22 pm Post subject: |
|
|
Consider the image width vs image.picture.bitmap.width.
Like in photoshop, when open an image, photo, picture; it's display the original bitmap/jpg/png, etc size not the image/document size.
And, I am put the image inside a scrollbox. i.e as attached.
Description: |
Image Zoom By Original Canvas Size |
|
Filesize: |
132.85 KB |
Viewed: |
1552 Time(s) |
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
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
|
|