Exemplo n.º 1
0
EXPORT BOOL WINAPI m_save(HSPEXINFO *hei, int p2, int p3, int p4)
{
	char *filename;
	int level, oldval, size;
	lstrcpy(funcname, "m_save");
	filename = hei->HspFunc_prm_gets();
	level = hei->HspFunc_prm_getdi(-1);
	if (level < -1 || level > 9)
		return -1;
	oldval = Ming_setSWFCompression(level);
	size = -SWFMovie_save(mhsp_movie, filename);
	Ming_setSWFCompression(oldval);
	return size;
}
Exemplo n.º 2
0
	/*
     * 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);

}
Exemplo n.º 3
0
EXPORT BOOL WINAPI m_output(HSPEXINFO *hei, int p2, int p3, int p4)
{
	char *data;
	int level, oldval, size;
	lstrcpy(funcname, "m_output");
	data = (char *)hei->HspFunc_prm_getv();
	method_size = hei->HspFunc_prm_geti();
	level = hei->HspFunc_prm_getdi(-1);
	if (level < -1 || level > 9) {
		return -1;
	}
	oldval = Ming_setSWFCompression(level);
	method_index = 0;
	size = -SWFMovie_output(mhsp_movie, (SWFByteOutputMethod)mhsp_method, data);
	Ming_setSWFCompression(oldval);
	return size;
}
Exemplo n.º 4
0
int
main (int argc, char **argv)
{
  if (Ming_init ())
    return 1;
  Ming_setSWFCompression (-1);

  do_movie (1);
  do_movie (2);

  return 0;
}
Exemplo n.º 5
0
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
}
Exemplo n.º 6
0
int
main()
{
	int swfcompression=-1; // be fast, we don't care
	                       // about compression, do we ?
	if ( Ming_init() )
	{
		fprintf(stderr, "Ming initialization error\n");
		exit(EXIT_FAILURE);
	}

	// TODO: use multiple SWF target versions !

	Ming_setSWFCompression(swfcompression);

	return do_tests();

}
Exemplo n.º 7
0
static void ming_begin_job(GVJ_t * job)
{
    SWFMovie movie;
    SWFAction action;

    Ming_init();
    Ming_useSWFVersion(SWFVERSION);
    Ming_setSWFCompression(SWFCOMPRESSION);
    movie = newSWFMovie();
    SWFMovie_setRate(movie, SWFFRAMERATE);
    SWFMovie_setDimension(movie, job->width, job->height);

// Works, but why is it here?
//    action = newSWFAction(script);
//    SWFMovie_add(movie, (SWFBlock)action);

    job->context = (void*) movie;
}
Exemplo n.º 8
0
int
main (int argc, char **argv)
{
	int width=640, height=480;    /* default stage size */
	int i;
	int swfcompression = DEFSWFCOMPRESSION;
	float framerate = 12.0;
	/*
	 * Allow network access from locally-loaded movies.
	 *
	 *   0 = file access
	 *   1 = network access
	 *  -1 = unspecified (omit the tag if SWF < 8, file access otherwise)
	 *
	 *  By default is unspecified.
	 */
	int networkAccess = -1;
	int usedfiles = 0;
	struct stat statbuf;
	int debug_parser = 0;	
#ifdef HAVE_GETOPT_LONG
	struct option opts[] =
	{
		{"dont-preprocess", 0, 0, 'p'},
		{"frame-rate", 1, 0, 'r'},
		{"swfversion", 1, 0, 'v'},
		{"bgcolor", 1, 0, 'b'},
		{"compression", 1, 0, 'c'},
		{"includepath", 1, 0, 'I'},
		{"define", 1, 0, 'D'},
		{"size", 1, 0, 's'},
		{"network-access", 1, 0, 'n'},
		{"output", 1, 0, 'o'},
		{"import", 1, 0, 'i'},
		{"version", 0, 0, 'V'},
		{"help", 0, 0, 'h'},
		{"debug", 0, 0, 'd'},
		{"init-action", 1, 0, 'a'},
		{0, 0, 0, 0}
	};
	int opts_idx;
#endif
	int c;
	char *me;

	cppargs = malloc(cppargsize);
	sprintf(cppargs, "%s", DEFAULT_FLAGS);
	//cppargs[0] = '\0';


	me = argv[0];

	while (1)
	{
#define BUFSIZE 1024
		char buf [BUFSIZE];

		const char *optstring = "Vhpds:r:D:I:v:c:b:i:o:a:n:";
#ifdef HAVE_GETOPT_LONG
		c = getopt_long (argc, argv, optstring, opts, &opts_idx);
#else
		c = getopt (argc, argv, optstring);
#endif
		if (c == -1) break;

		switch (c)
		{
			case 'p':
				makeswf_set_dopreprocess(0);
				break;
			case 's':
				if ( sscanf(optarg, "%dx%d", &width, &height) != 2 )
				{
					usage(argv[0], EXIT_FAILURE);
				}
				break;
			case 'n':
			{
				if ( ! strcasecmp(optarg, "network") )
				{
					networkAccess = 1;
				}
				else if ( ! strcasecmp(optarg, "file") )
				{
					networkAccess = 0;
				}
				else
				{
					fprintf(stderr, "Network access must be 'network' or 'file'\n");
					exit(1);
				}
				break;
			}
			case 'v':
				if ( sscanf(optarg, "%d", &swfversion) != 1 )
				{
					usage(argv[0], EXIT_FAILURE);
				}
				makeswf_set_swfversion(swfversion);
				break;
			case 'b':
				if ( sscanf(optarg, "%lx", &bgcolor) != 1 )
				{
					usage(argv[0], EXIT_FAILURE);
				}
				useBgColor=1;
				break;
			case 'c':
				if ( sscanf(optarg, "%d", &swfcompression) != 1 )
				{
					usage(argv[0], EXIT_FAILURE);
				}
				if ( swfcompression < -1 || swfcompression > 9 )
				{
					fprintf(stderr, "Compression level must be in the range -1..9\n");
					exit(1);
				}
				break;
			case 'r':
				if ( sscanf(optarg, "%f", &framerate) != 1 )
				{
					usage(argv[0], EXIT_FAILURE);
				}
				break;
			case 'I':
				snprintf(buf, BUFSIZE-1, " -I%s", optarg);
				buf[BUFSIZE-1]='\0';
				makeswf_append_cpparg(buf);
				break;
			case 'i':
				add_import_spec(optarg);
				break;
			case 'o':
				outputfile = optarg;
				break;
			case 'D':
				// yes, you can smash the stack ... 
				snprintf(buf, BUFSIZE-1, " -D%s", optarg);
				buf[BUFSIZE-1]='\0';
				makeswf_append_cpparg(buf);
				break;
			case 'd':
				debug_parser = 1;
				break;
			case 'a':
				add_init_action_spec(optarg);
				break;
			case 'V':
				printf("%s\n", RCSID);
				printf("Copyright (C) 2001-2006 \"Sandro Santilli\" <*****@*****.**>.\n");
				printf("Released under the GNU General Public License.\n");
				exit(EXIT_SUCCESS);
			case 'h':
				usage(argv[0], EXIT_SUCCESS);
			default:
				usage(argv[0], EXIT_FAILURE);
				break;
		}
	}
	argv+=optind;
	argc-=optind;

	if ( argc < 1 ) usage(me, EXIT_FAILURE);

	if ( stat(outputfile, &statbuf) )
	{
		// should warn about overriding (-f ?)
	}

	if ( Ming_init() )
	{
		fprintf(stderr, "Ming initialization error\n");
		exit(EXIT_FAILURE);
	}
	Ming_setWarnFunction(warningHandler);
	//Ming_setErrorFunction(compileError);
	Ming_useSWFVersion(swfversion);
	Ming_setSWFCompression(swfcompression);

	mo = newSWFMovie();
	if ( networkAccess >= 0 ) SWFMovie_setNetworkAccess(mo, networkAccess);
	SWFMovie_setDimension(mo, (float)width, (float)height);
	SWFMovie_setRate(mo, framerate);

	if ( useBgColor )
	{
		SWFMovie_setBackground(mo,
			bgcolor >> 16,
			(bgcolor&0x00FF00) >> 8,
			(bgcolor&0x0000FF));
	}

	printf("Output file name: %s\n", outputfile);
	printf("Output compression level: %d\n", swfcompression);
	printf("Output SWF version: %d\n", swfversion);
	
	 /* 
	 * Add imports
	 */
	if ( numimport_specs ) add_imports();

	for ( i=0; i<argc; i++ )
	{
		SWFAction ac;
		char *filename = argv[i];
		char ppfile[PATH_MAX];

		FileType type = getFileType(filename);

		compile_init_actions(i, debug_parser);

		if ( type == SWF )
		{
			printf("Adding prebuilt clip %s to frame %d... ",
					filename, i);
			embed_swf(mo, filename);
		}
		else if ( type == BITMAP )
		{
			printf("Adding bitmap %s to frame %d... ",
					filename, i);
			embed_image(mo, filename);
		}
		else
		{
			sprintf(ppfile, "%s.frame%d.pp", outputfile, i);
			ac = makeswf_compile_source(filename, ppfile, 
				debug_parser);
			printf("Adding %s to frame %d... ", filename, i);
			SWFMovie_add(mo, (SWFBlock)ac);
		}

		printf("done.\n"); 
		usedfiles++;
		SWFMovie_nextFrame(mo);

	}

	if ( i <= max_init_action_frame )
	{
		fprintf(stderr, "WARNING: following init actions for frames > %d have been discarded:\n", i-1);
		for (;i<=max_init_action_frame; ++i)
		{
			print_init_actions(i, stderr);
		}
	}

	if ( ! usedfiles )
	{
		printf("No valid input files\n");
		return 1;
	}

	printf("Saving output to %s... ", outputfile);
	fflush(stdout);
	SWFMovie_save(mo, outputfile);
	printf("done.\n"); 

	return 0;
}
Exemplo n.º 9
0
EXPORT BOOL WINAPI ming_setSWFCompression(int level, int p2, int p3, int p4)
{
	lstrcpy(funcname, "ming_setSWFCompression");
	return -Ming_setSWFCompression(level);
}
Exemplo n.º 10
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;
}