solaris fixes.
[swftools.git] / src / flash.h
1 /* flash.h
2    Header file for flash.c
3
4    Part of the swftools package.
5
6    Copyright (c) 2001 Matthias Kramm <kramm@quiss.org> 
7
8    This file is distributed under the GPL, see file COPYING for details */
9
10 #ifndef __flash_h__
11 #define __flash_h__
12
13 #include "types.h"
14 #include "../lib/rfxswf.h"
15
16 #define TAGID_END 0
17 #define TAGID_SHOWFRAME 1
18 #define TAGID_DEFINESHAPE 2
19 #define TAGID_PLACEOBJECT 4
20 #define TAGID_REMOVEOBJECT 5
21 #define TAGID_DEFINEBITS 6
22 #define TAGID_DEFINEBUTTON 7
23 #define TAGID_JPEGTABLES 8
24 #define TAGID_BACKGROUNDCOLOR 9
25 #define TAGID_DEFINEFONT 10
26 #define TAGID_DEFINETEXT 11
27 #define TAGID_DOACTION 12
28 #define TAGID_DEFINEFONTINFO 13
29 #define TAGID_DEFINESOUND 14
30 #define TAGID_STARTSOUND 15
31 #define TAGID_DEFINEBUTTONSOUND 17
32 #define TAGID_SOUNDSTREAMHEAD 18
33 #define TAGID_SOUNDSTREAMHEAD2 18
34 #define TAGID_SOUNDSTREAMBLOCK 19
35 #define TAGID_DEFINEBITSLOSSLESS 20
36 #define TAGID_DEFINEBITSJPEG2 21
37 #define TAGID_DEFINESHAPE2 22
38 #define TAGID_DEFINEBUTTONCXFORM 23
39 #define TAGID_PROTECT 24
40 #define TAGID_PLACEOBJECT2 26
41 #define TAGID_REMOVEOBJECT2 28
42 #define TAGID_DEFINESHAPE3 32
43 #define TAGID_DEFINETEXT2 33
44 #define TAGID_DEFINEBUTTON2 34
45 #define TAGID_DEFINEBITSJPEG3 35
46 #define TAGID_DEFINEBITSLOSSLESS2 36
47 #define TAGID_DEFINEEDITTEXT 37
48 #define TAGID_DEFINEMOVIE 38
49 #define TAGID_DEFINESPRITE 39
50 #define TAGID_FRAMELABEL 43
51 #define TAGID_DEFINEMORPHSHAPE 46
52 #define TAGID_DEFINEFONT2 48
53 #define TAGID_EXPORTASSETS   56
54 #define TAGID_IMPORTASSETS   57
55 #define TAGID_ENABLEDEBUGGER 58
56
57 #include "bitio.h"
58
59 struct swf_tag;
60 struct RECT;
61 struct RGB;
62 struct MATRIX;
63 struct CXFORM;
64 struct CLIPACTIONS;
65
66 struct swf_tag
67 {
68     u16 id;
69     u32 length;
70     u8*data;
71     u32 fulllength; // includes id
72     u8*fulldata; // likewise
73 };
74
75 struct RGB
76 {
77     byte r,g,b;
78 };
79
80 struct RGBA
81 {
82     byte r,g,b,a;
83 };
84
85 struct RECT
86 {
87     int x1, y1, x2, y2;
88 };
89
90 struct MATRIX 
91 {
92     u8 hasscale;
93     u8 hasrotate;
94     float a[2][2];
95     int b[2];
96 };
97
98 struct CXFORM 
99 {
100     u8 hasadd;
101     u8 hasmult;
102     float rmult, gmult, bmult, amult;
103     float radd, gadd, badd, aadd;
104     u8 alpha;
105 };
106
107 struct GRADIENT
108 {
109     int num;
110     u8 ratios[8];
111     struct RGB rgb[8];
112     struct RGBA rgba[8];
113 };
114
115 struct RECT readRECT();
116 struct RGB readRGB();
117 struct MATRIX readMATRIX();
118 unsigned char* readSTRING();
119 struct CLIPACTIONS readCLIPACTIONS();
120
121 void writeRECT(u8**pos, struct RECT*r);
122
123 void swf_init(struct reader_t*,uchar*newdata, int newlength);
124 struct flash_header
125 {
126     int version;
127     u32 length;
128     struct RECT boundingBox;
129     u16 rate;
130     u16 count;
131
132     u8*headerdata;
133     int headerlength;
134 };
135
136 struct swffile
137 {
138     struct flash_header header;
139     int tagnum;
140     struct swf_tag* tags;
141 };
142
143 struct flash_header swf_read_header(struct reader_t*);
144 struct RGB readRGB(struct reader_t*);
145 struct RGBA readRGBA(struct reader_t*);
146 struct GRADIENT readGRADIENT(struct reader_t*,int shape);
147 struct RECT readRECT(struct reader_t*);
148 struct CXFORM readCXFORM(struct reader_t*,char alpha);
149 struct MATRIX readMATRIX(struct reader_t*);
150 unsigned char* readSTRING(struct reader_t*);
151 int swf_read_tag(struct reader_t*,struct swf_tag* swftag);
152 int swf_count_tags(struct reader_t*);
153
154
155 struct PlaceObject
156 {
157     u16 id;
158     u16 depth;
159     struct MATRIX matrix;
160     struct CXFORM cxform;
161     u8 hascxform;
162 };
163
164 struct PlaceObject2
165 {
166     u8 reserved;
167     u8 hasclipactions;
168     u8 hasname;
169     u8 hasratio;
170     u8 hascolortransform;
171     u8 hasmatrix;
172     u8 hascharacter;
173     u8 hasmove;
174
175     u16 depth;
176     int id;
177     struct MATRIX matrix;
178     struct CXFORM cxform;
179     u16 ratio;
180     char * name;
181     u16 clipactions;
182 };
183
184
185 void placeobject_init (struct PlaceObject*obj, struct swf_tag*tag);
186 void placeobject_write (struct PlaceObject*obj, struct writer_t*w);
187
188 void placeobject2_init (struct PlaceObject2*obj, struct swf_tag*tag);
189
190 void read_swf(struct swffile*swf, uchar*data, int length);
191
192 int getidfromtag(struct swf_tag* tag);
193 void setidintag(struct swf_tag* tag, int id);
194 char is_sprite_tag (int id);
195 char is_defining_tag (int id);
196 struct swf_tag* duptag(struct swf_tag*tag);
197
198 #endif //__flash_h__