X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpython%2Ftags.c;h=0ff6b329e701d78dffe9780c13744cb8ecd430d8;hb=d0c255a3b63de4982e15f1c1c169ebdb08d4163c;hp=f28f1b667b9134f0ef220b1c9d834bd8c5cc01a3;hpb=459a2fa9fdbd9f8e41d5911e2aafce21c0fc7225;p=swftools.git diff --git a/lib/python/tags.c b/lib/python/tags.c index f28f1b6..0ff6b32 100644 --- a/lib/python/tags.c +++ b/lib/python/tags.c @@ -5,6 +5,7 @@ #include "tag.h" #include "tags.h" #include "image.h" +#include "../png.h" //---------------------------------------------------------------------------- @@ -185,7 +186,7 @@ static PyObject* po_create(PyObject* self, PyObject* args, PyObject* kwargs,char po->depth = depth; po->clipdepth = clipdepth; po->ratio = ratio; - po->name = name; + po->name = (unsigned char*)name; po->move = move; if(clipdepth) po->clipdepth = clipdepth; if(matrix) po->matrix = matrix_getMatrix(matrix); @@ -624,6 +625,28 @@ static PyObject* image_getattr(tag_internals_t*self,char*a) } return 0; } + +static PyObject* image_save(PyObject*self, PyObject*args) +{ + tag_internals_t*itag = tag_getinternals(self); + if(!image_parse(itag)) + return PY_ERROR("Couldn't parse image"); + image_internal_t*fi = (image_internal_t*)itag->data; + + char*filename = 0; + if(!PyArg_ParseTuple(args, "s", &filename)) + return NULL; + + writePNG(filename, (unsigned char*)fi->rgba ,fi->width, fi->height); + + return PY_NONE; +} + +static PyMethodDef image_methods[] = +{{"save", image_save, METH_VARARGS, "saves an image as PNG"}, + {NULL, NULL, 0, NULL} +}; + static tag_internals_t image_tag = { parse: image_parse, @@ -631,7 +654,7 @@ static tag_internals_t image_tag = dealloc: image_dealloc, getattr: image_getattr, setattr: 0, - tagfunctions: 0, + tagfunctions: image_methods, datasize: sizeof(image_internal_t), }; //----------------------------------------------------------------------------