Figure 23.3.5.1: GIF image on the website http://gambasdoc.org/help/comp/gb.qt/moviebox
This class provides a control that displays animated GIF images or MNG images. GIF images or MNG images consist of several individual images that are displayed one after the other for an adjustable period of time, just like a film.
These are the most important properties of the container component Moviebox that you can query or set:
The .Rewind method resets the film to the beginning. After stopping a film, you can either let the film continue or restart it.
In the following programme, you can start, stop and continue animated graphics in two different formats or reset the film to the first frame. However, you will only recognise the reset if the film has a length of a few seconds. A film legolok.gif is included with the project, which you can use for your own experiments with the Moviebox.
Figure 23.4.5.2: Moviebox with 2 image formats
' Gambas class file PUBLIC SUB Form_Open() FMain.Center() FMain.Border = 1 MovieBox1.Path = "Images/tanzen.gif" MovieBox2.Path = "Images/tanzen.mng" MovieBox1.Visible = TRUE MovieBox2.Visible = TRUE MovieBox1.Border = Border.Sunken MovieBox2.Border = Border.Raised ' … the visual difference is minimal StartAnimation() END PRIVATE SUB StartAnimation() MovieBox1.Playing = TRUE MovieBox2.Playing = TRUE btnStart.Enabled = FALSE END PUBLIC SUB btnStart_Click() IF checkBox1.Value = TRUE THEN MovieBox1.Rewind() MovieBox1.Playing = TRUE MovieBox2.Playing = TRUE btnStart.Enabled = FALSE btnStopp.Enabled = TRUE END PUBLIC SUB btnStopp_Click() MovieBox1.Playing = FALSE MovieBox2.Playing = FALSE btnStopp.Enabled = FALSE btnStart.Enabled = TRUE END PUBLIC SUB btnClose_Click() btnStopp_Click() btnStart.Enabled = FALSE WAIT 0.8 FMain.Close END
When compiling the programme, you will receive various error messages in the console of the Gambas IDE, which obviously have to do with the format of the animated MNG images:
MNG error 4: Encountered unexpected end-of-file; chunk vpAg; subcode 0:0 MNG error 11: Function is invalid at this point; chunk vpAg; subcode 0:0
You can use the convert programme to create a film in MNG format from several individual images in a directory or convert an image in GIF format to MNG format - without an error message if the syntax is correct:
hans@linux:~$ convert -delay 10 b-*.png film.mng hans@linux:~$ animate film.mng hans@linux:~$ convert /home/hans/bild.gif /home/hans/bild.mng hans@linux:~$ animate film.mng
Obviously the programme convert does NOT convert correctly to the MNG format, which is neither W3C-compliant nor otherwise supported - not even by Firefox. The Gimp programme also cannot do anything with the MNG format, as the following error message shows:
Figure 23.4.5.3: GIMP error message