Example:
GIFIMG1 has 200 frames
I want to create a new image GIFIMG2 with frames 20-30 from GIFIMG1
Right now I am just trying to even copy one but it is my first time working with images in PB maybe some one can help me and or point me in the right direction. Thanks
Code: Select all
UseGIFImageDecoder()
;- DataSection
DataSection
GIFIMG1:
IncludeBinary "a.gif"
EndDataSection
#imgRaw=1
#imgCut=2
Procedure Gif2NewIMG()
CatchImage(#imgRaw, ?GIFIMG1)
CreateImage(#imgCut,150, 150)
StartDrawing(ImageOutput(#imgCut))
SetImageFrame(#imgRaw, 100)
AddImageFrame(#imgCut, ImageFrameCount(#imgCut)-1)
SetImageFrame(#imgCut, ImageFrameCount(#imgCut)-1)
CopyImage(#imgRaw, #imgCut)
DrawImage(ImageID(#imgCut), 0,0)
StopDrawing()
EndProcedure
OpenWindow(0, 100, 100, 400, 400, "")
imgG = ImageGadget(#PB_Any, 0, 0, 150, 150,0)
AddWindowTimer(0, 1, 150)
Gif2NewIMG()
Debug "Now there is " + Str(ImageFrameCount(#imgRaw)) + " frames"
Debug "Now there is " + Str(ImageFrameCount(#imgCut)) + " frames"
;Frame=120
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Timer
SetImageFrame(#imgCut, Frame)
Frame+1
If Frame >= ImageFrameCount(#imgCut)
Frame = 0 : EndIf
SetGadgetState(imgG,ImageID(#imgCut))
EndIf
Until Event = #PB_Event_CloseWindow