/* * device_Close is called when the device is killed (dev.off). * This function is responsible for destroying any * device-specific resources that were created in * device_Open and for FREEing the device-specific * parameters structure. * */ static void SWF_Close( pDevDesc deviceInfo){ /* Shortcut pointers to variables of interest. */ swfDevDesc *swfInfo = (swfDevDesc *) deviceInfo->deviceSpecific; //If there is an open deug log, close it if( swfInfo->debug == TRUE ){ fprintf(swfInfo->logFile, "SWF_Close: ending movie with %d frames\n",swfInfo->nFrames); fprintf(swfInfo->logFile, "SWF_Close: end swf output\n"); fclose(swfInfo->logFile); } // Set the desired compression level for the output //(9 = maximum compression) Ming_setSWFCompression(9); //For some reason the last frame does't get drawn unless this happens // but then an extra blank frame gets entered? if( swfInfo->nFrames > 1 ) SWFMovie_nextFrame( swfInfo->m ); // Save the swf movie file to disk SWFMovie_save(swfInfo->m, swfInfo->outFileName); //Clear the movie reference destroySWFMovie(swfInfo->m); Ming_cleanup(); /* Destroy the swfInfo structure. */ free(swfInfo); }
static void ming_end_job(GVJ_t * job) { SWFMovie movie = (SWFMovie)(job->context); SWFMovie_output_to_stream(movie, job->output_file); destroySWFMovie(movie); // destroySWFAction(action); job->context = NULL; }
static void MingSWFClose(pDevDesc RGD) { MingSWFDesc *MGD = (MingSWFDesc *)RGD->deviceSpecific; /* Save plot */ Ming_setSWFCompression(9); SWFMovie_save(MGD->movie, MGD->file); destroySWFMovie(MGD->movie); free(MGD); RGD->deviceSpecific = NULL; #ifdef MINGSWFDEBUG Rprintf("Close(RGD=0x%x)\n",RGD); #endif }
int main() { SWFMovie m = newSWFMovieWithVersion(7); SWFSound sound; SWFSoundStream stream; FILE *file; int ret; file = fopen(MEDIADIR "/audio01.mp3", "rb"); if(!file) { perror(MEDIADIR "/audio01.mp3"); return EXIT_FAILURE; } stream = newSWFSoundStream(file); if (!stream) { fprintf(stderr, "Could not create SWFSoundStream\n"); return EXIT_FAILURE; } sound = newSWFSound_fromSoundStream(stream); if(!sound) { fprintf(stderr, "Could not create SWFSound\n"); return EXIT_FAILURE; } SWFMovie_addExport(m, sound, "audio01.mp3"); SWFMovie_startSound(m, sound); ret = SWFMovie_save(m, "test01.swf"); if ( ret == -1 ) { fprintf(stderr, "Something went wrong during SWFMovie_save\n"); return EXIT_FAILURE; } //SWFSoundStream destroy SWFInput created from file destroySWFSoundStream(stream); destroySWFSound(sound); destroySWFMovie(m); return 0; }
EXPORT BOOL WINAPI destroy_m(SWFMovie movie, int p2, int p3, int p4) { destroySWFMovie(movie); return 0; }
int main(void) { // Create local variables int i; SWFDisplayItem image_display_item; SWFFont font_object; SWFMovie test_movie; SWFText text_object; // Initialise the movie structure in memory Ming_init(); test_movie = newSWFMovieWithVersion(7); // Set the desired compression level // for the output (9 = maximum compression) Ming_setSWFCompression(9); // Set the background color for the movie SWFMovie_setBackground(test_movie, 0x00, 0x00, 0x00); // Adjust the dimensions of the movie SWFMovie_setDimension(test_movie, 800, 600); // Set the frame rate for the movie to 24 frames per second SWFMovie_setRate(test_movie, 24.0); // Load a font from disk font_object = newSWFFont_fromFile("../../fonts/vera/Vera.ttf"); if (NULL == font_object) { // Something went wrong, so exit printf("Unable to load font from file.\n"); return EXIT_FAILURE; } // Create a new, empty text object text_object = newSWFText(); // Tell the text object to use the font previously loaded SWFText_setFont(text_object, font_object); // Set the height of the text SWFText_setHeight(text_object, 18.0); // Set the color of the text SWFText_setColor(text_object, 0x00, 0x00, 0xff, 0xff); // Add a string to the text object SWFText_addString(text_object, "This is some example text", NULL); // Add the text object to the movie (at 0,0) image_display_item = SWFMovie_add(test_movie, (SWFBlock) text_object); // Move to 100, 100 SWFDisplayItem_moveTo(image_display_item, 100.00, 100.0); // Progressively move the text down and to the right for (i = 0; i <= 250; i++) { SWFMovie_nextFrame(test_movie); SWFDisplayItem_move(image_display_item, 2, 2); } // Save the swf movie file to disk SWFMovie_save(test_movie, "ming-test-text.swf"); // Free the swf movie in memory destroySWFMovie(test_movie); // Free the swf text object destroySWFText(text_object); return EXIT_SUCCESS; }