⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 placeobject.c

📁 flash swf file player
💻 C
字号:
/*    Ming, an SWF output library    Copyright (C) 2002  Opaque Industries - http://www.opaque.net/    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Lesser General Public    License as published by the Free Software Foundation; either    version 2.1 of the License, or (at your option) any later version.    This library is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    Lesser General Public License for more details.    You should have received a copy of the GNU Lesser General Public    License along with this library; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*//* $Id: placeobject.c,v 1.11 2003/11/08 18:24:57 whamann Exp $ */#include <stdlib.h>#include <string.h>#include "placeobject.h"#include "method.h"#include "block.h"#include "output.h"#include "browserfont.h"#include "outputblock.h"#include "character.h"#include "matrix.h"#include "cxform.h"struct SWFPlaceObject2Block_s{	struct SWFBlock_s block;	SWFOutput out;	SWFCharacter character;	SWFMatrix matrix;	SWFCXform cXform;	int ratio;	int masklevel;	char *name;	int depth;	int move;	int nActions;	int actionORFlags;	SWFAction *actions;	int *actionFlags;//	char *actionChars;};voidwriteSWFPlaceObject2BlockToStream(SWFBlock block,																	SWFByteOutputMethod method, void *data){	int i;	SWFPlaceObject2Block place = (SWFPlaceObject2Block)block;	SWFOutput_writeToMethod(place->out, method, data);	if ( place->nActions > 0 )	{		methodWriteUInt16(0, method, data); /* mystery number */// SWF6: UInt32		if(SWF_versionNum >= 6)			methodWriteUInt32(place->actionORFlags, method, data);		else			methodWriteUInt16(place->actionORFlags, method, data);		for ( i=0; i<place->nActions; ++i )		{			SWFOutputBlock local_block = (SWFOutputBlock)place->actions[i];// SWF6: UInt32			if(SWF_versionNum >= 6)				methodWriteUInt32(place->actionFlags[i], method, data);			else				methodWriteUInt16(place->actionFlags[i], method, data);			methodWriteUInt32(SWFOutputBlock_getLength(local_block), method, data);// SWF6: extra char if(place->actionFlags[i] & 0x20000)			if((SWF_versionNum >= 6) && (place->actionFlags[i] & 0x20000))				method(0, data);			SWFOutput_writeToMethod(SWFOutputBlock_getOutput(local_block), method, data);		}// SWF6: UInt32		if(SWF_versionNum >= 6)			methodWriteUInt32(0, method, data); /* trailing 0 for end of actions */		else			methodWriteUInt16(0, method, data); /* trailing 0 for end of actions */	}}intcompleteSWFPlaceObject2Block(SWFBlock block){	SWFPlaceObject2Block place = (SWFPlaceObject2Block)block;	SWFOutput out = newSizedSWFOutput(42);	int actionLen = 0;	int flags =		((place->name != NULL)			? SWF_PLACE_HAS_NAME : 0) |		((place->ratio != -1)				? SWF_PLACE_HAS_RATIO : 0) |		((place->masklevel != -1)		? SWF_PLACE_HAS_MASK : 0) |		((place->cXform != NULL)		? SWF_PLACE_HAS_CXFORM : 0) |		((place->matrix != NULL)		? SWF_PLACE_HAS_MATRIX : 0) |		((place->character != NULL) ? SWF_PLACE_HAS_CHARACTER : 0) |		((place->move != 0)					? SWF_PLACE_MOVE : 0) |		((place->nActions != 0)			? SWF_PLACE_HAS_ACTIONS : 0);	SWFOutput_writeUInt8(out, flags);	SWFOutput_writeUInt16(out, place->depth);	if ( place->character != NULL )		SWFOutput_writeUInt16(out, CHARACTERID(place->character));	if ( place->matrix != NULL )		SWFOutput_writeMatrix(out, place->matrix);	if ( place->cXform != NULL )		SWFOutput_writeCXform(out, place->cXform, SWF_PLACEOBJECT2);	if ( place->ratio != -1 )		SWFOutput_writeUInt16(out, place->ratio);	if ( place->masklevel != -1 )		SWFOutput_writeUInt16(out, place->masklevel);	if ( place->name != NULL )		SWFOutput_writeString(out, (byte*)place->name);	if ( place->nActions != 0 )	{		int i;// SWF6: 6		actionLen += (SWF_versionNum >= 6 ? 6 : 4);		for ( i=0; i<place->nActions; ++i )		{			SWFOutputBlock local_block = (SWFOutputBlock)place->actions[i];// SWF6: 8 (9 if char)			actionLen += (SWF_versionNum >= 6 ? 8 : 6) + SWFOutputBlock_getLength(local_block);			if((SWF_versionNum >= 6) && (place->actionFlags[i] & 0x20000))				actionLen++;		}// SWF6: 4		actionLen += (SWF_versionNum >= 6 ? 4 : 2);	}	place->out = out;	return SWFOutput_getLength(out) + actionLen;}voiddestroySWFPlaceObject2Block(SWFPlaceObject2Block place){	if ( place->actions != NULL )		free(place->actions);	if ( place->actionFlags != NULL )//	{	free(place->actionChars);		free(place->actionFlags);//	}	if ( place->name != NULL )		free(place->name);	if ( place->out != NULL )		destroySWFOutput(place->out);	if ( place->matrix != NULL )		destroySWFMatrix(place->matrix);	if ( place->cXform != NULL )		destroySWFCXform(place->cXform);	free(place);}SWFPlaceObject2BlocknewSWFPlaceObject2Block(int depth){	SWFPlaceObject2Block place = (SWFPlaceObject2Block)malloc(sizeof(struct SWFPlaceObject2Block_s));	SWFBlockInit((SWFBlock)place);	BLOCK(place)->type = SWF_PLACEOBJECT2;	BLOCK(place)->writeBlock = writeSWFPlaceObject2BlockToStream;	BLOCK(place)->complete = completeSWFPlaceObject2Block;	BLOCK(place)->dtor = (destroySWFBlockMethod) destroySWFPlaceObject2Block;	place->out = NULL;	place->name = NULL;	place->move = 0;	place->matrix = NULL;	place->cXform = NULL;	place->character = NULL;	place->masklevel = -1;	place->ratio = -1;	place->depth = depth;	place->nActions = 0;	place->actionORFlags = 0;	place->actionFlags = NULL;//	place->actionChars = NULL;	place->actions = NULL;	return place;}voidSWFPlaceObject2Block_setName(SWFPlaceObject2Block block, const char *name){	if ( block->name != NULL )		free(block->name);	block->name = strdup(name);}voidSWFPlaceObject2Block_setRatio(SWFPlaceObject2Block block, int ratio){	block->ratio = ratio;}voidSWFPlaceObject2Block_setDepth(SWFPlaceObject2Block block, int depth){	block->depth = depth;}voidSWFPlaceObject2Block_setMaskLevel(SWFPlaceObject2Block block, int masklevel){	block->masklevel = masklevel;}voidSWFPlaceObject2Block_setCXform(SWFPlaceObject2Block block, SWFCXform cXform){	block->cXform = cXform;}voidSWFPlaceObject2Block_setColorAdd(SWFPlaceObject2Block block,																 int r, int g, int b, int a){	if ( block->cXform == NULL )		block->cXform = newSWFAddCXform(r, g, b, a);	else		SWFCXform_setColorAdd(block->cXform, r, g, b, a);}voidSWFPlaceObject2Block_setColorMult(SWFPlaceObject2Block block,																	float r, float g, float b, float a){	if ( block->cXform == NULL )		block->cXform = newSWFMultCXform(r, g, b, a);	else		SWFCXform_setColorMult(block->cXform, r, g, b, a);}voidSWFPlaceObject2Block_setMatrix(SWFPlaceObject2Block block, SWFMatrix matrix){	if ( block->matrix != NULL )		free(block->matrix);	block->matrix = SWFMatrix_dup(matrix);}voidSWFPlaceObject2Block_setCharacter(SWFPlaceObject2Block block,																	SWFCharacter character){	block->character = character;}voidSWFPlaceObject2Block_setMove(SWFPlaceObject2Block block){	block->move = 1;}voidSWFPlaceObject2Block_addAction(SWFPlaceObject2Block block,															 SWFAction action, int flags){	block->actions =		(SWFAction*)realloc(block->actions, (block->nActions+1) * sizeof(SWFAction));	block->actionFlags =		(int*)realloc(block->actionFlags, (block->nActions+1) * sizeof(int));//	block->actionChars =//		realloc(block->actionChars, (block->nActions+1));	block->actions[block->nActions] = action;	block->actionFlags[block->nActions] = flags;//	block->actionChars[block->nActions] = actChar;	block->actionORFlags |= flags;	++block->nActions;}/* * Local variables: * tab-width: 2 * c-basic-offset: 2 * End: */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -