User Tools

Site Tools


Sidebar

Multimedia

k23:k23.4:k23.4.5:start

23.4.5 Moviebox

GIF-Bild

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.

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

23.3.5.1 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.

23.4.5.2 Methods

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

23.4.5.3 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.

Moviebox

Figure 23.4.5.2: Moviebox with 2 image formats

23.4.5.4 Source code

' 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

23.4.5.5 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:

Fehlermeldung

Figure 23.4.5.3: GIMP error message

23.4.5.6 Download

Project

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