fixed ImageShape image size lookup.
[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* f_PlaceObject(PyObject* self, PyObject* args, PyObject* kwargs)
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     if(clipdepth) po->clipdepth = clipdepth;
143     if(matrix) po->matrix = matrix_getMatrix(matrix);
144     if(cxform) po->cxform = colortransform_getCXForm(cxform);
145     if(action) po->actions = action_getAction(action);
146
147     PyObject*tag;
148     tag = tag_new(&placeobject_tag);
149     tag_internals_t*itag = tag_getinternals(tag);
150     placeobject_internal_t*pi = (placeobject_internal_t*)itag->data;
151     pi->po = po;
152     pi->po->id = tagmap_add(itag->tagmap,(PyObject*)character);
153     
154     mylog("+%08x(%d) PlaceObject %08x(%d)\n", (int)tag, tag->ob_refcnt, character, character->ob_refcnt);
155
156     return (PyObject*)tag;
157 }
158 static tag_internals_t placeobject_tag =
159 {
160     parse: po_parse,
161     fillTAG: po_fillTAG,
162     dealloc: po_dealloc,
163     tagfunctions: 0,
164     datasize: sizeof(placeobject_internal_t),
165 };
166 //----------------------------------------------------------------------------
167 staticforward tag_internals_t bgcolor_tag;
168 static PyObject* tag_setbackgroundcolor_getrgb(PyObject * self, PyObject*other)
169 {
170     tag_internals_t*itag = tag_getinternals(self);
171     int r,g,b;
172     r = itag->tag->data[0];
173     g = itag->tag->data[1];
174     b = itag->tag->data[2];
175     return Py_BuildValue("(iii)", r,g,b);
176 }
177 static PyMethodDef setbgcolor_methods[] = 
178 {{"getRGB", tag_setbackgroundcolor_getrgb, METH_VARARGS, "get's the color set by this tag"},
179  {NULL, NULL, 0, NULL}
180 };
181 static PyObject* f_SetBackgroundColor(PyObject* self, PyObject* args, PyObject* kwargs)
182 {
183     static char *kwlist[] = {"color", NULL};
184     int r=0,g=0,b=0;
185     PyObject*tag;
186     PyObject*color;
187     
188     tag = tag_new(&bgcolor_tag);
189     tag_internals_t*itag = tag_getinternals(tag);
190
191     /* 1st try- copy constructor */
192     if(!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &ColorClass, &color)) {
193         PyErr_Clear();
194         /* 2nd try- color's contructor */
195         color = f_Color(NULL, args, kwargs);
196     }
197     if(!color)
198         return NULL;
199
200     itag->tag = swf_InsertTag(0, ST_SETBACKGROUNDCOLOR);
201     RGBA rgba = color_getRGBA(color);
202     swf_SetU8(itag->tag, rgba.r);
203     swf_SetU8(itag->tag, rgba.g);
204     swf_SetU8(itag->tag, rgba.b);
205     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);
206     Py_DECREF(color);
207     return (PyObject*)tag;
208 }
209 static tag_internals_t bgcolor_tag =
210 {
211     parse: 0,
212     fillTAG: 0,
213     dealloc: 0,
214     tagfunctions: setbgcolor_methods,
215     datasize: 0,
216 };
217 //----------------------------------------------------------------------------
218 staticforward tag_internals_t protect_tag;
219 static PyObject* f_Protect(PyObject* self, PyObject* args, PyObject* kwargs)
220 {
221     static char *kwlist[] = {"password", NULL};
222     char*password = 0;
223
224     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", kwlist, &password))
225         return NULL;
226
227     PyObject*tag = tag_new(&protect_tag);
228     tag_internals_t*itag = tag_getinternals(tag);
229     itag->tag = swf_InsertTag(0, ST_PROTECT);
230     if(password) {
231         swf_SetPassword(itag->tag, password);
232     }
233     mylog("+%08x(%d) f_Protect", (int)tag, tag->ob_refcnt);
234     return (PyObject*)tag;
235 }
236 static tag_internals_t protect_tag =
237 {
238     parse: 0,
239     fillTAG: 0,
240     dealloc: 0,
241     tagfunctions: 0,
242     datasize: 0,
243 };
244 //----------------------------------------------------------------------------
245 staticforward tag_internals_t end_tag;
246 static tag_internals_t end_tag =
247 {
248     parse: 0,
249     fillTAG: 0,
250     dealloc: 0,
251     tagfunctions: 0,
252     datasize: 0,
253 };
254 //----------------------------------------------------------------------------
255 staticforward tag_internals_t text_tag;
256
257 typedef struct _text_internal
258 {
259     char*text;
260     SWFFONT* swffont;
261     RGBA rgba;
262     int size;
263 } text_internal_t;
264 staticforward tag_internals_t placeobject_tag;
265
266 static int text_fillTAG(tag_internals_t*self)
267 {
268     text_internal_t*ti = (text_internal_t*)self->data;
269     self->tag= swf_InsertTag(0, ST_DEFINETEXT2);
270     swf_SetU16(self->tag, /*ID*/0);
271     SRECT r = swf_SetDefineText(self->tag, ti->swffont, &ti->rgba, ti->text, ti->size);
272     return 1;
273 }
274 static PyObject* f_DefineText(PyObject* self, PyObject* args, PyObject* kwargs)
275 {
276     static char *kwlist[] = {"font", "text", "size", "color", NULL};
277     PyObject*tag = 0;
278     char*text = 0;
279     int textlen = 0;
280     PyObject*unicode16;
281     PyObject*unicode8;
282     int size = 0;
283     RGBA rgba = {255,0,0,0};
284     PyObject*color = 0;
285     PyObject*font = 0;
286
287     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!u#i|O!", kwlist, &TagClass, &font, &text, &textlen, &size, &ColorClass, &color))
288         return NULL;
289     
290     unicode16 = PyUnicode_DecodeUTF16(text, textlen*2, NULL, NULL);
291     unicode8 = PyUnicode_AsUTF8String(unicode16);
292     text = PyString_AS_STRING(unicode8);
293
294     if(color)
295         rgba = color_getRGBA(color);
296
297     mylog("DefineText: text = %s", text);
298     
299     tag = tag_new(&text_tag);
300     tag_internals_t* itag = tag_getinternals(tag);
301     text_internal_t*ti = (text_internal_t*)itag->data;
302
303     ti->swffont = font_getSWFFONT(font);
304     int font_id = tagmap_add(itag->tagmap, font); // add dependency on font
305     ti->swffont->id = font_id; // for swf_SetDefineTexts
306     ti->text = strdup(text);
307     ti->rgba = rgba;
308     ti->size = size;
309
310     return (PyObject*)tag;
311 }
312 static tag_internals_t text_tag =
313 {
314     parse: 0,
315     fillTAG: text_fillTAG,
316     dealloc: 0,
317     tagfunctions: 0,
318     datasize: sizeof(text_internal_t),
319 };
320 //----------------------------------------------------------------------------
321 staticforward tag_internals_t image_tag;
322
323 typedef struct _image_internal
324 {
325     RGBA*rgba;
326     int size;
327     int width;
328     int height;
329     int bpp;
330     char isindexed;
331     char islossless;
332 } image_internal_t;
333 staticforward tag_internals_t image_tag;
334
335 static int image_fillTAG(tag_internals_t*self)
336 {
337     image_internal_t*ti = (image_internal_t*)self->data;
338     self->tag= swf_InsertTag(0, ST_DEFINEBITSLOSSLESS2);
339     swf_SetU16(self->tag, /*ID*/0);
340     swf_SetLosslessBits(self->tag, ti->width, ti->height, ti->rgba, BMF_32BIT);
341     return 1;
342 }
343 static void image_dealloc(tag_internals_t*self)
344 {
345     image_internal_t*pi = (image_internal_t*)self->data;
346     if(pi->rgba) {
347         free(pi->rgba);pi->rgba = 0;
348     }
349 }
350 static int imagetag_getWidth(PyObject* self)
351 {
352     tag_internals_t*itag = tag_getinternals(self);
353     image_internal_t*pi = (image_internal_t*)itag->data;
354     return pi->width;
355 }
356 static int imagetag_getHeight(PyObject* self)
357 {
358     tag_internals_t*itag = tag_getinternals(self);
359     image_internal_t*pi = (image_internal_t*)itag->data;
360     return pi->height;
361 }
362 static PyObject* f_DefineImage(PyObject* self, PyObject* args, PyObject* kwargs)
363 {
364     static char *kwlist[] = {"image"};
365     PyObject*image = 0;
366     PyObject*tag = tag_new(&image_tag);
367
368     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &image))
369         return NULL;
370     
371     tag = tag_new(&image_tag);
372     tag_internals_t* itag = tag_getinternals(tag);
373     image_internal_t*ti = (image_internal_t*)itag->data;
374
375     ti->rgba = image_toRGBA(image);
376     if(!ti->rgba) // pass through exception
377         return 0;
378     ti->width = image_getWidth(image);
379     ti->height = image_getHeight(image);
380     ti->isindexed = 0;
381     ti->islossless = 1;
382     ti->bpp = 32;
383     ti->size = ti->width*ti->height;
384
385     return (PyObject*)tag;
386 }
387 static tag_internals_t image_tag =
388 {
389     parse: 0,
390     fillTAG: image_fillTAG,
391     dealloc: image_dealloc,
392     tagfunctions: 0,
393     datasize: sizeof(image_internal_t),
394 };
395 //----------------------------------------------------------------------------
396 staticforward tag_internals_t shape_tag;
397
398 typedef struct _shape_internal
399 {
400     SHAPE2*shape;
401 } shape_internal_t;
402 staticforward tag_internals_t shape_tag;
403
404 static int shape_fillTAG(tag_internals_t*self)
405 {
406     shape_internal_t*ti = (shape_internal_t*)self->data;
407     self->tag= swf_InsertTag(0, ST_DEFINESHAPE3);
408     swf_SetU16(self->tag, /*ID*/0);
409     swf_SetShape2(self->tag, ti->shape);
410     return 1;
411 }
412 static void shape_dealloc(tag_internals_t*self)
413 {
414     shape_internal_t*pi = (shape_internal_t*)self->data;
415     if(pi->shape) {
416         swf_Shape2Free(pi->shape);
417         pi->shape = 0;
418     }
419 }
420 static PyObject* f_DefineImageShape(PyObject* self, PyObject* args, PyObject* kwargs)
421 {
422     static char *kwlist[] = {"image"};
423     PyObject*shape = 0;
424     PyObject*tag = tag_new(&shape_tag);
425     PyObject*image = 0;
426
427     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &TagClass, &image))
428         return NULL;
429     
430     tag = tag_new(&shape_tag);
431     tag_internals_t* itag = tag_getinternals(tag);
432     shape_internal_t*ti = (shape_internal_t*)itag->data;
433     ti->shape = 0; /*HACK*/
434
435     int width = imagetag_getWidth(image);
436     int height = imagetag_getHeight(image);
437     int id = tagmap_add(itag->tagmap, image);
438     itag->tag= swf_InsertTag(0, ST_DEFINESHAPE3);
439     swf_SetU16(itag->tag, 0);
440     swf_ShapeSetBitmapRect(itag->tag, id, width, height);
441     return (PyObject*)tag;
442 }
443 static tag_internals_t shape_tag =
444 {
445     parse: 0,
446     fillTAG: shape_fillTAG,
447     dealloc: shape_dealloc,
448     tagfunctions: 0,
449     datasize: sizeof(shape_internal_t),
450 };
451 //----------------------------------------------------------------------------
452
453 typedef struct _videostream_internal
454 {
455     VIDEOSTREAM* stream;
456     int lastiframe;
457 } videostream_internal_t;
458 staticforward tag_internals_t videostream_tag;
459 staticforward tag_internals_t videoframe_tag;
460
461 static int videostream_parse(tag_internals_t*self)
462 {
463     videostream_internal_t*videostream = (videostream_internal_t*)self->data;
464     /* TODO */
465     PyErr_SetString(PyExc_Exception, setError("videostream parsing not implemented yet"));
466     return 0;
467 }
468 static void videostream_dealloc(tag_internals_t*self)
469 {
470     videostream_internal_t*videostream = (videostream_internal_t*)self->data;
471     if(videostream->stream) {
472         swf_VideoStreamClear(videostream->stream);
473         free(videostream->stream);
474         videostream->stream = 0;
475     }
476 }
477 static int videostream_fillTAG(tag_internals_t*self)
478 {
479     videostream_internal_t*fi = (videostream_internal_t*)self->data;
480     if(self->tag)
481         return 1;
482     /* TODO */
483     PyErr_SetString(PyExc_Exception, setError("videostream filling not implemented yet"));return 0;
484     return 1;
485 }
486 static PyObject* f_DefineVideoStream(PyObject* self, PyObject* args, PyObject* kwargs)
487 {
488     PyObject*tag = tag_new(&videostream_tag);
489    
490     int width=0,height=0,frames=65535;
491     static char *kwlist[] = {"width", "height", "frames", NULL};
492     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|i", kwlist, &TagClass, &width, &height, &frames))
493         return NULL;
494     
495     tag_internals_t*itag = tag_getinternals(tag);
496     videostream_internal_t*fi = (videostream_internal_t*)itag->data;
497     fi->stream = malloc(sizeof(VIDEOSTREAM));
498     memset(fi->stream, 0, sizeof(VIDEOSTREAM));
499
500     TAG*t = swf_InsertTag(0, ST_DEFINEVIDEOSTREAM);
501     swf_SetVideoStreamDefine(t, fi->stream, frames, width, height);
502     fi->lastiframe = -65536;
503     return (PyObject*)tag;
504 }
505 static VIDEOSTREAM* videostream_getVIDEOSTREAM(PyObject*self)
506 {
507     PY_ASSERT_TYPE(self, &TagClass);
508     tag_internals_t*itag = tag_getinternals(self);
509     videostream_internal_t*fi = (videostream_internal_t*)itag->data;
510     return fi->stream;
511 }
512 static PyObject* videostream_getbwidth(PyObject*self, PyObject*args)
513 {
514     tag_internals_t*itag = tag_getinternals(self);
515     videostream_internal_t*fi = (videostream_internal_t*)itag->data;
516     int width = fi->stream->bbx;
517     return Py_BuildValue("i", width);
518 }
519 static PyObject* videostream_getbheight(PyObject*self, PyObject*args)
520 {
521     tag_internals_t*itag = tag_getinternals(self);
522     videostream_internal_t*fi = (videostream_internal_t*)itag->data;
523     int height = fi->stream->bby;
524     return Py_BuildValue("i", height);
525 }
526 static PyObject* videostream_addFrame(PyObject*self, PyObject*args, PyObject*kwargs)
527 {
528     tag_internals_t*_itag = tag_getinternals(self);
529     videostream_internal_t*fi = (videostream_internal_t*)_itag->data;
530    
531     PyObject*image = 0;
532     char*type=0; // none, "i", "p"
533     int quant=7;
534     static char *kwlist[] = {"image", "quant", "type", NULL};
535     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|is", kwlist, &image, &quant, &type))
536         return NULL;
537     if(fi->stream->width != image_getWidth(image)) {
538         PyErr_SetString(PyExc_Exception, setError("bad image width %d!=%d", image_getWidth(image), fi->stream->width));return 0;
539     }
540     if(fi->stream->height != image_getHeight(image)) {
541         PyErr_SetString(PyExc_Exception, setError("bad image width %d!=%d", image_getHeight(image), fi->stream->height));return 0;
542     }
543     PyObject*tag = tag_new(&videoframe_tag);
544     tag_internals_t*itag = tag_getinternals(tag);
545
546     RGBA*pic = image_toRGBA(image);
547     TAG* t = swf_InsertTag(0, ST_VIDEOFRAME);
548     if((type && (type[0]=='I' || type[0]=='i')) || (type==0 && fi->lastiframe+64 < fi->stream->frame)) {
549         swf_SetU16(t,0);
550         swf_SetVideoStreamIFrame(t, fi->stream, pic, quant);
551         fi->lastiframe = fi->stream->frame;
552     } else {
553         swf_SetU16(t,0);
554         swf_SetVideoStreamPFrame(t, fi->stream, pic, quant);
555     }
556     itag->tag = t;
557     tagmap_addMapping(itag->tagmap, 0, self);
558     free(pic);
559     return Py_BuildValue("s", 0);
560 }
561 static PyObject* videostream_addDistortionFrame(PyObject*self, PyObject*args)
562 {
563     tag_internals_t*itag = tag_getinternals(self);
564     videostream_internal_t*fi = (videostream_internal_t*)itag->data;
565     
566     /* TODO */
567     return Py_BuildValue("s", 0);
568 }
569 static PyMethodDef videostream_methods[] = 
570 {{"xblocks", videostream_getbwidth, METH_VARARGS, "get's the number of horizontal blocks"},
571  {"yblocks", videostream_getbheight, METH_VARARGS, "get's the number of vertical blocks"},
572  {"addFrame", (PyCFunction)videostream_addFrame, METH_KEYWORDS, "add a Video Frame"},
573  {"addDistortionFrame", (PyCFunction)videostream_addDistortionFrame, METH_KEYWORDS, "add a MVD frame"},
574  {NULL, NULL, 0, NULL}
575 };
576
577 static tag_internals_t videostream_tag =
578 {
579     parse: videostream_parse,
580     fillTAG: videostream_fillTAG,
581     dealloc: videostream_dealloc,
582     tagfunctions: videostream_methods,
583     datasize: sizeof(videostream_internal_t),
584 };
585
586 //============================================================================
587
588 static tag_internals_t videoframe_tag =
589 {
590     parse: 0,
591     fillTAG: 0,
592     dealloc: 0,
593     tagfunctions: 0,
594     datasize: 0
595 };
596
597 //============================================================================
598
599 static PyMethodDef TagMethods[] = 
600 {
601     /* TAGS */
602     {"BackgroundColor", (PyCFunction)f_SetBackgroundColor, METH_KEYWORDS, "Create a SetBackGroundColor Tag."},
603     {"Protect", (PyCFunction)f_Protect, METH_KEYWORDS, "Create a Protect Tag."},
604     {"Font", (PyCFunction)f_DefineFont, METH_KEYWORDS, "Create a DefineFont Tag."},
605     {"Text", (PyCFunction)f_DefineText, METH_KEYWORDS, "Create a DefineText Tag."},
606     {"PlaceObject", (PyCFunction)f_PlaceObject, METH_KEYWORDS, "Create a PlaceObject Tag."},
607     {"VideoStream", (PyCFunction)f_DefineVideoStream, METH_KEYWORDS, "Create a Videostream."},
608     {"Image", (PyCFunction)f_DefineImage, METH_KEYWORDS, "Create an SWF Image Tag."},
609     {"ImageShape", (PyCFunction)f_DefineImageShape, METH_KEYWORDS, "Create an SWF Image Shape Tag."},
610     {NULL, NULL, 0, NULL}
611 };
612 PyMethodDef* tags_getMethods()
613 {
614     TagClass.ob_type = &PyType_Type;
615     
616     register_tag(ST_PLACEOBJECT,&placeobject_tag);
617     register_tag(ST_PLACEOBJECT2,&placeobject_tag);
618     register_tag(ST_SETBACKGROUNDCOLOR,&bgcolor_tag);
619     register_tag(ST_DEFINEFONT,&font_tag);
620     register_tag(ST_PROTECT,&protect_tag);
621     register_tag(ST_DEFINETEXT,&text_tag);
622     register_tag(ST_DEFINEBITSJPEG,&image_tag);
623     register_tag(ST_DEFINEBITSJPEG2,&image_tag);
624     register_tag(ST_DEFINEBITSJPEG3,&image_tag);
625     register_tag(ST_DEFINEBITSLOSSLESS,&image_tag);
626     register_tag(ST_DEFINEBITSLOSSLESS2,&image_tag);
627     register_tag(ST_END,&end_tag);
628
629     return TagMethods;
630 }
631