SWFText newSWFText() { SWFText text = (SWFText)malloc(sizeof(struct SWFText_s)); SWFCharacterInit((SWFCharacter)text); CHARACTERID(text) = ++SWF_gNumCharacters; BLOCK(text)->type = SWF_DEFINETEXT; BLOCK(text)->writeBlock = writeSWFTextToMethod; BLOCK(text)->complete = completeSWFText; BLOCK(text)->dtor = (destroySWFBlockMethod) destroySWFText; CHARACTER(text)->bounds = newSWFRect(0,0,0,0); text->out = newSWFOutput(); text->currentRecord = NULL; text->initialRecord = NULL; text->matrix = NULL; text->nAdvanceBits = 0; #if TRACK_ALLOCS text->gcnode = ming_gc_add_node(text, (dtorfunctype) destroySWFBitmap); #endif return text; }
static void finishBrowserFont(SWFBrowserFont font) { unsigned int i; SWFOutput out; SWF_assert(BLOCK(font)->swfVersion); out = newSWFOutput(); font->out = out; SWFOutput_writeUInt16(out, CHARACTERID(font)); if(BLOCK(font)->swfVersion > 5) /* maybe italic or bold flag? */ SWFOutput_writeUInt8(out, SWF_FONT_WIDECODES); else SWFOutput_writeUInt8(out, 0); SWFOutput_writeUInt8(out, 0); /* reserved flags */ SWFOutput_writeUInt8(out, strlen(font->name)); for ( i=0; i<strlen(font->name); ++i ) SWFOutput_writeUInt8(out, font->name[i]); SWFOutput_writeUInt16(out, 0); /* number of glyphs */ SWFOutput_writeSInt16(out, 2); /* offset */ SWFOutput_byteAlign(out); }
SWFText newSWFText() { SWFRect temp_rect; SWFText text = (SWFText)malloc(sizeof(struct SWFText_s)); /* If malloc failed, return NULL to signify this */ if (NULL == text) return NULL; SWFCharacterInit((SWFCharacter)text); CHARACTERID(text) = ++SWF_gNumCharacters; BLOCK(text)->type = SWF_DEFINETEXT; BLOCK(text)->writeBlock = writeSWFTextToMethod; BLOCK(text)->complete = completeSWFText; BLOCK(text)->dtor = (destroySWFBlockMethod) destroySWFText; temp_rect = newSWFRect(0,0,0,0); /* If newSWFRect() failed, return NULL to signify this */ if (NULL == temp_rect) { free(text); return NULL; } CHARACTER(text)->bounds = temp_rect; text->out = newSWFOutput(); /* If newSWFOutput() failed, return NULL to signify this */ if (NULL == text->out) { destroySWFRect(temp_rect); free(text); return NULL; } text->currentRecord = NULL; text->initialRecord = NULL; text->matrix = NULL; text->nAdvanceBits = 0; #if TRACK_ALLOCS text->gcnode = ming_gc_add_node(text, (dtorfunctype) destroySWFText); #endif return text; }
SWFPrebuilt newSWFPrebuilt() { SWFPrebuilt data = (SWFPrebuilt)malloc(sizeof(struct SWFPrebuilt_s)); SWFBlockInit((SWFBlock)data); BLOCK(data)->type = SWF_PREBUILT; BLOCK(data)->writeBlock = writeSWFPrebuiltToMethod; BLOCK(data)->complete = completeSWFPrebuilt; BLOCK(data)->dtor = (destroySWFBlockMethod) destroySWFPrebuilt; data->defines = newSWFOutput(); return data; }
SWFOutput outputswfSWF_SHAPE (SWF_SHAPE * shape) { SWFOutput out; int i; out=newSWFOutput(); SWFOutput_writeBits(out,shape->NumFillBits,4); SWFOutput_writeBits(out,shape->NumLineBits,4); for (i = 0; i < shape->NumShapeRecords; i++) { outputswfSWF_SHAPERECORD (&(shape->ShapeRecords[i]), out,shape->NumFillBits,shape->NumLineBits); } SWFOutput_byteAlign(out); return out; }
SWFPrebuiltClip newSWFPrebuiltClip() { SWFPrebuiltClip clip = (SWFPrebuiltClip)malloc(sizeof(struct SWFPrebuiltClip_s)); SWFCharacterInit((SWFCharacter)clip); BLOCK(clip)->type = SWF_PREBUILTCLIP; BLOCK(clip)->writeBlock = writeSWFPrebuiltClipToMethod; BLOCK(clip)->complete = completeSWFPrebuiltClip; BLOCK(clip)->dtor = (destroySWFBlockMethod) destroySWFPrebuiltClip; clip->frames = 0; clip->display = newSWFOutput(); return clip; }
SWFShape newSWFShape() { SWFShape shape = (SWFShape)malloc(sizeof(struct SWFShape_s)); /* If malloc failed, return NULL to signify this */ if (NULL == shape) return NULL; SWFCharacterInit((SWFCharacter)shape); BLOCK(shape)->writeBlock = writeSWFShapeBlockToMethod; BLOCK(shape)->complete = completeSWFShapeBlock; BLOCK(shape)->dtor = (destroySWFBlockMethod) destroySWFShape; BLOCK(shape)->type = SWF_DEFINESHAPE3; CHARACTERID(shape) = ++SWF_gNumCharacters; shape->out = newSWFOutput(); CHARACTER(shape)->bounds = newSWFRect(0,0,0,0); shape->edgeBounds = newSWFRect(0,0,0,0); shape->records = NULL; shape->lines = NULL; shape->fills = NULL; shape->nRecords = 0; shape->xpos = 0; shape->ypos = 0; shape->nLines = 0; shape->nFills = 0; shape->lineWidth = 0; shape->isMorph = FALSE; shape->isEnded = FALSE; shape->flags = 0; shape->useVersion = SWF_SHAPE3; SWFOutput_writeUInt8(shape->out, 0); /* space for nFillBits, nLineBits */ #if TRACK_ALLOCS shape->gcnode = ming_gc_add_node(shape, (dtorfunctype) destroySWFShape); #endif return shape; }
SWFBlock newSWFProtect(const char *password) { SWFProtect protect = (SWFProtect)malloc(sizeof(struct SWFProtect_s)); SWFBlockInit(BLOCK(protect)); BLOCK(protect)->type = SWF_PROTECT; BLOCK(protect)->writeBlock = writeSWFProtectToMethod; BLOCK(protect)->complete = completeSWFProtect; BLOCK(protect)->dtor = (destroySWFBlockMethod) destroySWFProtect; protect->out = newSWFOutput(); if(password != NULL) protect->Password = strdup(password); else protect->Password = NULL; return (SWFBlock)protect; }
void SWFShape_addStyleHeader(SWFShape shape) { SWFOutput out = newSWFOutput(); SWFOutput_writeUInt16(out, CHARACTERID(shape)); SWFOutput_writeRect(out, SWFCharacter_getBounds(CHARACTER(shape))); if(shape->useVersion == SWF_SHAPE4) { SWFOutput_writeRect(out, shape->edgeBounds); SWFOutput_writeUInt8(out, shape->flags); } SWFOutput_writeFillStyles(out, shape->fills, shape->nFills, BLOCK(shape)->type, shape->edgeBounds); SWFOutput_writeLineStyles(out, shape->lines, shape->nLines, BLOCK(shape)->type); /* prepend shape->out w/ shape header */ SWFOutput_setNext(out, shape->out); shape->out = out; }
void SWFShape_addStyleHeader(SWFShape shape) { SWFOutput out = newSWFOutput(); SWFOutput_writeUInt16(out, CHARACTERID(shape)); SWFOutput_writeRect(out, SWFCharacter_getBounds(CHARACTER(shape))); if (shape->isUsingNewStyles) { shape->nFills2 = 0; shape->nLines2 = 0; } SWFOutput_writeFillStyles(out, shape->fills2, shape->nFills2, BLOCK(shape)->type); SWFOutput_writeLineStyles(out, shape->lines2, shape->nLines2, BLOCK(shape)->type); /* prepend shape->out w/ shape header */ SWFOutput_setNext(out, shape->out); shape->out = 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; }
static int completeSWFSceneData(SWFBlock block) { SWFSceneData sdata = (SWFSceneData)block; int i; sdata->out = newSWFOutput(); SWFOutput_writeEncUInt32(sdata->out, sdata->sceneCount); for(i = 0; i < sdata->sceneCount; i++) { SWFOutput_writeEncUInt32(sdata->out, sdata->sceneOffset[i]); SWFOutput_writeString(sdata->out, (unsigned char *)sdata->sceneName[i]); } SWFOutput_writeEncUInt32(sdata->out, sdata->frameLabelCount); for(i = 0; i < sdata->frameLabelCount; i++) { SWFOutput_writeEncUInt32(sdata->out, sdata->frameNumber[i]); SWFOutput_writeString(sdata->out, (unsigned char *)sdata->frameLabel[i]); } return SWFOutput_getLength(sdata->out); }
SWFOutput outputSWF_DEFINEFONT2 (SWF_Parserstruct * pblock) { SWFOutput hdr0,hdr1,offsettbl,*glyphdata; int i,size, glyphbase; OUT_BEGIN (SWF_DEFINEFONT2); glyphdata = calloc(sblock->NumGlyphs,sizeof(SWFOutput *)); size=0; for (i = 0; i < sblock->NumGlyphs; i++) { glyphdata[i] = outputswfSWF_SHAPE (&(sblock->GlyphShapeTable[i])); size+= SWFOutput_getLength(glyphdata[i]); } if( size > 0xffff ) sblock->FontFlagsWideOffsets=1; if (sblock->FontFlagsWideOffsets) { glyphbase=(sblock->NumGlyphs*4)+4; sblock->CodeTableOffset.UI32=glyphbase; sblock->OffsetTable.UI32[0]=glyphbase; } else { glyphbase=(sblock->NumGlyphs*2)+2; sblock->CodeTableOffset.UI16=glyphbase; sblock->OffsetTable.UI16[0]=glyphbase; } for (i = 0; i < sblock->NumGlyphs; i++) { if (sblock->FontFlagsWideOffsets) { sblock->OffsetTable.UI32[i]=sblock->CodeTableOffset.UI32; sblock->CodeTableOffset.UI32=sblock->OffsetTable.UI32[i]+SWFOutput_getLength(glyphdata[i]); } else { sblock->OffsetTable.UI16[i]=sblock->CodeTableOffset.UI16; sblock->CodeTableOffset.UI16=sblock->OffsetTable.UI16[i]+SWFOutput_getLength(glyphdata[i]); } } offsettbl=newSWFOutput(); for (i = 0; i < sblock->NumGlyphs; i++) { if (sblock->FontFlagsWideOffsets) { SWFOutput_writeUInt32(offsettbl,sblock->OffsetTable.UI32[i]); } else { SWFOutput_writeUInt16(offsettbl,sblock->OffsetTable.UI16[i]); } } /* Now that we have the glyph data, and it's offset, we can start assembling this block */ size= 5 /* Initial header through FontNameLen */ +(sblock->FontNameLen) /* FontName */ +2; /* NumGlyphs */ hdr1=newSizedSWFOutput(size); SWFOutput_writeUInt16(hdr1,sblock->FontID); SWFOutput_writeBits(hdr1,sblock->FontFlagsHasLayout,1); SWFOutput_writeBits(hdr1,sblock->FontFlagsShiftJis,1); SWFOutput_writeBits(hdr1,sblock->FontFlagsSmallText,1); SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagANSI,1); SWFOutput_writeBits(hdr1,sblock->FontFlagsWideOffsets,1); SWFOutput_writeBits(hdr1,sblock->FontFlagsWideCodes,1); SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagsItalics,1); SWFOutput_writeBits(hdr1,sblock->FontFlagsFlagsBold,1); SWFOutput_writeUInt8(hdr1,sblock->LanguageCode); SWFOutput_writeUInt8(hdr1,sblock->FontNameLen); SWFOutput_writeBuffer(hdr1,(unsigned char *)sblock->FontName,sblock->FontNameLen); SWFOutput_writeUInt16(hdr1,sblock->NumGlyphs); /* Now, copy these parts into the hdr buffer */ SWFOutput_writeToMethod(offsettbl,SWFOutputMethod,hdr1); destroySWFOutput(offsettbl); if (sblock->FontFlagsWideOffsets) { SWFOutput_writeUInt32(hdr1,sblock->CodeTableOffset.UI32); } else { SWFOutput_writeUInt16(hdr1,sblock->CodeTableOffset.UI16); } for (i = 0; i < sblock->NumGlyphs; i++) { SWFOutput_writeToMethod(glyphdata[i],SWFOutputMethod,hdr1); destroySWFOutput(glyphdata[i]); } free(glyphdata); /* Now, resume the normal linear processing this tag */ for (i = 0; i < sblock->NumGlyphs; i++) { if( sblock->FontFlagsWideCodes ) { SWFOutput_writeUInt16(hdr1,sblock->CodeTable[i]); } else { SWFOutput_writeUInt8(hdr1,sblock->CodeTable[i]); } } if( sblock->FontFlagsHasLayout ) { SWFOutput_writeSInt16(hdr1,sblock->FontAscent); SWFOutput_writeSInt16(hdr1,sblock->FontDecent); SWFOutput_writeSInt16(hdr1,sblock->FontLeading); for (i = 0; i < sblock->NumGlyphs; i++) { SWFOutput_writeSInt16(hdr1,sblock->FontAdvanceTable[i]); } for (i = 0; i < sblock->NumGlyphs; i++) { outputswfSWF_RECT (hdr1,&(sblock->FontBoundsTable[i])); SWFOutput_byteAlign(hdr1); } SWFOutput_writeUInt16(hdr1,sblock->KerningCount); for (i = 0; i < sblock->KerningCount; i++) { if( sblock->FontFlagsWideCodes ) { SWFOutput_writeUInt16(hdr1,sblock->FontKerningTable[i].FontKerningCode1); SWFOutput_writeUInt16(hdr1,sblock->FontKerningTable[i].FontKerningCode2); SWFOutput_writeSInt16(hdr1,sblock->FontKerningTable[i].FontKerningAdjustment); } else { SWFOutput_writeUInt8(hdr1,sblock->FontKerningTable[i].FontKerningCode1); SWFOutput_writeUInt8(hdr1,sblock->FontKerningTable[i].FontKerningCode2); SWFOutput_writeSInt16(hdr1,sblock->FontKerningTable[i].FontKerningAdjustment); } } } /* This code really belongs in outputTAGHeader() */ hdr0=newSizedSWFOutput(6); if(SWFOutput_getLength(hdr1) <= 62 ) { fprintf(stderr,"TAG %x\n",(SWF_DEFINEFONT2<<6)|SWFOutput_getLength(hdr1)); SWFOutput_writeUInt16(hdr0,(SWF_DEFINEFONT2<<6)|SWFOutput_getLength(hdr1)); } else { SWFOutput_writeUInt16(hdr0,(SWF_DEFINEFONT2<<6)|0x3f); SWFOutput_writeUInt32(hdr0,SWFOutput_getLength(hdr1)); } SWFOutput_writeToMethod(hdr1,SWFOutputMethod,hdr0); destroySWFOutput(hdr1); return hdr0; }
void outputHeader (struct Movie *m) { swfout=newSWFOutput(); }