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 


Creating GIF Animation From Local Images File

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater
Reputation: 26

Joined: 10 Apr 2015
Posts: 914

PostPosted: Mon Jun 03, 2019 9:12 am    Post subject: Creating GIF Animation From Local Images File Reply with quote

Graphics Interchange Format (GIF), is a file extension for an often animated raster graphics file. GIF created by using several bitmap images such as JPEG, BMP, PNG, and many other images formats.

The idea to create a GIF file (animation) is by shows each image by time interval (frames rate) and collection of several shown image usually called as a sprite.

Since CE build by default to handle show three images format type (JPEG, BMP, PNG, and plus ICO); then need some custom functions to show/displaying a GIF format type file to get animation on parent objects such as CEForm and CEPanel.

Storing several images to CE Table File will make a CT File size growing to big size. You can imagine if you save 100 images file to CE Table, it will make your CT File size bigger.

So, we able to get the images and use it to creating a GIF animation from the internet or online file storage, but how if the internet speed is slow?. You can find some functions to creating a GIF animation on this forum if you are not too lazy to find it.

Then, here is a small function use to creating a GIF animation with source images load from local disk.

Code:
function framesAsGif(parentImage, frameDir, frameNumber, speed)

 local pics={}
 local t = {}
 --local path = TrainerOrigin or getMainForm() or frameDir

 function createPictureImg(data)
  local picture = createPicture()
  local stream = createStringStream(data)
  picture.loadFromStream(stream)
  stream.destroy()
  return picture
 end

 for i=1, frameNumber do  ---- change here with total number of frames
  if i < 10 then
  var = '00'..i
  elseif i > 9 and i < 100 then
  var = '0'..i
 else
  var = i
 end
 local frame = 'frame_'..var..'.png'
 table.insert(t,frame)
 end

 for i=1,frameNumber do
  local file = io.open(frameDir..t[i],"rb")  --- change here for path name
  if not file then return nil end
  local pic = file:read("*a")
  local img = createPictureImg(pic)
  pics[i] = img
 end

 pics.currentPicture=1
 local var = 0

 function createGifsy()
  t.enabled = true
  parentImage.Picture=pics[pics.currentPicture]
  if pics.currentPicture == frameNumber then
  t.enabled = false
  t.destroy()
  else
  pics.currentPicture=(pics.currentPicture % frameNumber)+1
  end
 end

 t = createTimer()
 t.interval = speed
 t.enabled = true
 t.onTimer =  createGifsy
end



You can copy paste the script above and save it as a Lua file to CE autorun folder or directly use on your project script.

Explanation:
Code:

function framesAsGif(parentImage, frameDir, frameNumber, speed)


framesAsGif = The function name
frameDir = String, The directory and folder name where the source images located
frameNumber = Number, Total of the images on the directory/folder
speed = Number, The number to control the animation speed. Small number = fast, big number = slow
NOTE: by default, the images name MUST BE 'frame_001', 'frame_002' and so on

SAMPLE:

Code:
-------------------------- TEST CREATING CIRCLE PROGRESS BAR WITH PERCENT
f = createForm()
f.setSize(300,300)
f.Color = '0x000000'
f.Position = 'poScreenCenter'

pbImage = createImage(f)
pbImage.setSize(350,200)
pbImage.stretch = true
pbImage.setPosition(-25,30)

btn = createButton(f)
btn.setSize(50,30)
btn.setPosition(240,260)
btn.Caption = 'Play'

mypath = 'E://GIFframesSource//' -- this contains source images frames, default name = frame_xxx

function gif()
 framesAsGif(pbImage, mypath, 102, 100)
end

function exit()
 closeCE()
 return caFree()
end

f.show()
btn.onClick = gif
f.onClose = exit


If you want to test by yourself here is the link for source images file which you able to download (copy paste to your web browser):

https://mega.nz/#!T5tFlaSD!D0rftajCO_9Y0-oeoeEWSOwK2vdbuXTe0Y_oM7G8BII

Edit, modify or share all of these is on my pleasure. It's free!

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

Joined: 16 Feb 2017
Posts: 329

PostPosted: Mon Jun 03, 2019 12:47 pm    Post subject: Reply with quote

This is a more regular version of the previous version.
The other code was a little more complicated
(Created with Corroder and FreeER, gif code.)
and I liked the following code.

Picture - Path - Number of Photos - Execution Speed ...
Code:
framesAsGif(pbImage, mypath, 102, 100)


Congratulations. Regular and nice work.

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions 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