Page 1 of 1

[5.60b1] AddImageFrame with start/stop drawing

Posted: Mon Jan 30, 2017 12:20 pm
by ar-s
That is working

Code: Select all

Enumeration Window
  #mainForm
EndEnumeration

Enumeration Gadget
  #image 
EndEnumeration

Global Image = CreateImage(#PB_Any, 100, 100, 24)
 
Declare Start()
Declare ChangeFrame()
Declare Exit()

Start()

Procedure Start()
  ;Creation de trois frames
  StartDrawing(ImageOutput(Image))
  Box(0, 0, 100, 100, RGB(255, 0, 0)) ;Red
  StopDrawing()
 
  AddImageFrame(Image)
  StartDrawing(ImageOutput(Image))
  Box(0, 0, 100, 100, RGB(0, 0, 255)) ;Blue
  StopDrawing()
 
  AddImageFrame(Image)
  StartDrawing(ImageOutput(Image))
  Box(0, 0, 100, 100, RGB(255, 215, 0)) ;Yellow
  StopDrawing()

; So many StartStopDrawing ! 


  ;Affichage du nombre de frames : On a bien les 3 frames
  Debug "Image frame count " + ImageFrameCount(Image)

  ;Selection de la première frame
  SetImageFrame(Image, 0)
 
  OpenWindow(#mainForm, 0, 0, 500, 300, "Image animée", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ImageGadget(#image, 10, 10, 0, 0, ImageID(Image))
 
  AddWindowTimer(#mainForm, 0, 1000)
 
  ;Triggers
  BindEvent(#PB_Event_CloseWindow, @Exit())
  BindEvent(#PB_Event_Timer, @ChangeFrame())
 
  Repeat : WaitWindowEvent() : ForEver
EndProcedure

Procedure ChangeFrame()
  Static Frame
  Frame +1
  If Frame = 3
    Frame = 0
  EndIf
     
  SetImageFrame(Image, Frame)
  SetGadgetState(#Image, ImageID(Image))
EndProcedure

Procedure Exit() 
  End
EndProcedure

But we should be able to write like that in the Start() Procedure

Code: Select all

;Creation de 3 frames
  StartDrawing(ImageOutput(Image))   ; Only one
  Box(0, 0, 100, 100, RGB(255, 0, 0)) ;Red ; First frame

  AddImageFrame(Image)
  Box(0, 0, 100, 100, RGB(0, 0, 255)) ;Blue

  AddImageFrame(Image)
  Box(0, 0, 100, 100, RGB(255, 215, 0)) ;Yellow

  StopDrawing()  ; Only one
But here the red frame does not appear.

Re: [5.60b1] AddImageFrame with start/stop drawing

Posted: Mon Jan 30, 2017 1:57 pm
by walbus
Interesting,
but, i think the Bug Report thread is not optimal for this
I have linked it in the 560 beta1 thread for further comments and testings

Re: [5.60b1] AddImageFrame with start/stop drawing

Posted: Mon Jan 30, 2017 5:05 pm
by Fred
This is the way it is done for now, it's not a bug. If you want to add a frame, you create a new image and you need to change the drawing area for StartingDrawin().

Re: [5.60b1] AddImageFrame with start/stop drawing

Posted: Mon Jan 30, 2017 9:05 pm
by walbus
Yep Fred,
this all are great news, thanks a lot, it feel very very good !