📄 outputblock.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: outputblock.c,v 1.15 2006/09/01 00:21:13 strk Exp $ */#include <stdio.h>#include <stdlib.h>#include <string.h>#include "outputblock.h"#include "method.h"#include "block.h"#include "character.h"#include "matrix.h"#include "cxform.h"#include "libming.h"struct SWFOutputBlock_s{ struct SWFBlock_s block; SWFOutput output;};SWFOutputSWFOutputBlock_getOutput(SWFOutputBlock block){ return block->output;}intSWFOutputBlock_getLength(SWFOutputBlock block){ return SWFOutput_getLength(block->output);}voidwriteSWFOutputBlockToStream(SWFBlock block, SWFByteOutputMethod method, void *data){ SWFOutput out = ((SWFOutputBlock)block)->output; SWFOutput_writeToMethod(out, method, data);}intgetSWFOutputBlockLength(SWFBlock block){ SWFOutput out = ((SWFOutputBlock)block)->output; SWFOutput_byteAlign(out); return SWFOutput_getLength(out);}voiddestroySWFOutputBlock(SWFOutputBlock outputBlock){ if ( outputBlock->output != NULL ) destroySWFOutput(outputBlock->output); free(outputBlock);}SWFOutputBlocknewSWFOutputBlock(SWFOutput out, SWFBlocktype type){ SWFOutputBlock block = (SWFOutputBlock)malloc(sizeof(struct SWFOutputBlock_s)); SWFBlockInit((SWFBlock)block); BLOCK(block)->type = type; BLOCK(block)->writeBlock = writeSWFOutputBlockToStream; BLOCK(block)->complete = getSWFOutputBlockLength; BLOCK(block)->dtor = (destroySWFBlockMethod) destroySWFOutputBlock; block->output = out; return block;}/* placeObject2 block is in placeobject.c */SWFOutputBlocknewSWFPlaceObjectBlock(SWFCharacter character, int depth, SWFMatrix matrix, SWFCXform cXform){ SWFOutput out = newSizedSWFOutput(40); SWFOutput_writeUInt16(out, CHARACTERID(character)); SWFOutput_writeUInt16(out, depth); SWFOutput_writeMatrix(out, matrix); /* max length: 210 bits=27 bytes */ if ( cXform ) /* max length: 9 bytes */ SWFOutput_writeCXform(out, cXform, SWF_PLACEOBJECT); return newSWFOutputBlock(out, SWF_PLACEOBJECT);}SWFOutputBlocknewSWFSetBackgroundBlock(byte r, byte g, byte b){ SWFOutput out = newSizedSWFOutput(4); SWFOutput_writeUInt8(out, r); SWFOutput_writeUInt8(out, g); SWFOutput_writeUInt8(out, b); return newSWFOutputBlock(out, SWF_SETBACKGROUNDCOLOR);}SWFOutputBlocknewSWFRemoveObjectBlock(SWFCharacter character, int depth){ SWFOutput out = newSizedSWFOutput(5); SWFOutput_writeUInt16(out, CHARACTERID(character)); SWFOutput_writeUInt16(out, depth); return newSWFOutputBlock(out, SWF_REMOVEOBJECT);}SWFOutputBlocknewSWFRemoveObject2Block(int depth){ SWFOutput out = newSizedSWFOutput(3); SWFOutput_writeUInt16(out, depth); return newSWFOutputBlock(out, SWF_REMOVEOBJECT2);}SWFOutputBlocknewSWFFrameLabelBlock(const char *string){ SWFOutput out = newSizedSWFOutput(strlen(string)+1); SWFOutput_writeString(out, (byte*)string); return newSWFOutputBlock(out, SWF_FRAMELABEL);}SWFOutputBlocknewSWFNamedAnchorBlock(const char *string){ SWFOutput out = newSizedSWFOutput(strlen(string)+2); SWFOutput_writeString(out, (byte*)string); SWFOutput_writeUInt8(out, 1); return newSWFOutputBlock(out, SWF_FRAMELABEL);}SWFOutputBlocknewSWFExportBlock(SWFExports exports, int nExports){ int n, sum; SWFOutput out; for ( n = 0, sum = 2; n < nExports; ++n ) sum += 2 + strlen(exports[n].name) + 1; out = newSizedSWFOutput(sum); SWFOutput_writeUInt16(out, nExports); for ( n = 0; n < nExports; ++n ) { SWFOutput_writeUInt16(out, CHARACTERID(exports[n].block)); SWFOutput_writeString(out, (byte*)exports[n].name); } return newSWFOutputBlock(out, SWF_EXPORTASSETS);}/* * Local variables: * tab-width: 2 * c-basic-offset: 2 * End: */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -