X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpython%2FSWF.c;h=0c8fd6f931d74b372d3a00683cae012134db42cc;hb=357b4098faaa5cf537c1e2292521305d95f681b1;hp=2ed67f391d7d9fb2d6daebb7fd7885c2715621dd;hpb=786db6cd5ade7f42b13efb21647a22becb58ce35;p=swftools.git diff --git a/lib/python/SWF.c b/lib/python/SWF.c index 2ed67f3..0c8fd6f 100644 --- a/lib/python/SWF.c +++ b/lib/python/SWF.c @@ -49,7 +49,7 @@ staticforward PyTypeObject SWFClass; typedef struct { PyObject_HEAD - SWF swf; //swf.firstTag ist not used + SWF swf; //swf.firstTag is not used PyObject*taglist; char*filename; } SWFObject; @@ -74,12 +74,14 @@ static PyObject* f_create(PyObject* self, PyObject* args, PyObject* kwargs) &obbox, &filename)) return NULL; - if (!PY_CHECK_TYPE(obbox, &BBoxClass)) { - obbox = f_BBox(0, obbox, 0); - if(!obbox) - return NULL; + if(obbox) { + if (!PY_CHECK_TYPE(obbox, &BBoxClass)) { + obbox = f_BBox(0, obbox, 0); + if(!obbox) + return NULL; + } + bbox = bbox_getSRECT(obbox); } - bbox = bbox_getSRECT(obbox); memset(&swf->swf, 0, sizeof(SWF)); if(filename) @@ -169,8 +171,9 @@ static PyObject * swf_save(PyObject* self, PyObject* args, PyObject* kwargs) swf->compressed = 1; swf->firstTag = taglist_getTAGs(swfo->taglist); - if(!swf->firstTag) - return NULL; + + /*if(!swf->firstTag) + return NULL;*/ // fix the file, in case it is empty or not terminated properly { @@ -280,7 +283,7 @@ static int swf_print(PyObject * self, FILE *fi, int flags) //flags&Py_PRINT_RAW static PyObject* swf_getattr(PyObject * self, char* a) { SWFObject*swf = (SWFObject*)self; - PyObject* ret; + PyObject* ret = 0; if(!strcmp(a, "fps")) { double fps = swf->swf.frameRate/256.0; @@ -301,6 +304,18 @@ static PyObject* swf_getattr(PyObject * self, char* a) Py_INCREF(ret); mylog(" %08x(%d) swf_getattr %s = %08x(%d)\n", (int)self, self->ob_refcnt, a, ret, ret->ob_refcnt); return ret; + } else if(!strcmp(a, "filesize")) { + int s = swf->swf.fileSize; + return Py_BuildValue("i", s); + } else if(!strcmp(a, "width")) { + int w = (swf->swf.movieSize.xmax - swf->swf.movieSize.xmin) / 20; + return Py_BuildValue("i", w); + } else if(!strcmp(a, "height")) { + int h = (swf->swf.movieSize.ymax - swf->swf.movieSize.ymin) / 20; + return Py_BuildValue("i", h); + } else if(!strcmp(a, "framecount")) { + int f = swf->swf.frameCount; + return Py_BuildValue("i", f); } ret = Py_FindMethod(swf_functions, self, a); @@ -438,4 +453,3 @@ void initSWF(void) to keep it around */ // free(all_methods) } -