X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpython%2Ftags.c;h=29272430a7535eeb91ec18cb95b523c848ff1168;hb=5d23cf0d32a9e907fc641db4a2f3946f0645ed3a;hp=96929326129d6e6e86d9bb7a5cc9924da9441a0f;hpb=e771c1276a8b8a7831de866b17fc1fba561936e5;p=swftools.git diff --git a/lib/python/tags.c b/lib/python/tags.c index 9692932..2927243 100644 --- a/lib/python/tags.c +++ b/lib/python/tags.c @@ -417,6 +417,7 @@ typedef struct _text_internal SWFFONT* swffont; RGBA rgba; int size; + SRECT bbox; } text_internal_t; staticforward tag_internals_t placeobject_tag; @@ -425,9 +426,17 @@ static int text_fillTAG(tag_internals_t*self) text_internal_t*ti = (text_internal_t*)self->data; self->tag= swf_InsertTag(0, ST_DEFINETEXT2); swf_SetU16(self->tag, /*ID*/0); - SRECT r = swf_SetDefineText(self->tag, ti->swffont, &ti->rgba, ti->text, ti->size); + ti->bbox = swf_SetDefineText(self->tag, ti->swffont, &ti->rgba, ti->text, ti->size); return 1; } +static PyObject* text_getattr(tag_internals_t*self,char*a) +{ + text_internal_t*si = (text_internal_t*)self->data; + if(!strcmp(a, "bbox")) { + return f_BBox2(si->bbox); + } + return 0; +} static PyObject* f_DefineText(PyObject* self, PyObject* args, PyObject* kwargs) { static char *kwlist[] = {"font", "text", "size", "color", NULL}; @@ -441,7 +450,11 @@ static PyObject* f_DefineText(PyObject* self, PyObject* args, PyObject* kwargs) if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!Oi|O!", kwlist, &TagClass, &font, &otext, &size, &ColorClass, &color)) return NULL; - text = PyString_AS_STRING(PyUnicode_AsUTF8String(otext)); + if(PyUnicode_Check(otext)) { + text = PyString_AS_STRING(PyUnicode_AsUTF8String(otext)); + } else if(PyString_Check(otext)) { + text = PyString_AS_STRING(otext); + } if(color) rgba = color_getRGBA(color); @@ -466,7 +479,7 @@ static tag_internals_t text_tag = parse: 0, fillTAG: text_fillTAG, dealloc: 0, - getattr: 0, + getattr: text_getattr, setattr: 0, tagfunctions: 0, datasize: sizeof(text_internal_t), @@ -708,8 +721,7 @@ static PyObject* videostream_addFrame(PyObject*self, PyObject*args, PyObject*kwa if(!pic) return 0; - -{ int f,j=0,i=0,rr,gg,bb; +/*{ int f,j=0,i=0,rr,gg,bb; FILE *o; RGBA*it = pic; char*filename="test.ppm"; @@ -726,7 +738,7 @@ static PyObject* videostream_addFrame(PyObject*self, PyObject*args, PyObject*kwa j++; } fclose(o); -} +}*/ TAG* t = swf_InsertTag(0, ST_VIDEOFRAME); if((type && (type[0]=='I' || type[0]=='i')) || (type==0 && fi->lastiframe+64 < fi->stream->frame)) {