added HAVE_FREETYPE_FREETYPE_H
[swftools.git] / lib / modules / swfdump.c
1 /* swfdump.c
2
3    Dump / debug functions
4    
5    Extension module for the rfxswf library.
6    Part of the swftools package.
7
8    Copyright (c) 2001 Rainer Böhme <rfxswf@reflex-studio.de>
9  
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 2 of the License, or
13    (at your option) any later version.
14
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
23
24 void swf_DumpHeader(FILE * f,SWF * swf)
25 { if (!f) f = stderr;
26   fprintf(f,"File size\t%u\n",swf->fileSize);
27   fprintf(f,"Movie width\t%u\n",(swf->movieSize.xmax - swf->movieSize.xmin)/20);
28   fprintf(f,"Movie height\t%u\n",(swf->movieSize.ymax - swf->movieSize.ymin)/20);
29   fprintf(f,"Frame rate\t%u.%u\n",swf->frameRate>>8,swf->frameRate&0xff);
30   fprintf(f,"Frame count\t%u\n",swf->frameCount);
31 }
32
33 void swf_DumpMatrix(FILE * f,MATRIX * m)
34 { if (!f) f = stderr;
35   /*fprintf(f,"[%08x][%08x]\n",m->sx,m->r1);
36   fprintf(f,"[%08x][%08x]\n",m->r0,m->sy);
37   fprintf(f," %08x, %08x\n",m->tx,m->ty);*/
38   fprintf(f,"[%08x][%08x] %5.2f %5.2f %5.2f\n",m->sx,m->r1, m->sx/65536.0,m->r1/65536.0, m->tx/20.0);
39   fprintf(f,"[%08x][%08x] %5.2f %5.2f %5.2f\n",m->r0,m->sy, m->r0/65536.0,m->sy/65536.0, m->ty/20.0 );
40   fprintf(f," %08x, %08x \n",m->tx,m->ty);
41 }
42
43 void swf_DumpTag(FILE * f,TAG * t)
44 { int i;
45   if (!f) f = stderr;
46   for (i=0;i<t->len;i++)
47   { if (!(i&15)) fprintf(f,"\n");
48     fprintf(f,"%02x ",t->data[i]);
49   }
50   fprintf(f,"\n");
51 }
52
53 void swf_DumpSWF(FILE * f, SWF*swf)
54 {
55     TAG* tag = swf->firstTag;
56     fprintf(f, "vvvvvvvvvvvvvvvvvvvvv\n");
57     while(tag) {
58         printf("%8d %s\n", tag->len, swf_TagGetName(tag));
59         tag = tag->next;
60     }
61     fprintf(f, "^^^^^^^^^^^^^^^^^^^^^\n");
62 }
63
64 void swf_DumpFont(SWFFONT * font)
65 {
66     printf("ID: %d\n", font->id);
67     printf("Version: %d\n", font->version);
68     printf("name: %s\n", font->name);
69     printf("characters: %d\n", font->numchars);
70     printf("biggest mapped ascii value: %d\n", font->maxascii);
71     printf("layout: %s\n", font->layout?"yes":"no");
72     if(font->layout)
73     {
74         printf(" ascent:%d\n", font->layout->ascent);
75         printf(" descent:%d\n", font->layout->descent);
76         printf(" leading:%d\n", font->layout->leading);
77         printf(" bounds: (not shown)\n");
78         printf(" kerning records:%d\n", font->layout->kerningcount);
79         printf(" kerning records: (not shown)\n");
80     }
81     printf("style: %d\n", font->style);
82     printf("encoding: %d\n", font->encoding);
83     printf("language: %d\n", font->language);
84 }
85
86 void swf_DumpShape(SHAPE2*shape2)
87 {
88     SHAPELINE*l = shape2->lines;
89     while(l) {
90         if(l->type == moveTo) {
91             //printf("fill %d/%d line %d\n", l->fillstyle0, l->fillstyle1, l->linestyle);
92             printf("moveTo %.2f,%.2f (fill0:%d fill1:%d line:%d)\n", l->x/20.0, l->y/20.0, l->fillstyle0, l->fillstyle1, l->linestyle);
93         }
94         if(l->type == lineTo) {
95             //printf("fill %d/%d line %d\n", l->fillstyle0,  l->fillstyle1, l->linestyle);
96             printf("lineTo %.2f,%.2f (fill0:%d fill1:%d line:%d)\n", l->x/20.0, l->y/20.0, l->fillstyle0, l->fillstyle1, l->linestyle);
97         }
98         if(l->type == splineTo) {
99             //printf("fill %d/%d line %d\n", l->fillstyle0, l->fillstyle1, l->linestyle);
100             printf("splineTo %.2f,%.2f %.2f,%.2f (fill0:%d fill1:%d line:%d)\n", l->sx/20.0, l->sy/20.0, l->x/20.0, l->y/20.0, l->fillstyle0, l->fillstyle1, l->linestyle);
101         }
102         l = l->next;
103     }
104 }
105
106 char* swf_TagGetName(TAG*tag)
107 {
108     switch(tag->id)
109     {
110         case ST_END:
111             return "END";
112         case ST_SHOWFRAME:
113             return "SHOWFRAME";
114         case ST_DEFINESHAPE:
115             return "DEFINESHAPE";
116         case ST_FREECHARACTER:
117             return "FREECHARACTER";
118         case ST_PLACEOBJECT:
119             return "PLACEOBJECT";
120         case ST_REMOVEOBJECT:
121             return "REMOVEOBJECT";
122         case ST_DEFINEBITS:
123             return "DEFINEBITS";
124         case ST_DEFINEBUTTON:
125             return "DEFINEBUTTON";
126         case ST_JPEGTABLES:
127             return "JPEGTABLES";
128         case ST_SETBACKGROUNDCOLOR:
129             return "SETBACKGROUNDCOLOR";
130         case ST_DEFINEFONT:
131             return "DEFINEFONT";
132         case ST_DEFINETEXT:
133             return "DEFINETEXT";
134         case ST_DEFINEEDITTEXT:
135             return "DEFINEEDITTEXT";
136         case ST_DOACTION:
137             return "DOACTION";
138         case ST_DEFINEFONTINFO:
139             return "DEFINEFONTINFO";
140         case ST_DEFINESOUND:
141             return "DEFINESOUND";
142         case ST_STARTSOUND:
143             return "STARTSOUND";
144         case ST_DEFINEBUTTONSOUND:
145             return "DEFINEBUTTONSOUND";
146         case ST_SOUNDSTREAMHEAD:
147             return "SOUNDSTREAMHEAD";
148         case ST_SOUNDSTREAMBLOCK:
149             return "SOUNDSTREAMBLOCK";
150         case ST_DEFINEBITSLOSSLESS:
151             return "DEFINEBITSLOSSLESS";
152         case ST_DEFINEBITSJPEG2:
153             return "DEFINEBITSJPEG2";
154         case ST_DEFINESHAPE2:
155             return "DEFINESHAPE2";
156         case ST_DEFINEBUTTONCXFORM:
157             return "DEFINEBUTTONCXFORM";
158         case ST_PROTECT:
159             return "PROTECT";
160         case ST_PLACEOBJECT2:
161             return "PLACEOBJECT2";
162         case ST_REMOVEOBJECT2:
163             return "REMOVEOBJECT2";
164         case ST_DEFINESHAPE3:
165             return "DEFINESHAPE3";
166         case ST_DEFINETEXT2:
167             return "DEFINETEXT2";
168         case ST_DEFINEBUTTON2:
169             return "DEFINEBUTTON2";
170         case ST_DEFINEBITSJPEG3:
171             return "DEFINEBITSJPEG3";
172         case ST_DEFINEBITSLOSSLESS2:
173             return "DEFINEBITSLOSSLESS2";
174         case ST_DEFINESPRITE:
175             return "DEFINESPRITE";
176         case ST_NAMECHARACTER:
177             return "NAMECHARACTER";
178         case ST_SERIALNUMBER:
179             return "SERIALNUMBER";
180         case ST_GENERATORTEXT:
181             return "GENERATORTEXT";
182         case ST_FRAMELABEL:
183             return "FRAMELABEL";
184         case ST_SOUNDSTREAMHEAD2:
185             return "SOUNDSTREAMHEAD2";
186         case ST_DEFINEMORPHSHAPE:
187             return "DEFINEMORPHSHAPE";
188         case ST_DEFINEFONT2:
189             return "DEFINEFONT2";
190         case ST_TEMPLATECOMMAND:
191             return "TEMPLATECOMMAND";
192         case ST_GENERATOR3:
193             return "GENERATOR3";
194         case ST_EXTERNALFONT:
195             return "EXTERNALFONT";
196         case ST_EXPORTASSETS:
197             return "EXPORTASSETS";
198         case ST_IMPORTASSETS:
199             return "IMPORTASSETS";
200         case ST_ENABLEDEBUGGER:
201             return "ENABLEDEBUGGER";
202         case ST_DOINITACTION:
203             return "DOINITACTION";
204         case ST_DEFINEMOVIE:
205             return "DEFINEMOVIE";
206         case ST_DEFINEVIDEOSTREAM:
207             return "DEFINEVIDEOSTREAM";
208         case ST_VIDEOFRAME:
209             return "VIDEOFRAME";
210         case ST_DEFINEFONTINFO2:
211             return "DEFINEFONTINFO2";
212         case ST_FREEALL:
213             return "FREEALL";
214         case ST_MX4:
215             return "MX4";
216         case ST_SCRIPTLIMITS:
217             return "SCRIPTLIMITS";
218         case ST_SETTABINDEX:
219             return "SETTABINDEX";
220         
221         case ST_REFLEX:
222             return "REFLEX";
223         case ST_GLYPHNAMES:
224             return "GLYPHNAMES";
225     }
226     return 0;
227 }