User Tools

Site Tools




23.4.5 Moviebox


Figure GIF image on the website

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.

  • GIF - Graphics Interchange Format
  • MNG - Multiple-Image Network Graphics Properties

These are the most important properties of the container component Moviebox that you can query or set:

  • Property Border AS Integer: You can set a border (Etched, Plain, Raised or Sunken) for the moviebox or do without a border (None)
  • Property Path AS String: Path to the GIF image or to the MNG image
  • Property Playing AS Boolean: By setting this property, you start or stop the animation. Methods

The .Rewind method resets the film to the beginning. After stopping a film, you can either let the film continue or restart it. Project

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 Moviebox with 2 image formats Source code

' Gambas class file
PUBLIC SUB Form_Open()
  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
PRIVATE SUB StartAnimation()
  MovieBox1.Playing = TRUE
  MovieBox2.Playing = TRUE
  btnStart.Enabled = FALSE
PUBLIC SUB btnStart_Click()
  IF checkBox1.Value = TRUE THEN MovieBox1.Rewind()
  MovieBox1.Playing = TRUE
  MovieBox2.Playing = TRUE
  btnStart.Enabled = FALSE
  btnStopp.Enabled = TRUE
PUBLIC SUB btnStopp_Click()
  MovieBox1.Playing = FALSE
  MovieBox2.Playing = FALSE
  btnStopp.Enabled = FALSE
  btnStart.Enabled = TRUE
PUBLIC SUB btnClose_Click()
  btnStart.Enabled = FALSE
  WAIT 0.8
END Notes

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 GIMP error message Download



The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k23/k23.4/k23.4.5/start.txt · Last modified: 08.03.2024 by emma

Page Tools