added moveobject, showframe.
[swftools.git] / lib / python / tags.c
1 #include "pyutils.h"
2 #include "primitives.h"
3 #include "action.h"
4 #include "tag.h"
5 #include "tags.h"
6 #include "image.h"
7
8 //----------------------------------------------------------------------------
9
10 typedef struct _font_internal
11 {
12     SWFFONT* font;
13 } font_internal_t;
14 staticforward tag_internals_t font_tag;
15
16 static int font_parse(tag_internals_t*self)
17 {
18     font_internal_t*font = (font_internal_t*)self->data;
19     /* TODO */
20     PyErr_SetString(PyExc_Exception, setError("Font parsing not implemented yet"));
21     return 0;
22 }
23 static void font_dealloc(tag_internals_t*self)
24 {
25     font_internal_t*font = (font_internal_t*)self->data;
26     if(font->font) {
27         swf_FontFree(font->font);
28         font->font = 0;
29     }
30 }
31 static int font_fillTAG(tag_internals_t*self)
32 {
33     font_internal_t*fi = (font_internal_t*)self->data;
34     if(self->tag)
35         return 1;
36     self->tag = swf_InsertTag(0, ST_DEFINEFONT2);
37     swf_FontSetDefine2(self->tag, fi->font);
38     return 1;
39 }
40 static PyObject* f_DefineFont(PyObject* self, PyObject* args, PyObject* kwargs)
41 {
42     static char *kwlist[] = {"filename", NULL};
43     char*filename = 0;
44     PyObject*tag;
45     SWFFONT* font;
46
47     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &filename))
48         return NULL;
49
50     font = swf_LoadFont(filename);
51     if(!font) {
52         PyErr_SetString(PyExc_Exception, setError("Could not load %s", filename));
53         return NULL;
54     }
55
56     tag = tag_new(&font_tag);
57     tag_internals_t*itag = tag_getinternals(tag);
58     font_internal_t*fi = (font_internal_t*)itag->data;
59     font->id = 0;
60     fi->font = font;
61     return (PyObject*)tag;
62 }
63 static SWFFONT* font_getSWFFONT(PyObject*self)
64 {
65     PY_ASSERT_TYPE(self, &TagClass);
66     tag_internals_t*itag = tag_getinternals(self);
67     font_internal_t*fi = (font_internal_t*)itag->data;
68     return fi->font;
69 }
70 static tag_internals_t font_tag =
71 {
72     parse: font_parse,
73     fillTAG: font_fillTAG,
74     dealloc: font_dealloc,
75     tagfunctions: 0,
76     datasize: sizeof(font_internal_t),
77 };
78 //----------------------------------------------------------------------------
79
80 typedef struct _placeobject_internal
81 {
82     SWFPLACEOBJECT* po;
83 } placeobject_internal_t;
84 staticforward tag_internals_t placeobject_tag;
85
86 static void po_dealloc(tag_internals_t*self)
87 {
88     placeobject_internal_t*pi = (placeobject_internal_t*)self->data;
89     if(pi->po) {
90         swf_PlaceObjectFree(pi->po);
91         pi->po = 0;
92     }
93 }
94 static int po_parse(tag_internals_t*self)
95 {
96     placeobject_internal_t*pi = (placeobject_internal_t*)self->data;
97     /* TODO */
98     PyErr_SetString(PyExc_Exception, setError("Font parsing not implemented yet"));
99     return 0;
100 }
101 static int po_fillTAG(tag_internals_t*self)
102 {
103     placeobject_internal_t*pi = (placeobject_internal_t*)self->data;
104     self->tag = swf_InsertTag(0, ST_PLACEOBJECT2);
105     swf_SetPlaceObject(self->tag, pi->po);
106     return 1;
107 }
108 static PyObject* po_create(PyObject* self, PyObject* args, PyObject* kwargs,char move)
109 {
110     static char *kwlist[] = {"character", "depth", "matrix", "colortransform", "ratio", "name", "clipdepth", "action", NULL};
111     
112     PyObject*character = 0;
113     int depth;
114     int clipdepth = 0;
115     PyObject*matrix = 0;
116     PyObject*cxform = 0;
117     PyObject*action = 0;
118     int ratio = 0;
119     char* name = 0;
120     SWFPLACEOBJECT* po;
121     po = malloc(sizeof(SWFPLACEOBJECT));
122     memset(po, 0, sizeof(SWFPLACEOBJECT));
123
124     swf_GetPlaceObject(0, po);
125
126     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|O!O!isiO!", kwlist, 
127                 &character, 
128                 &depth, 
129                 &MatrixClass, &matrix, 
130                 &CXFormClass, &cxform,
131                 &ratio,
132                 &name,
133                 &clipdepth,
134                 &ActionClass, &action
135                 ))
136         return NULL;
137     po->depth = depth;
138     po->id = /*ID*/ 0;
139     po->clipdepth = clipdepth;
140     po->ratio = ratio;
141     po->name = name;
142     po->move = move;
143     if(clipdepth) po->clipdepth = clipdepth;
144     if(matrix) po->matrix = matrix_getMatrix(matrix);
145     if(cxform) po->cxform = colortransform_getCXForm(cxform);
146     if(action) po->actions = action_getAction(action);
147
148     PyObject*tag;
149     tag = tag_new(&placeobject_tag);
150     tag_internals_t*itag = tag_getinternals(tag);
151     placeobject_internal_t*pi = (placeobject_internal_t*)itag->data;
152     pi->po = po;
153     pi->po->id = tagmap_add(itag->tagmap,(PyObject*)character);
154     
155     mylog("+%08x(%d) PlaceObject %08x(%d)\n", (int)tag, tag->ob_refcnt, character, character->ob_refcnt);
156
157     return (PyObject*)tag;
158 }
159 static PyObject* f_PlaceObject(PyObject* self, PyObject* args, PyObject* kwargs)
160 {
161     return po_create(self, args, kwargs, 0);
162 }
163 static PyObject* f_MoveObject(PyObject* self, PyObject* args, PyObject* kwargs)
164 {
165     return po_create(self, args, kwargs, 1);
166 }
167 static tag_internals_t placeobject_tag =
168 {
169     parse: po_parse,
170     fillTAG: po_fillTAG,
171     dealloc: po_dealloc,
172     tagfunctions: 0,
173     datasize: sizeof(placeobject_internal_t),
174 };
175 //----------------------------------------------------------------------------
176 staticforward tag_internals_t bgcolor_tag;
177 static PyObject* tag_setbackgroundcolor_getrgb(PyObject * self, PyObject*other)
178 {
179     tag_internals_t*itag = tag_getinternals(self);
180     int r,g,b;
181     r = itag->tag->data[0];
182     g = itag->tag->data[1];
183     b = itag->tag->data[2];
184     return Py_BuildValue("(iii)", r,g,b);
185 }
186 static PyMethodDef setbgcolor_methods[] = 
187 {{"getRGB", tag_setbackgroundcolor_getrgb, METH_VARARGS, "get's the color set by this tag"},
188  {NULL, NULL, 0, NULL}
189 };
190 static PyObject* f_SetBackgroundColor(PyObject* self, PyObject* args, PyObject* kwargs)
191 {
192     static char *kwlist[] = {"color", NULL};
193     int r=0,g=0,b=0;
194     PyObject*tag;
195     PyObject*color;
196     
197     tag = tag_new(&bgcolor_tag);
198     tag_internals_t*itag = tag_getinternals(tag);
199
200     /* 1st try- copy constructor */
201     if(!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &ColorClass, &color)) {
202         PyErr_Clear();
203         /* 2nd try- color's contructor */
204         color = f_Color(NULL, args, kwargs);
205     }
206     if(!color)
207         return NULL;
208
209     itag->tag = swf_InsertTag(0, ST_SETBACKGROUNDCOLOR);
210     RGBA rgba = color_getRGBA(color);
211     swf_SetU8(itag->tag, rgba.r);
212     swf_SetU8(itag->tag, rgba.g);
213     swf_SetU8(itag->tag, rgba.b);
214     mylog(" %08x(%d) SetBackgroundColor(%02x,%02x,%02x) (colorobj=%08x(%d))\n", (int)tag, tag->ob_refcnt, rgba.r, rgba.g, rgba.b, color, color->ob_refcnt);
215     Py_DECREF(color);
216     return (PyObject*)tag;
217 }
218 static tag_internals_t bgcolor_tag =
219 {
220     parse: 0,
221     fillTAG: 0,
222     dealloc: 0,
223     tagfunctions: setbgcolor_methods,
224     datasize: 0,
225 };
226 //----------------------------------------------------------------------------
227 staticforward tag_internals_t protect_tag;
228 static PyObject* f_Protect(PyObject* self, PyObject* args, PyObject* kwargs)
229 {
230     static char *kwlist[] = {"password", NULL};
231     char*password = 0;
232
233     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &password))
234         return NULL;
235
236     PyObject*tag = tag_new(&protect_tag);
237     tag_internals_t*itag = tag_getinternals(tag);
238     itag->tag = swf_InsertTag(0, ST_PROTECT);
239     if(password) {
240         swf_SetPassword(itag->tag, password);
241     }
242     mylog("+%08x(%d) f_Protect", (int)tag, tag->ob_refcnt);
243     return (PyObject*)tag;
244 }
245 static tag_internals_t protect_tag =
246 {
247     parse: 0,
248     fillTAG: 0,
249     dealloc: 0,
250     tagfunctions: 0,
251     datasize: 0,
252 };
253 //----------------------------------------------------------------------------
254 staticforward tag_internals_t showframe_tag;
255 static PyObject* f_ShowFrame(PyObject* self, PyObject* args, PyObject* kwargs)
256 {
257     static char *kwlist[] = {"name", NULL};
258     char*name= 0;
259     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &name))
260         return NULL;
261
262     PyObject*tag = tag_new(&showframe_tag);
263     tag_internals_t*itag = tag_getinternals(tag);
264     itag->tag = swf_InsertTag(0, ST_SHOWFRAME);
265     mylog("+%08x(%d) f_ShowFrame", (int)tag, tag->ob_refcnt);
266     return (PyObject*)tag;
267 }
268 static tag_internals_t showframe_tag =
269 {
270     parse: 0,
271     fillTAG: 0,
272     dealloc: 0,
273     tagfunctions: 0,
274     datasize: 0,
275 };
276 //----------------------------------------------------------------------------
277 staticforward tag_internals_t end_tag;
278 static tag_internals_t end_tag =
279 {
280     parse: 0,
281     fillTAG: 0,
282     dealloc: 0,
283     tagfunctions: 0,
284     datasize: 0,
285 };
286 //----------------------------------------------------------------------------
287 staticforward tag_internals_t text_tag;
288
289 typedef struct _text_internal
290 {
291     char*text;
292     SWFFONT* swffont;
293     RGBA rgba;
294     int size;
295 } text_internal_t;
296 staticforward tag_internals_t placeobject_tag;
297
298 static int text_fillTAG(tag_internals_t*self)
299 {
300     text_internal_t*ti = (text_internal_t*)self->data;
301     self->tag= swf_InsertTag(0, ST_DEFINETEXT2);
302     swf_SetU16(self->tag, /*ID*/0);
303     SRECT r = swf_SetDefineText(self->tag, ti->swffont, &ti->rgba, ti->text, ti->size);
304     return 1;
305 }
306 static PyObject* f_DefineText(PyObject* self, PyObject* args, PyObject* kwargs)
307 {
308     static char *kwlist[] = {"font", "text", "size", "color", NULL};
309     PyObject*tag = 0;
310     char*text = 0;
311     int textlen = 0;
312     PyObject*unicode16;
313     PyObject*unicode8;
314     int size = 0;
315     RGBA rgba = {255,0,0,0};
316     PyObject*color = 0;
317     PyObject*font = 0;
318
319     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!u#i|O!", kwlist, &TagClass, &font, &text, &textlen, &size, &ColorClass, &color))
320         return NULL;
321     
322     unicode16 = PyUnicode_DecodeUTF16(text, textlen*2, NULL, NULL);
323     unicode8 = PyUnicode_AsUTF8String(unicode16);
324     text = PyString_AS_STRING(unicode8);
325
326     if(color)
327         rgba = color_getRGBA(color);
328
329     mylog("DefineText: text = %s", text);
330     
331     tag = tag_new(&text_tag);
332     tag_internals_t* itag = tag_getinternals(tag);
333     text_internal_t*ti = (text_internal_t*)itag->data;
334
335     ti->swffont = font_getSWFFONT(font);
336     int font_id = tagmap_add(itag->tagmap, font); // add dependency on font
337     ti->swffont->id = font_id; // for swf_SetDefineTexts
338     ti->text = strdup(text);
339     ti->rgba = rgba;
340     ti->size = size;
341
342     return (PyObject*)tag;
343 }
344 static tag_internals_t text_tag =
345 {
346     parse: 0,
347     fillTAG: text_fillTAG,
348     dealloc: 0,
349     tagfunctions: 0,
350     datasize: sizeof(text_internal_t),
351 };
352 //----------------------------------------------------------------------------
353 staticforward tag_internals_t image_tag;
354
355 typedef struct _image_internal
356 {
357     RGBA*rgba;
358     int size;
359     int width;
360     int height;
361     int bpp;
362     char isindexed;
363     char islossless;
364 } image_internal_t;
365 staticforward tag_internals_t image_tag;
366
367 static int image_fillTAG(tag_internals_t*self)
368 {
369     image_internal_t*ti = (image_internal_t*)self->data;
370     self->tag= swf_InsertTag(0, ST_DEFINEBITSLOSSLESS2);
371     swf_SetU16(self->tag, /*ID*/0);
372     swf_SetLosslessBits(self->tag, ti->width, ti->height, ti->rgba, BMF_32BIT);
373     return 1;
374 }
375 static void image_dealloc(tag_internals_t*self)
376 {
377     image_internal_t*pi = (image_internal_t*)self->data;
378     if(pi->rgba) {
379         free(pi->rgba);pi->rgba = 0;
380     }
381 }
382 static int imagetag_getWidth(PyObject* self)
383 {
384     tag_internals_t*itag = tag_getinternals(self);
385     image_internal_t*pi = (image_internal_t*)itag->data;
386     return pi->width;
387 }
388 static int imagetag_getHeight(PyObject* self)
389 {
390     tag_internals_t*itag = tag_getinternals(self);
391     image_internal_t*pi = (image_internal_t*)itag->data;
392     return pi->height;
393 }
394 static PyObject* f_DefineImage(PyObject* self, PyObject* args, PyObject* kwargs)
395 {
396     static char *kwlist[] = {"image"};
397     PyObject*image = 0;
398     PyObject*tag = tag_new(&image_tag);
399
400     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &image))
401         return NULL;
402     
403     tag = tag_new(&image_tag);
404     tag_internals_t* itag = tag_getinternals(tag);
405     image_internal_t*ti = (image_internal_t*)itag->data;
406
407     ti->rgba = image_toRGBA(image);
408     if(!ti->rgba) // pass through exception
409         return 0;
410     ti->width = image_getWidth(image);
411     ti->height = image_getHeight(image);
412     ti->isindexed = 0;
413     ti->islossless = 1;
414     ti->bpp = 32;
415     ti->size = ti->width*ti->height;
416
417     return (PyObject*)tag;
418 }
419 static tag_internals_t image_tag =
420 {
421     parse: 0,
422     fillTAG: image_fillTAG,
423     dealloc: image_dealloc,
424     tagfunctions: 0,
425     datasize: sizeof(image_internal_t),
426 };
427 //----------------------------------------------------------------------------
428 staticforward tag_internals_t shape_tag;
429
430 typedef struct _shape_internal
431 {
432     SHAPE2*shape;
433 } shape_internal_t;
434 staticforward tag_internals_t shape_tag;
435
436 static int shape_fillTAG(tag_internals_t*self)
437 {
438     shape_internal_t*ti = (shape_internal_t*)self->data;
439     self->tag= swf_InsertTag(0, ST_DEFINESHAPE3);
440     swf_SetU16(self->tag, /*ID*/0);
441     swf_SetShape2(self->tag, ti->shape);
442     return 1;
443 }
444 static void shape_dealloc(tag_internals_t*self)
445 {
446     shape_internal_t*pi = (shape_internal_t*)self->data;
447     if(pi->shape) {
448         swf_Shape2Free(pi->shape);
449         pi->shape = 0;
450     }
451 }
452 static PyObject* f_DefineImageShape(PyObject* self, PyObject* args, PyObject* kwargs)
453 {
454     static char *kwlist[] = {"image"};
455     PyObject*shape = 0;
456     PyObject*tag = tag_new(&shape_tag);
457     PyObject*image = 0;
458
459     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &TagClass, &image))
460         return NULL;
461     
462     tag = tag_new(&shape_tag);
463     tag_internals_t* itag = tag_getinternals(tag);
464     shape_internal_t*ti = (shape_internal_t*)itag->data;
465     ti->shape = 0; /*HACK*/
466
467     int width = imagetag_getWidth(image);
468     int height = imagetag_getHeight(image);
469     int id = tagmap_add(itag->tagmap, image);
470     itag->tag= swf_InsertTag(0, ST_DEFINESHAPE3);
471     swf_SetU16(itag->tag, 0);
472     swf_ShapeSetBitmapRect(itag->tag, id, width, height);
473     return (PyObject*)tag;
474 }
475 static tag_internals_t shape_tag =
476 {
477     parse: 0,
478     fillTAG: shape_fillTAG,
479     dealloc: shape_dealloc,
480     tagfunctions: 0,
481     datasize: sizeof(shape_internal_t),
482 };
483 //----------------------------------------------------------------------------
484
485 typedef struct _videostream_internal
486 {
487     VIDEOSTREAM* stream;
488     int lastiframe;
489 } videostream_internal_t;
490 staticforward tag_internals_t videostream_tag;
491 staticforward tag_internals_t videoframe_tag;
492
493 static int videostream_parse(tag_internals_t*self)
494 {
495     videostream_internal_t*videostream = (videostream_internal_t*)self->data;
496     /* TODO */
497     PyErr_SetString(PyExc_Exception, setError("videostream parsing not implemented yet"));
498     return 0;
499 }
500 static void videostream_dealloc(tag_internals_t*self)
501 {
502     videostream_internal_t*videostream = (videostream_internal_t*)self->data;
503     if(videostream->stream) {
504         swf_VideoStreamClear(videostream->stream);
505         free(videostream->stream);
506         videostream->stream = 0;
507     }
508 }
509 static int videostream_fillTAG(tag_internals_t*self)
510 {
511     videostream_internal_t*fi = (videostream_internal_t*)self->data;
512     if(self->tag)
513         return 1;
514     PyErr_SetString(PyExc_Exception, setError("videostream filling not implemented"));
515     return 0;
516 }
517 static PyObject* f_DefineVideoStream(PyObject* self, PyObject* args, PyObject* kwargs)
518 {
519     PyObject*tag = tag_new(&videostream_tag);
520    
521     int width=0,height=0,frames=65535;
522     static char *kwlist[] = {"width", "height", "frames", NULL};
523     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|i", kwlist, &width, &height, &frames))
524         return NULL;
525
526     printf(": %d %d\n", width, height);
527     
528     tag_internals_t*itag = tag_getinternals(tag);
529     videostream_internal_t*fi = (videostream_internal_t*)itag->data;
530     fi->stream = malloc(sizeof(VIDEOSTREAM));
531     memset(fi->stream, 0, sizeof(VIDEOSTREAM));
532
533     TAG*t = swf_InsertTag(0, ST_DEFINEVIDEOSTREAM);
534     swf_SetU16(t, 0); /* id */
535     swf_SetVideoStreamDefine(t, fi->stream, frames, width, height);
536     itag->tag = t;
537     fi->lastiframe = -65536;
538     return (PyObject*)tag;
539 }
540 static VIDEOSTREAM* videostream_getVIDEOSTREAM(PyObject*self)
541 {
542     PY_ASSERT_TYPE(self, &TagClass);
543     tag_internals_t*itag = tag_getinternals(self);
544     videostream_internal_t*fi = (videostream_internal_t*)itag->data;
545     return fi->stream;
546 }
547 static PyObject* videostream_getbwidth(PyObject*self, PyObject*args)
548 {
549     tag_internals_t*itag = tag_getinternals(self);
550     videostream_internal_t*fi = (videostream_internal_t*)itag->data;
551     int width = fi->stream->bbx;
552     return Py_BuildValue("i", width);
553 }
554 static PyObject* videostream_getbheight(PyObject*self, PyObject*args)
555 {
556     tag_internals_t*itag = tag_getinternals(self);
557     videostream_internal_t*fi = (videostream_internal_t*)itag->data;
558     int height = fi->stream->bby;
559     return Py_BuildValue("i", height);
560 }
561 static PyObject* videostream_addFrame(PyObject*self, PyObject*args, PyObject*kwargs)
562 {
563     tag_internals_t*_itag = tag_getinternals(self);
564     videostream_internal_t*fi = (videostream_internal_t*)_itag->data;
565    
566     PyObject*image = 0;
567     char*type=0; // none, "i", "p"
568     int quant=7;
569     static char *kwlist[] = {"image", "quant", "type", NULL};
570     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|is", kwlist, &image, &quant, &type))
571         return NULL;
572     if(fi->stream->width != image_getWidth(image)) {
573         PyErr_SetString(PyExc_Exception, setError("bad image width %d!=%d", image_getWidth(image), fi->stream->width));return 0;
574     }
575     if(fi->stream->height != image_getHeight(image)) {
576         PyErr_SetString(PyExc_Exception, setError("bad image width %d!=%d", image_getHeight(image), fi->stream->height));return 0;
577     }
578     PyObject*tag = tag_new(&videoframe_tag);
579     tag_internals_t*itag = tag_getinternals(tag);
580
581     RGBA*pic = image_toRGBA(image);
582     if(!pic)
583         return 0;
584     TAG* t = swf_InsertTag(0, ST_VIDEOFRAME);
585     if((type && (type[0]=='I' || type[0]=='i')) || (type==0 && fi->lastiframe+64 < fi->stream->frame)) {
586         swf_SetU16(t,0);
587         swf_SetVideoStreamIFrame(t, fi->stream, pic, quant);
588         fi->lastiframe = fi->stream->frame;
589     } else {
590         swf_SetU16(t,0);
591         swf_SetVideoStreamPFrame(t, fi->stream, pic, quant);
592     }
593     itag->tag = t;
594     tagmap_addMapping(itag->tagmap, 0, self);
595     free(pic);
596     return tag;
597 }
598 static PyObject* videostream_addDistortionFrame(PyObject*self, PyObject*args)
599 {
600     tag_internals_t*_itag = tag_getinternals(self);
601     videostream_internal_t*fi = (videostream_internal_t*)_itag->data;
602     
603     PyObject*tag = tag_new(&videoframe_tag);
604     tag_internals_t*itag = tag_getinternals(tag);
605     /* DUMMY */
606     TAG* t = swf_InsertTag(0, ST_REFLEX);
607     itag->tag = t;
608
609     return tag;
610 }
611 static PyMethodDef videostream_methods[] = 
612 {{"xblocks", videostream_getbwidth, METH_VARARGS, "get's the number of horizontal blocks"},
613  {"yblocks", videostream_getbheight, METH_VARARGS, "get's the number of vertical blocks"},
614  {"addFrame", (PyCFunction)videostream_addFrame, METH_KEYWORDS, "add a Video Frame"},
615  {"addDistortionFrame", (PyCFunction)videostream_addDistortionFrame, METH_KEYWORDS, "add a MVD frame"},
616  {NULL, NULL, 0, NULL}
617 };
618
619 static tag_internals_t videostream_tag =
620 {
621     parse: videostream_parse,
622     fillTAG: videostream_fillTAG,
623     dealloc: videostream_dealloc,
624     tagfunctions: videostream_methods,
625     datasize: sizeof(videostream_internal_t),
626 };
627
628 //============================================================================
629
630 static tag_internals_t videoframe_tag =
631 {
632     parse: 0,
633     fillTAG: 0,
634     dealloc: 0,
635     tagfunctions: 0,
636     datasize: 0
637 };
638
639 //============================================================================
640
641 static PyMethodDef TagMethods[] = 
642 {
643     /* TAGS */
644     {"BackgroundColor", (PyCFunction)f_SetBackgroundColor, METH_KEYWORDS, "Create a SetBackGroundColor Tag."},
645     {"Protect", (PyCFunction)f_Protect, METH_KEYWORDS, "Create a Protect Tag."},
646     {"Font", (PyCFunction)f_DefineFont, METH_KEYWORDS, "Create a DefineFont Tag."},
647     {"Text", (PyCFunction)f_DefineText, METH_KEYWORDS, "Create a DefineText Tag."},
648     {"PlaceObject", (PyCFunction)f_PlaceObject, METH_KEYWORDS, "Create a PlaceObject Tag."},
649     {"MoveObject", (PyCFunction)f_MoveObject, METH_KEYWORDS, "Create a PlaceObject Move Tag."},
650     {"VideoStream", (PyCFunction)f_DefineVideoStream, METH_KEYWORDS, "Create a Videostream."},
651     {"Image", (PyCFunction)f_DefineImage, METH_KEYWORDS, "Create an SWF Image Tag."},
652     {"ImageShape", (PyCFunction)f_DefineImageShape, METH_KEYWORDS, "Create an SWF Image Shape Tag."},
653     {"ShowFrame", (PyCFunction)f_ShowFrame, METH_KEYWORDS, "Create an SWF Show Frame Tag."},
654     {NULL, NULL, 0, NULL}
655 };
656 PyMethodDef* tags_getMethods()
657 {
658     TagClass.ob_type = &PyType_Type;
659     
660     register_tag(ST_PLACEOBJECT,&placeobject_tag);
661     register_tag(ST_PLACEOBJECT2,&placeobject_tag);
662     register_tag(ST_SETBACKGROUNDCOLOR,&bgcolor_tag);
663     register_tag(ST_DEFINEFONT,&font_tag);
664     register_tag(ST_PROTECT,&protect_tag);
665     register_tag(ST_DEFINETEXT,&text_tag);
666     register_tag(ST_DEFINEBITSJPEG,&image_tag);
667     register_tag(ST_DEFINEBITSJPEG2,&image_tag);
668     register_tag(ST_DEFINEBITSJPEG3,&image_tag);
669     register_tag(ST_DEFINEBITSLOSSLESS,&image_tag);
670     register_tag(ST_DEFINEBITSLOSSLESS2,&image_tag);
671     register_tag(ST_END,&end_tag);
672
673     return TagMethods;
674 }
675