Example #1
0
SWFFillStyle
SWFShape_addBitmapFillStyle(SWFShape shape, SWFBitmap bitmap, byte flags)
{
	SWFCharacter_addDependency((SWFCharacter)shape, (SWFCharacter)bitmap);

	return addFillStyle(shape, newSWFBitmapFillStyle(bitmap, flags));
}
Example #2
0
/*
 * Adds a block to a movie.
 * This function adds a block or character to a movieclip.
 * returns a SWFDisplayItem 
 */
SWFDisplayItem
SWFMovieClip_add(SWFMovieClip clip, SWFBlock block)
{
	if ( SWFBlock_getType(block) == SWF_DEFINEBITS ||
			 SWFBlock_getType(block) == SWF_DEFINEBITSJPEG2 ||
			 SWFBlock_getType(block) == SWF_DEFINEBITSJPEG3 ||
			 SWFBlock_getType(block) == SWF_DEFINELOSSLESS ||
			 SWFBlock_getType(block) == SWF_DEFINELOSSLESS2 )
	{
		block = (SWFBlock)newSWFShapeFromBitmap((SWFBitmap)block, SWFFILL_TILED_BITMAP);
	}

	if ( SWFBlock_isCharacter(block) )
	{
		SWFCharacter_getDependencies((SWFCharacter)block,
																 &CHARACTER(clip)->dependencies,
																 &CHARACTER(clip)->nDependencies);

		SWFCharacter_addDependency((SWFCharacter)clip, (SWFCharacter)block);

		SWFCharacter_setFinished((SWFCharacter)block);

		return SWFDisplayList_add(clip->displayList, clip->blockList, (SWFCharacter)block);
	}
	else
	{
		/* XXX - make sure it's a legit block for a sprite */
		SWFBlockList_addBlock(clip->blockList, block);
	}

	return NULL;
}
Example #3
0
File: button.c Project: cran/R2SWF
/* adds a character 
 * Add a character to a button for given states
 * possible states:
 * SWFBUTTON_HIT
 * SWFBUTTON_DOWN
 * SWFBUTTON_OVER
 * SWFBUTTON_UP
 * states can be combined using the binary or operator
 * returns a SWFButtonRecord object which can be further modified.
 */
SWFButtonRecord
SWFButton_addCharacter(SWFButton button /* button object */, 
                       SWFCharacter character /* character to be added */, 
                       byte state /* state description */)
{
	SWFMatrix m;
	SWFButtonRecord record;
	SWFCharacter **depsPtr = &CHARACTER(button)->dependencies;
	int *depCount = &CHARACTER(button)->nDependencies;
	
	if ( SWFCharacter_isFinished((SWFCharacter)button) )
	{
		SWF_warn("Can't alter a button after it's been added to another character");
		return NULL;
	}

	SWFCharacter_getDependencies(character, depsPtr, depCount);
	SWFCharacter_addDependency((SWFCharacter)button, character);
	SWFCharacter_setFinished(character);
	
	m = newSWFMatrix(1.0, 0, 0, 1.0, 0, 0);
	record = newSWFButtonRecord(state, character, 0, m);
	SWFButton_addRecord(button, record);
	return record;
}
Example #4
0
/*
 * Stops playing event sound (SWFSound)
 *
 * see also SWFSoundInstance, SWFSound, SWFMovieClip_startSound
 */
void
SWFMovieClip_stopSound(SWFMovieClip clip, SWFSound sound)
{
	SWFCharacter_addDependency((SWFCharacter)clip, (SWFCharacter)sound);

	SWFBlockList_addBlock(clip->blockList,
												(SWFBlock)newSWFSoundInstance_stop(sound));
}
Example #5
0
/*
 * Starts playing event-sound (SWFSound)
 *
 * returns a SWFSoundInstance object.
 * see also SWFSoundInstance, SWFSound, SWFMovieClip_stopSound
 */
SWFSoundInstance
SWFMovieClip_startSound(SWFMovieClip clip, SWFSound sound)
{
	SWFSoundInstance inst = newSWFSoundInstance(sound);

	SWFCharacter_addDependency((SWFCharacter)clip, (SWFCharacter)sound);
	SWFBlockList_addBlock(clip->blockList, (SWFBlock)inst);

	return inst;
}
Example #6
0
/* font machinery:
	if a regular font (outlines in fdb) is used, it is added to the textfield
	as type Font and later converted to a FontChar
	while a Font, characters can be added (embedded)
	an Imported font stays as is, so does a BrowserFont
 */
