static void writeSWFTextToMethod(SWFBlock block, SWFByteOutputMethod method, void *data) { SWFText text = (SWFText)block; int length = 0; SWFOutput out; if ( text->matrix == NULL ) text->matrix = newSWFMatrix(1.0, 0, 0, 1.0, 0, 0); length += (SWFMatrix_numBits(text->matrix)+7)/8; length += (SWFRect_numBits(CHARACTER(text)->bounds)+7)/8; length += 4; out = newSizedSWFOutput(length); SWFOutput_writeUInt16(out, CHARACTERID(text)); SWFOutput_writeRect(out, CHARACTER(text)->bounds); SWFOutput_writeMatrix(out, text->matrix); SWFOutput_writeUInt8(out, text->nGlyphBits); SWFOutput_writeUInt8(out, text->nAdvanceBits); SWFOutput_writeToMethod(out, method, data); SWFOutput_writeToMethod(text->out, method, data); destroySWFOutput(out); }
int completeSWFPlaceObject2Block(SWFBlock block) { SWFPlaceObject2Block place = (SWFPlaceObject2Block)block; SWFOutput out = newSizedSWFOutput(42); 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); if(place->version == 3) { flags = 0; if(place->hasCacheFlag) flags |= SWF_PLACE_CACHE; if(place->hasBlendFlag) flags |= SWF_PLACE_HAS_BLEND; if(place->hasFilterFlag) flags |= SWF_PLACE_HAS_FILTER; 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->name != NULL ) SWFOutput_writeString(out, (byte*)place->name); if ( place->masklevel != -1 ) SWFOutput_writeUInt16(out, place->masklevel); if( place->version == 3 && place->hasFilterFlag) SWFOutput_writeFilterList(out, place->filterList); if( place->version == 3 && place->hasBlendFlag) SWFOutput_writeUInt8(out, place->blendMode); place->out = out; writeActions(place); return SWFOutput_getLength(out); }
int completeSWFButton(SWFBlock block) { SWFButton button = (SWFButton)block; SWFButtonRecord record; SWFOutput out = newSWFOutput(); int i, length = 0, layer; byte *offset; SWFOutput_writeUInt16(out, CHARACTERID(button)); SWFOutput_writeUInt8(out, button->menuflag); /* fill in offset later */ offset = SWFOutput_getCurPos(out); SWFOutput_writeUInt16(out, 0); for(i=0; i<button->nRecords; ++i) { record = button->records[i]; SWFOutput_writeUInt8(out, record->flags); SWFOutput_writeUInt16(out, CHARACTERID(record->character)); layer = record->layer; if(layer == 0 && block->swfVersion >= 5) layer = i+1; SWFOutput_writeUInt16(out, layer); SWFOutput_writeMatrix(out, SWFPosition_getMatrix(record->position)); SWFOutput_writeUInt8(out, 0); /* blank CXForm */ if(record->flags & RECORD_HASFILTER) SWFOutput_writeFilterList(out, record->filterList); if(record->flags & RECORD_HASBLEND) SWFOutput_writeUInt8(out, record->blendMode); } SWFOutput_writeUInt8(out, 0); /* end buttons */ length = SWFOutput_getLength(out) - 3; if(button->nActions > 0) { *offset = length&0xff; *(offset+1) = (length>>8)&0xff; }