Return to FunctionReference page
Function
SWFMovie newSWFMovie();
Purpose
- This function creates a new SWFMovie with the default swf version (version 5 if not set elsewhere).
Parameters
None
Returns
- A new, empty movie object. Additionally, from 14th January 2008, the latest CVS version (that will probably become 0.4.0 beta 6) return's NULL if there was a failure to allocate enough memory for a new memory object.
Language
- C
Ming version
- (unknown). At least 0.3.0 and onwards, possibly earlier versions as well.
Notes
- The new, empty movie object is initialised to 320 x 240 (320 pixels across x 240 pixels high), with a frame rate of 12.0 fps, and a background color of white (Red: 0xff; Green: 0xff; Blue: 0xff)
Example
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <ming.h>
4
5 int main(void)
6 {
7 // Create local variables
8 FILE *file_pointer = NULL;
9 int bitmap_height, bitmap_width;
10 SWFJpegBitmap image_file;
11 SWFMovie test_movie;
12
13
14 // Initialise the movie structure in memory
15 Ming_init();
16 test_movie = newSWFMovie();
17
18 // Set the background color for the movie
19 SWFMovie_setBackground(test_movie, 0x00, 0x00, 0x00);
20
21 // Load an image file, ready for adding to the movie
22 file_pointer = fopen("image.jpg", "rb");
23 if (file_pointer == NULL)
24 {
25 fprintf(stderr, "Image file could not be opened\n");
26 return EXIT_FAILURE;
27 }
28 image_file = newSWFJpegBitmap(file_pointer);
29
30 // Adjust the dimensions of the movie to match the image file
31 bitmap_height = SWFBitmap_getHeight((SWFBitmap) image_file);
32 bitmap_width = SWFBitmap_getWidth((SWFBitmap) image_file);
33 SWFMovie_setDimension(test_movie, bitmap_width, bitmap_height);
34
35 // Set the frame rate for the movie to 12 frames per second
36 SWFMovie_setRate(test_movie, 12.0);
37
38 // Set the total number of frames in the movie to 120
39 SWFMovie_setNumberOfFrames(test_movie, 120);
40
41 // Add the image file to the movie
42 SWFMovie_add(test_movie, (SWFBlock) image_file);
43
44 // Save the swf movie file to disk
45 SWFMovie_save(test_movie, "ming-test.swf");
46
47 return EXIT_SUCCESS;
48 }