void
SWFTextField_setFont(SWFTextField field, SWFBlock font)
{
	if(font == NULL)
		return;
	if ( BLOCK(font)->type == SWF_BROWSERFONT )
	{
		field->fonttype = BrowserFont;
		field->font.browserFont = (SWFBrowserFont)font;
		SWFCharacter_addDependency((SWFCharacter)field, (SWFCharacter)font);
		field->flags |= SWFTEXTFIELD_HASFONT;
	}
	else if ( BLOCK(font)->type == SWF_DEFINEFONT 
		|| BLOCK(font)->type == SWF_DEFINEFONT2)
	{
		SWFFontCharacter fc = (SWFFontCharacter)font;
		if(checkSWFFontCharacter(fc))	
		{
			SWF_warn("font is empty or has no layout information\n");
			return;
		}
		field->fonttype = Imported;
		field->font.fontchar = fc;
		SWFCharacter_addDependency(
			(SWFCharacter)field, (SWFCharacter)font);
		field->flags |= SWFTEXTFIELD_HASFONT | SWFTEXTFIELD_USEFONT;
	}
	else if (BLOCK(font)->type == SWF_MINGFONT)
	{
		if(!(SWFFont_getFlags((SWFFont)font) & SWF_FONT_HASLAYOUT))
		{
			SWF_warn("font is empty or has no layout information\n");
			return;
		}
		field->fonttype = Font;
		field->font.font = (SWFFont)font;
		field->flags |= SWFTEXTFIELD_HASFONT | SWFTEXTFIELD_USEFONT;
	}
	else
		SWF_warn("SWFTextField_setFont: not a valid font object\n");
}
Example #7
0
SWFFillStyle
SWFShape_addBitmapFillStyle(SWFShape shape, SWFBitmap bitmap, byte flags)
{
    SWFFillStyle fill;
    SWFCharacter_addDependency((SWFCharacter)shape, (SWFCharacter)bitmap);
    fill = newSWFBitmapFillStyle(bitmap, flags);
    if(addFillStyle(shape, fill) < 0)
    {
        destroySWFFillStyle(fill);
        return NULL;
    }
    return fill;
}
Example #8
0
/* 
 * Import a font from an other SWFFile
 * see also SWFMovie_importCharacter
 * returns a SWFFontCharacter object
 */
SWFFontCharacter
SWFMovie_importFont(SWFMovie movie, const char *filename, const char *name)
{
	SWFFontCharacter res;
	SWFImportBlock importer;
	int id;

	res = newSWFDummyFontCharacter();
	id = CHARACTERID(res);
	importer = SWFMovie_addImport(movie, filename, name, id);
	SWFCharacter_addDependency((SWFCharacter) res, (SWFCharacter) importer);
	return res;
}
Example #9
0
File: button.c Project: cran/R2SWF
static void SWFButton_addRecord(SWFButton button, SWFButtonRecord record)
{
	if ( button->nRecords % BUTTONRECORD_INCREMENT == 0 )
	{
		button->records = (SWFButtonRecord*) realloc(button->records,
						(button->nRecords + BUTTONRECORD_INCREMENT) *
						sizeof(SWFButtonRecord));
	}

	button->records[button->nRecords++] = record;

	SWFCharacter_addDependency((SWFCharacter)button,
														 (SWFCharacter)record->character);
}
Example #10
0
File: button.c Project: cran/R2SWF
/* adds a shape character 
 * Add a shape character to a button for given states
 * possible states:
 * SWFBUTTON_HIT  
 * SWFBUTTON_DOWN  
 * SWFBUTTON_OVER
 * SWFBUTTON_UP
 * states can be combined using the binary or operator    
 * deprecated! use SWFButton_addCharacter instead
 */
void SWFButton_addShape(SWFButton button, SWFCharacter character, byte flags)
{
	SWFMatrix m;
	SWF_warnOnce("SWFButton_addShape is deprecated\nUse SWFButton_addCharacter instead\n");
	if ( SWFCharacter_isFinished((SWFCharacter)button) )
		SWF_error("Can't alter a button after it's been added to another character");

	m = newSWFMatrix(1.0, 0, 0, 1.0, 0, 0);

	SWFCharacter_getDependencies((SWFCharacter)character,
									 &CHARACTER(button)->dependencies,
									 &CHARACTER(button)->nDependencies);

	SWFCharacter_addDependency((SWFCharacter)button, (SWFCharacter)character);

	SWFCharacter_setFinished(character);
	SWFButton_addRecord(button, newSWFButtonRecord(flags, character, 0, m));
}
Example #11
0
/* 
 * Import a character to the movie
 * Imports characters from an other movie. filename (URL) points to a SWF 
 * file with exported characters. 
 *
 * returns a SWFCharacter object
 */
SWFCharacter
SWFMovie_importCharacter(SWFMovie movie, 
                         const char *filename /* URL to movie */, 
                         const char *name /* idetifier of character */)
{
	SWFCharacter res;
	SWFImportBlock importer;
	int id;

	res = (SWFCharacter) malloc(sizeof(struct SWFCharacter_s));
	SWFCharacterInit(res);
	CHARACTERID(res) = id = ++SWF_gNumCharacters;
	BLOCK(res)->type = SWF_DEFINESPRITE;
	BLOCK(res)->writeBlock = NULL;
	BLOCK(res)->complete = completeSWFImportCharacter;
	BLOCK(res)->dtor = (destroySWFBlockMethod) destroySWFCharacter;
	importer = SWFMovie_addImport(movie, filename, name, id);
	SWFCharacter_addDependency(res, (SWFCharacter) importer);
	return res;
}