I've been busy working on a workaround so I made this (messy) code to make a way to handle it.
This example can insert, replace or remove a frame in an anim file.
later. Perhaps it can be used in a similar function and do the same thing as my example with less resources.
Code: Select all
frametowrite = 2
task$ = "insert" ;options are "replace" (default"),"insert" or "remove".
brushtowrite = 2
;create a brush to insert or replace
CreateBrush(2, 640, 480, #RED)
;Create an example anim file with 7 frames
CreateBrush(1, 640, 480)
SelectBrush(1)
SetFillStyle(#FILLCOLOR)
BeginAnimStream(1, "anim_1.gif", 640, 480)
For Local k = 1 To 7
Box(50,200, 200, 30, #BLACK)
TextOut(50, 200, "FRAME NUMBER "..k)
WriteAnimFrame(1, 1)
Next
FinishAnimStream(1)
EndSelect
;f$ = FileRequest("Select an anim file", {Filters = "gif|avi|iff"})
f$ = "anim_1.gif"
If IsAnim(f$)
OpenAnim(1, f$)
Else
SystemRequest("Invalid anim file", "File "..f$.." is not a valid anim file", "OK")
End
EndIf
animwidth = GetAttribute(#ANIM, 1, #ATTRWIDTH)
animheight = GetAttribute(#ANIM, 1, #ATTRHEIGHT)
animframes = GetAttribute(#ANIM, 1, #ATTRNUMFRAMES)
CloseAnim(1)
Function BrushToAnimFrame(brushid, frameno, f$, msg$)
If msg$ <> "remove"
If frameno > animframes Then frameno = animframes+1
Else
If frameno > animframes Then frameno = animframes
EndIf
;Create a temporary brush to store the whole anim
If msg$ = "insert"
CreateBrush(9, animwidth*(animframes+1), animheight, #WHITE)
ElseIf msg$ = "remove"
CreateBrush(9, animwidth*(animframes-1), animheight, #WHITE)
Else
CreateBrush(9, animwidth*(Max(animframes, frameno)), animheight, #WHITE)
EndIf
SelectBrush(9)
Local addwidth = 0
For i = 1 To animframes
LoadAnimFrame(10, i, f$)
If i = frameno And msg$ = "insert" Then addwidth = 1
If i = frameno+1 And msg$ = "remove" Then addwidth = -1
DisplayBrush(10, ((i+addwidth)*animwidth)-animwidth, 0)
Next
If msg$ <> "remove" Then DisplayBrush(brushid, (animwidth*frameno)-animwidth, 0)
EndSelect()
BeginAnimStream(1, f$, 640, 480)
For i = 1 To Max(animframes+addwidth, frameno)
CopyBrush(9, 11)
If msg$ = "remove" And i = animframes
Else
CropBrush(11, (i*animwidth)-animwidth, 0, animwidth, animheight)
WriteAnimFrame(1, 11)
EndIf
Next
FinishAnimStream(1)
FreeBrush(9)
FreeBrush(10)
FreeBrush(11)
Return(frameno, Max(animframes+addwidth, frameno))
EndFunction
wrtto, frs = BrushToAnimFrame(brushtowrite, frametowrite, f$, task$); (brush id, frame, anim$)
SystemRequest("Done", "Finished updating anim file\nFrame "..wrtto.." updated.\nFrames in anim: "..frs, "OK")
OpenAnim(1, f$)
animframes = GetAttribute(#ANIM, 1, #ATTRNUMFRAMES)
;show the result
LoadAnim(1, f$)
For i = 1 To animframes
LoadAnimFrame(1, i, f$)
DisplayBrush(1, 0 , 0)
Wait(25)
Next
WaitLeftMouse()