📄 fromswf.c
字号:
tagnam = "stagDefineBitsLossless"; break; case SWF_DEFINEBITSJPEG2: tagnam = "stagDefineBitsJPEG2"; break; case SWF_DEFINESHAPE2: tagnam = "stagDefineShape2"; break; case SWF_DEFINEBUTTONCXFORM: tagnam = "stagDefineButtonCxform"; break; case SWF_PROTECT: tagnam = "stagProtect"; break; case SWF_PLACEOBJECT2: tagnam = "stagPlaceObject2"; break; case SWF_PLACEOBJECT3: tagnam = "stagPlaceObject3"; break; case SWF_REMOVEOBJECT2: tagnam = "stagRemoveObject2"; break; case SWF_DEFINESHAPE3: tagnam = "stagDefineShape3"; break; case SWF_DEFINESHAPE4: tagnam = "stagDefineShape4"; break; case SWF_DEFINETEXT2: tagnam = "stagDefineText2"; break; case SWF_DEFINEBUTTON2: tagnam = "stagDefineButton2"; break; case SWF_DEFINEBITSJPEG3: tagnam = "stagDefineBitsJPEG3"; break; case SWF_DEFINELOSSLESS2: tagnam = "stagDefineBitsLossless2"; break; case SWF_DEFINEEDITTEXT: tagnam = "stagDefineTextField"; break; case SWF_DEFINESPRITE: tagnam = "stagDefineSprite"; break; case SWF_NAMECHARACTER: tagnam = "stagNameCharacter"; break; case SWF_FRAMELABEL: tagnam = "stagFrameLabel"; break; case SWF_SOUNDSTREAMHEAD2: tagnam = "stagSoundStreamHead2"; break; case SWF_DEFINEMORPHSHAPE: tagnam = "stagDefineMorphShape"; break; case SWF_DEFINEMORPHSHAPE2: tagnam = "stagDefineMorphShape2"; break; case SWF_DEFINEFONT2: tagnam = "stagDefineFont2"; break; case SWF_DEFINEFONT3: tagnam = "stagDefineFont3"; break; case SWF_DEFINEFONTALIGNZONES: tagnam = "stagDefineFontAlignZones"; break; case SWF_EXPORTASSETS: tagnam = "stagExportAssets"; break; /*case stagClipInit: tagnam = "stagClipInit"; break;*/ /*case stagNewFontInfo: tagnam = "stagNewFontInfo"; break;*/ case SWF_DEFINEVIDEOSTREAM: tagnam = "stagDefineVideoStrem"; break; case SWF_VIDEOFRAME: tagnam = "stagVideoFrame"; break; case SWF_INITACTION: tagnam = "stagInitAction"; break; } printf("tag %d %s\n", tp->type, tagnam); } switch(tp->type) { /* tags without an id */ case SWF_END: case SWF_SHOWFRAME: case SWF_SETBACKGROUNDCOLOR: case SWF_DOACTION: case SWF_PROTECT: case SWF_REMOVEOBJECT2: case SWF_FRAMELABEL: case SWF_SOUNDSTREAMHEAD: case SWF_SOUNDSTREAMHEAD2: case SWF_SOUNDSTREAMBLOCK: case SWF_JPEGTABLES: case SWF_SYMBOLCLASS: case SWF_DOABC: case SWF_DEFINEFONTNAME: /*case stagClipInit:*/ break; /* simple tags - one id at beginning */ case SWF_FREECHARACTER: case SWF_PLACEOBJECT: case SWF_REMOVEOBJECT: case SWF_DEFINEBITS: case SWF_DEFINEBITSJPEG2: case SWF_DEFINEBITSJPEG3: case SWF_DEFINELOSSLESS: case SWF_DEFINELOSSLESS2: case SWF_DEFINEFONT: case SWF_DEFINEFONTINFO: case SWF_DEFINESOUND: case SWF_STARTSOUND: case SWF_NAMECHARACTER: case SWF_DEFINEFONT2: case SWF_DEFINEFONT3: case SWF_DEFINEFONTALIGNZONES: case SWF_DEFINEBUTTONCXFORM: case SWF_DEFINEVIDEOSTREAM: case SWF_VIDEOFRAME: case SWF_INITACTION: case SWF_DEFINEBINARYDATA: /*case SWF_NEWFONTINFO:*/ id = change_id(tp); if(verbose) printf("id %d offset %d\n", id, idoffset); break; /* to be processed specially */ case SWF_DEFINESHAPE: defineshape(tp, 1); break; case SWF_DEFINETEXT: definetext(tp, 1); break; case SWF_DEFINESHAPE2: defineshape(tp, 2); break; case SWF_PLACEOBJECT2: placeobject(tp, 2); break; case SWF_PLACEOBJECT3: placeobject(tp, 3); break; case SWF_DEFINESHAPE3: defineshape(tp, 3); break; case SWF_DEFINESHAPE4: defineshape(tp, 4); break; case SWF_DEFINETEXT2: definetext(tp, 2); break; case SWF_DEFINEBUTTON: definebutton(tp); break; case SWF_DEFINEBUTTON2: definebutton2(tp); break; case SWF_DEFINEEDITTEXT: definetextfield(tp); break; case SWF_DEFINESPRITE: definesprite(tp); break; case SWF_DEFINEMORPHSHAPE: definemorphshape(tp, 1); break; case SWF_DEFINEMORPHSHAPE2: definemorphshape(tp, 2); break; case SWF_EXPORTASSETS: exportassets(tp); break; case SWF_DEFINEBUTTONSOUND: definebuttonsound(tp); break; default: SWF_error("unknown tag %d\n", tp->type); } switch(tp->type) { case SWF_END: case SWF_SHOWFRAME: case SWF_DOACTION: case SWF_REMOVEOBJECT2: case SWF_FRAMELABEL: case SWF_SOUNDSTREAMHEAD: case SWF_SOUNDSTREAMHEAD2: case SWF_SOUNDSTREAMBLOCK: case SWF_DEFINEVIDEOSTREAM: case SWF_VIDEOFRAME: case SWF_INITACTION: case SWF_FREECHARACTER: case SWF_PLACEOBJECT: case SWF_REMOVEOBJECT: case SWF_STARTSOUND: case SWF_NAMECHARACTER: case SWF_PLACEOBJECT2: case SWF_PLACEOBJECT3: displaylist = 1; } return displaylist;}static void definesprite(TAG sp){ TAG tp; int type; int id, frames; id = change_id(sp); frames = readint2((BITS) sp); if(verbose) printf("sprite %d, %d frames\n", id, frames); do { tp = readtag_sprite(sp); handle_tag(tp); type = tp->type; free(tp); } while(type); if(sp->datptr != sp->datend) SWF_error("consistency check: file size wrong in sprite\n");}/* shape */static void shaperecord(TAG tp, int nfillbits, int nlinebits, int lev){ int type, statenewstyles, statelinestyle, statefillstyle1, statefillstyle0; int statemoveto, movebits, movex, movey, fill0style, fill1style, linestyle; int edgeflag, nbits, genlineflag, dx, dy, vertlineflag; int cdx, cdy, adx, ady; while(1) { type = getbits((BITS) tp, 1); if(!type) { statenewstyles = getbits((BITS) tp, 1); statelinestyle = getbits((BITS) tp, 1); statefillstyle1 = getbits((BITS) tp, 1); statefillstyle0 = getbits((BITS) tp, 1); if((statemoveto = getbits((BITS) tp, 1))) { movebits = getbits((BITS) tp, 5); movex = getsbits((BITS) tp, movebits); movey = getsbits((BITS) tp, movebits); if(verbose) printf("move %d %d\n", movex, movey); } if(statenewstyles == 0 && statelinestyle == 0 && statefillstyle1 == 0&& statefillstyle0 == 0 && statemoveto == 0) break; if(statefillstyle0) { fill0style = getbits((BITS) tp, nfillbits); if(verbose) printf("fillstyle0 %d\n", fill0style); } if(statefillstyle1) { fill1style = getbits((BITS) tp, nfillbits); if(verbose) printf("fillstyle1 %d\n", fill1style); } if(statelinestyle) { linestyle = getbits((BITS) tp, nlinebits); if(verbose) printf("linestyle %d\n", linestyle); }/* contrary to document, but ... seems to work AND make sense */ if(statefillstyle0 || statefillstyle1 || statelinestyle) ; else if(statenewstyles) fillandlinestyles(tp, lev); } else { edgeflag = getbits((BITS) tp, 1); if(!edgeflag) /* curve */ { nbits = getbits((BITS) tp, 4)+2; cdx = getsbits((BITS) tp, nbits); cdy = getsbits((BITS) tp, nbits); adx = getsbits((BITS) tp, nbits); ady = getsbits((BITS) tp, nbits); if(verbose) printf("curve %d,%d %d,%d\n", cdx, cdy, adx, ady); } else { nbits = getbits((BITS) tp, 4)+2; if((genlineflag = getbits((BITS) tp, 1))) { dx = getsbits((BITS) tp, nbits); dy = getsbits((BITS) tp, nbits); } else if((vertlineflag = getbits((BITS) tp, 1))) { dx = 0; dy = getsbits((BITS) tp, nbits); } else { dx = getsbits((BITS) tp, nbits); dy = 0; } if(verbose) printf("line %d,%d\n", dx, dy); } } }}static void gradient(TAG tp, int alpha, int cod){ int n, ngrad, r1; alignbits(tp); ngrad = tp->readc(tp); for(n = 0 ; n < ngrad ; n++) { r1 = tp->readc(tp); if(verbose) printf("ratio %d\n", r1); if(alpha) rgba((BITS) tp); else rgb((BITS) tp); } if (cod == 0x13) readint2((BITS) tp);}static void fillstyle(TAG tp, int lev){ unsigned short id; char cod; alignbits(tp); cod = tp->readc(tp); switch(cod) { case 0: if(verbose) printf("solid fill:\n"); break; case 0x10: if(verbose) printf("linear gradient fill\n"); break; case 0x12: if(verbose) printf("radial gradient fill:\n"); break; case 0x13: if(verbose) printf("focal gradient fill:\n"); break; case 0x40: if(verbose) printf("tiled bitmap fill:\n"); break; case 0x41: if(verbose) printf("clipped bitmap fill\n"); break; case 0x42: if(verbose) printf("tilled bitmap fill with hard edges\n"); break; case 0x43: if(verbose) printf("clipped bitmap fill with hard edges\n"); break; } if(cod == 0) if(lev >= 3) rgba((BITS) tp); else rgb((BITS) tp); else if(cod == 0x10 || cod == 0x12 || cod == 0x13) { matrix((BITS) tp); gradient(tp, lev >= 3, cod); } else if(cod == 0x40 || cod == 0x41 || cod == 0x42 || cod == 0x43) { id = change_id(tp); if(verbose) printf("fill with id %d\n", id); matrix((BITS) tp); } else printf("%s:%d: UNEXPEDCED %x\n", __FILE__, __LINE__, cod);}static void morphgradient(TAG tp){ int n, ngrad, r1, r2; alignbits(tp); ngrad = tp->readc(tp); for(n = 0 ; n < ngrad ; n++) { r1 = tp->readc(tp); if(verbose) printf("ratio %d\n", r1); rgba((BITS) tp); r2 = tp->readc(tp); if(verbose) printf("ratio %d\n", r2); rgba((BITS) tp); }}static void morphfillstyle(TAG tp){ unsigned short id; char cod; alignbits(tp); cod = tp->readc(tp); switch(cod) { case 0: if(verbose) printf("solid fill:\n"); break; case 0x10: if(verbose) printf("linear gradient fill\n"); break; case 0x12: if(verbose) printf("radial gradient fill:\n"); break; case 0x13: if(verbose) printf("focal gradient fill:\n"); break; case 0x40: if(verbose) printf("tiled bitmap fill:\n"); break; case 0x41: if(verbose) printf("clipped bitmap fill\n"); break; case 0x42: if(verbose) printf("tilled bitmap fill with hard edges\n"); break; case 0x43: if(verbose) printf("clipped bitmap fill with hard edges\n"); break; } if(cod == 0) { rgba((BITS) tp); rgba((BITS) tp); } else if(cod == 0x10 || cod == 0x12 || cod == 0x13) { matrix((BITS) tp); alignbits(tp); matrix((BITS) tp); morphgradient(tp); } else if(cod == 0x40 || cod == 0x41 || cod == 0x42 || cod == 0x43) { id = change_id(tp); if(verbose) printf("fill with id %d\n", id); matrix((BITS) tp); alignbits(tp); matrix((BITS) tp); } else printf("%s:%d: UNEXPEDCED %x\n", __FILE__, __LINE__, cod);}static void fillandlinestyles(TAG tp, int lev){ int n, nfill, nline; alignbits(tp); nfill = tp->readc(tp); if(nfill == 0xff) nfill = readint2((BITS) tp); if(verbose) printf ("%d fill styles\n", nfill); for(n = 0 ; n < nfill ; n++) fillstyle(tp, lev); alignbits(tp); nline = tp->readc(tp); if(nline == 0xff) nline = readint2((BITS) tp); if(verbose) printf ("%d line styles\n", nline); for(n = 0 ; n < nline ; n++) if (lev == 4) morphlinestyle2(tp); else linestyle(tp, lev);}static void linestyle(TAG tp, int lev){ unsigned short w; w = readint2((BITS) tp); if(verbose) printf ("w %d\n", w); if(lev >= 3) rgba((BITS) tp); else rgb((BITS) tp);}static void morphlinestyle(TAG tp){ unsigned short w1, w2; w1 = readint2((BITS) tp); w2 = readint2((BITS) tp); if(verbose) printf("w %d => %d\n", w1, w2); rgba((BITS) tp); rgba((BITS) tp);}static void morphlinestyle2(TAG tp){ unsigned short w1; int join_style; int has_fill; int is_morph = (tp->type == SWF_DEFINEMORPHSHAPE2); w1 = readint2((BITS) tp); if (is_morph) { unsigned short w2; w2 = readint2((BITS) tp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -