Return to FunctionReference page
Function
int Ming_init(void);
Purpose
Initialises Ming. Call this before any other Ming functions
Parameters
None
Returns
- 0 if all went well, non-0 if something went wrong.
Language
- C
Ming version
- (unknown). At least 0.3.0 and onwards, possibly earlier versions as well.
Notes
Call this before any other Ming functions
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 = newSWFMovieWithVersion(7);
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, 2);
40
41 // Add the image file to the movie
42 SWFMovie_add(test_movie, (SWFBlock) image_file);
43
44 // Set the desired compression level for the output (9 = maximum compression)
45 Ming_setSWFCompression(9);
46
47 // Save the swf movie file to disk
48 SWFMovie_save(test_movie, "ming-test.swf");
49
50 return EXIT_SUCCESS;
51 }