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 


How do I load pictures from zip into the image control?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
gfetgkh
Newbie cheater
Reputation: 0

Joined: 06 Apr 2018
Posts: 22

PostPosted: Sun Dec 22, 2019 4:51 am    Post subject: How do I load pictures from zip into the image control? Reply with quote

Zip is added to TableFile, How do I load pictures from zip into the image control?


zip.png
 Description:
 Filesize:  291.59 KB
 Viewed:  4568 Time(s)

zip.png


Back to top
View user's profile Send private message
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3329

PostPosted: Sun Dec 22, 2019 4:56 am    Post subject: Reply with quote

I am curious: why'd you ZIP a JPG?
JPGs are already compressed.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25820
Location: The netherlands

PostPosted: Sun Dec 22, 2019 5:01 am    Post subject: Reply with quote

extract the contents of the .zip and then add that to the cheat table

or write your own unzip code in lua

_________________
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
View user's profile Send private message MSN Messenger
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Sun Dec 22, 2019 5:28 am    Post subject: Reply with quote

Dark Byte wrote:
extract the contents of the .zip and then add that to the cheat table

or write your own unzip code in lua
Do you have any codes or examples related to Lua unpacking
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 22, 2019 10:26 am    Post subject: Reply with quote

Files added to the CT file are already compressed with zlib.

Of course when you save to CT file, compressed stream (inside memory stream) is serialized and converted to text ( binary-to-text encoding - my implementation of Ascii85 encoding)
and overhead is 25%

For example you added 100KB file and zlib can compress it to 60%, final size in the CT file will be:
100KB * 60% * 125% = 75KB


EDIT:
Csimbi wrote:
I am curious: why'd you ZIP a JPG?
JPGs are already compressed.

It got me thinking. Maybe he wants to add few hundreds of files.

I've just written a simple "CE Tape Archiver" (CETAR) implementation.

Creating CETAR:
Code:
testArchive = getCETapeArchive('bigBuckBunny.cetar', true) -- getCETapeArchive(name, OPTIONAL reset default false)

filepath = [[C:\Users\mgrinzPlayer\Desktop\big buck bunny\]]

for i=1,300 do
  local fileName = string.format('image%04d.jpg',i)
  testArchive.addFile(fileName, filepath..fileName)
end


List all files from CETAR:
Code:
testArchive = getCETapeArchive('bigBuckBunny.cetar') -- getCETapeArchive(name, OPTIONAL reset=false)
print( testArchive.listContent() )



Using CETAR:
Code:
testArchive = getCETapeArchive('bigBuckBunny.cetar') -- getCETapeArchive(name, OPTIONAL reset=false)

form = createForm()
image = createImage(form)
image.Proportional = true
image.Align = 'alClient'

imageNumber = 0
timer = createTimer(form)
timer.Interval = 1
timer.OnTimer = function ()
  local fileName = string.format('image%04d.jpg',imageNumber + 1)

  local fileMemoryStream = testArchive.findFile(fileName)

  image.Picture.Jpeg.loadFromStream(fileMemoryStream)
  fileMemoryStream.destroy()

  form.Caption = imageNumber
  imageNumber = (imageNumber + 1) % 300
end





Demo files (zipped CT files):
1. "CE Tape Archiver" demo
2. Traditional way

3846KB versus 4053KB

3. cetrainer versions





 

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

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sun Dec 22, 2019 7:43 pm    Post subject: Reply with quote

mgr.inz.Player CETAR tool is very useful. Thanks.

Before use mgr.inz.Player CETAR tool, I am using vbs script to unzip files.

unzip.vbs :

Code:
'The location of the zip file.
ZipFile="E:\Capture.Zip"
'The folder the contents should be extracted to.
ExtractTo="E:\Capture\"

'If the extraction location does not exist create it.
Set fso = CreateObject("Scripting.FileSystemObject")
If NOT fso.FolderExists(ExtractTo) Then
   fso.CreateFolder(ExtractTo)
End If

'Extract the contants of the zip file.
set objShell = CreateObject("Shell.Application")
set FilesInZip=objShell.NameSpace(ZipFile).items
objShell.NameSpace(ExtractTo).CopyHere(FilesInZip)
Set fso = Nothing
Set objShell = Nothing


example use with CE (zip contain single image file)

Code:
f = createForm()
img = createImage(f)
img.Align = 'alClient'
img.Stretch = true

path = TrainerOrigin or getMainForm()
pic_zip = findTableFile('Capture1.zip')
pic_zip.saveToFile(path..'//Capture.zip')
os.execute('unzip.vbs')

file = path..'//Capture//'
img.Picture.loadFromFile(file..'Capture1.jpg')


_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3329

PostPosted: Mon Dec 23, 2019 1:13 pm    Post subject: Reply with quote

mgr.inz.Player wrote:

It got me thinking. Maybe he wants to add few hundreds of files.

I've just written a simple "CE Tape Archiver" (CETAR) implementation.

 

Nice!
Back to top
View user's profile Send private message
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Wed Dec 25, 2019 9:49 am    Post subject: Reply with quote

mgr.inz.Player wrote:

Code:
testArchive = getCETapeArchive('bigBuckBunny.cetar', true

 
Do you have to use it from the form,I wonder if I can use it from my local disk
Code:
testArchive.listContent()
How to get its total
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Wed Dec 25, 2019 1:46 pm    Post subject: Reply with quote

.lua wrote:
Do you have to use it from the form. I wonder if I can use it from my local disk

Yes you can (needs some modifications). But, what's the point?
.lua wrote:
How to get its total

File count? Archive byte size?
Code:
sizeInBytes = testArchive.stream.Size

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

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Dec 25, 2019 9:48 pm    Post subject: Reply with quote

.lua wrote:

 
Do you have to use it from the form,I wonder if I can use it from my local disk[[/quote]

I did it before in the traditional way.

Demo :
https://youtu.be/FCgWobo9NjI

Source code:
https://mega.nz/#!74EG0IBQ!gBciG45nzn2y0CJn6J5Qe6RqBIZfg8ObIzEBCGqsfN8

_________________
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 Dec 26, 2019 12:00 am    Post subject: Reply with quote

mgr.inz.Player wrote:
File count?
Yes, get file count
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