SWFPLACEOBJECT* po;
po = malloc(sizeof(SWFPLACEOBJECT));
memset(po, 0, sizeof(SWFPLACEOBJECT));
-
+
swf_GetPlaceObject(0, po);
-
+
+ PyErr_Clear();
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|O!O!isiO!", kwlist,
&character,
&depth,
&ActionClass, &action
))
return NULL;
+
po->depth = depth;
po->clipdepth = clipdepth;
po->ratio = ratio;
datasize: 0,
};
//----------------------------------------------------------------------------
+staticforward tag_internals_t removeobject_tag;
+static PyObject* f_RemoveObject(PyObject* self, PyObject* args, PyObject* kwargs)
+{
+ static char *kwlist[] = {"depth", NULL};
+ int depth;
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &depth))
+ return NULL;
+
+ PyObject*tag = tag_new(&removeobject_tag);
+ tag_internals_t*itag = tag_getinternals(tag);
+ itag->tag = swf_InsertTag(0, ST_REMOVEOBJECT);
+ swf_SetU16(itag->tag, depth);
+ mylog("+%08x(%d) f_RemoveObject", (int)tag, tag->ob_refcnt);
+ return (PyObject*)tag;
+}
+static tag_internals_t removeobject_tag =
+{
+ parse: 0,
+ fillTAG: 0,
+ dealloc: 0,
+ getattr: 0,
+ setattr: 0,
+ tagfunctions: 0,
+ datasize: 0,
+};
+//----------------------------------------------------------------------------
staticforward tag_internals_t sprite_tag;
typedef struct _sprite_internal
{
SWFFONT* swffont;
RGBA rgba;
int size;
+ SRECT bbox;
} text_internal_t;
staticforward tag_internals_t placeobject_tag;
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};
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);
parse: 0,
fillTAG: text_fillTAG,
dealloc: 0,
- getattr: 0,
+ getattr: text_getattr,
setattr: 0,
tagfunctions: 0,
datasize: sizeof(text_internal_t),
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|i", kwlist, &width, &height, &frames))
return NULL;
- printf(": %d %d\n", width, height);
-
tag_internals_t*itag = tag_getinternals(tag);
videostream_internal_t*fi = (videostream_internal_t*)itag->data;
fi->stream = malloc(sizeof(VIDEOSTREAM));
int height = fi->stream->bby;
return Py_BuildValue("i", height);
}
+static PyObject* videostream_addBlackFrame(PyObject*self, PyObject*args, PyObject*kwargs)
+{
+ tag_internals_t*_itag = tag_getinternals(self);
+ videostream_internal_t*fi = (videostream_internal_t*)_itag->data;
+
+ TAG* t = swf_InsertTag(0, ST_VIDEOFRAME);
+
+ PyObject*tag = tag_new(&videoframe_tag);
+ tag_internals_t*itag = tag_getinternals(tag);
+
+ swf_SetU16(t,0); /* id */
+ swf_SetVideoStreamBlackFrame(t, fi->stream);
+ fi->lastiframe = fi->stream->frame;
+
+ itag->tag = t;
+ tagmap_addMapping(itag->tagmap, 0, self);
+ return tag;
+}
static PyObject* videostream_addFrame(PyObject*self, PyObject*args, PyObject*kwargs)
{
tag_internals_t*_itag = tag_getinternals(self);
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";
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)) {
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i", kwlist, &array, &quant))
return NULL;
- signed char* movex = malloc(fi->stream->bbx * fi->stream->bby);
- signed char* movey = malloc(fi->stream->bbx * fi->stream->bby);
+ signed char* movex = malloc(fi->stream->bbx * fi->stream->bby * 1);
+ signed char* movey = malloc(fi->stream->bbx * fi->stream->bby * 1);
+ RGBA** pics = (RGBA**)malloc(fi->stream->bbx * fi->stream->bby * sizeof(void*));
signed char* itx=movex;
signed char* ity=movey;
+ RGBA**pic=pics;
int x,y;
if(!array || !PySequence_Check(array))
return PY_ERROR("Not an array");
for(x=0;x<fi->stream->bbx;x++) {
PyObject*pixel = PySequence_GetItem(line, x);
+ PyObject*xy = 0;
+ PyObject*image = 0;
+
if(!pixel) {
- *itx = 0;
- *ity = 0;
+ xy = image = 0;
} else {
- if(!PyComplex_Check(pixel)) {
- return PY_ERROR("Not an array of arrays of complex numbers");
+ if(PyComplex_Check(pixel)) {
+ xy = pixel; image = 0;
+ } else if(PyString_Check(pixel)) {
+ xy = 0; image = pixel;
+ } else if(PyTuple_Check(pixel)) {
+ int size = PyTuple_GET_SIZE(pixel);
+ if(size!=2) return PY_ERROR("Tuples have to have size 2 (xy,img)");
+ xy = PyTuple_GetItem(pixel, 0);
+ if(!xy) return 0;
+ if(!PyComplex_Check(xy)) return PY_ERROR("Tuples must be (COMPLEX,string)");
+ image = PyTuple_GetItem(pixel, 1);
+ if(!image) return 0;
+ if(!PyString_Check(image)) return PY_ERROR("Tuples must be (complex,STRING)");
}
+ }
+
+ *itx = *ity = 0;
+ *pic= 0;
+
+ if(xy) {
*itx = (signed char)PyComplex_RealAsDouble(pixel);
*ity = (signed char)PyComplex_ImagAsDouble(pixel);
}
+ if(image) {
+ char*string;
+ int size;
+ PyString_AsStringAndSize(image,&string,&size);
+ if(size<256*3) {
+ return PY_ERROR("image strings must be >= 256*3");
+ }
+ *pic = malloc(sizeof(RGBA)*16*16);
+ int t;
+ for(t=0;t<16*16;t++) {
+ (*pic)[t].r = string[t*3];
+ (*pic)[t].g = string[t*3+1];
+ (*pic)[t].b = string[t*3+2];
+ (*pic)[t].a = 255;
+ }
+ }
itx++;
ity++;
+ pic++;
}
}
TAG* t = swf_InsertTag(0, ST_VIDEOFRAME);
swf_SetU16(t,0); /* id */
- swf_SetVideoStreamMover(t, fi->stream, movex, movey, quant);
+ swf_SetVideoStreamMover(t, fi->stream, movex, movey,(void**)pics, quant);
itag->tag = t;
tagmap_addMapping(itag->tagmap, 0, self);
+ for(x=0;x<fi->stream->bbx*fi->stream->bby;x++) {
+ if(pics[x]) {
+ free(pics[x]);pics[x] = 0;
+ }
+ }
+
free(movex);
free(movey);
+ free(pics);
return tag;
}
{{"xblocks", videostream_getbwidth, METH_VARARGS, "get's the number of horizontal blocks"},
{"yblocks", videostream_getbheight, METH_VARARGS, "get's the number of vertical blocks"},
{"addFrame", (PyCFunction)videostream_addFrame, METH_KEYWORDS, "add a Video Frame"},
+ {"addBlackFrame", (PyCFunction)videostream_addBlackFrame, METH_KEYWORDS, "add a black Video Frame"},
{"addDistortionFrame", (PyCFunction)videostream_addDistortionFrame, METH_KEYWORDS, "add a MVD frame"},
{NULL, NULL, 0, NULL}
};
{"Font", (PyCFunction)f_DefineFont, METH_KEYWORDS, "Create a DefineFont Tag."},
{"Text", (PyCFunction)f_DefineText, METH_KEYWORDS, "Create a DefineText Tag."},
{"PlaceObject", (PyCFunction)f_PlaceObject, METH_KEYWORDS, "Create a PlaceObject Tag."},
+ {"RemoveObject", (PyCFunction)f_RemoveObject, METH_KEYWORDS, "Create a RemoveObject Tag."},
{"MoveObject", (PyCFunction)f_MoveObject, METH_KEYWORDS, "Create a PlaceObject Move Tag."},
{"VideoStream", (PyCFunction)f_DefineVideoStream, METH_KEYWORDS, "Create a Videostream."},
{"Image", (PyCFunction)f_DefineImage, METH_KEYWORDS, "Create an SWF Image Tag."},
register_tag(ST_PLACEOBJECT,&placeobject_tag);
register_tag(ST_PLACEOBJECT2,&placeobject_tag);
+ register_tag(ST_REMOVEOBJECT,&removeobject_tag);
+ register_tag(ST_REMOVEOBJECT2,&removeobject_tag);
register_tag(ST_SETBACKGROUNDCOLOR,&bgcolor_tag);
register_tag(ST_DEFINEFONT,&font_tag);
register_tag(ST_PROTECT,&protect_tag);