This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via acc0e486f8637754ffdc19b5c0bd463d1317841d (commit) from 2a5a7b89fa7ccb27b25011cc0d1c7456832db0b0 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/acc0e486f8637754ffdc19b5c0bd463d13178...
commit acc0e486f8637754ffdc19b5c0bd463d1317841d Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 28 23:40:22 2013 +0100
pywrap: core: Add ToByteArray() context method.
This allows us to pass the context pixel data to various python libraries (such as PySide).
The downside is that data are being coiped to newly allocated ByteArray. I would love to see a native buffer implementation for GP_Context however I doubt that we can easily fill out the PyTypeObject field tp_as_buffer in swig without doing unspeakable things.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py index 00bba2a..96bf9be 100644 --- a/pylib/gfxprim/core/__init__.py +++ b/pylib/gfxprim/core/__init__.py @@ -99,6 +99,12 @@ def _init(module): See GP_ContextConvertAlloc() for details.""" return c_core.GP_ContextConvertAlloc(self, pixeltype_no(target_type))
+ @extend(_context) + def ToByteArray(self): + """Returns new Python ByteArray created from context pixels. The + array size is exactly context.bytes_per_row * context.h""" + return c_core.GP_ContextToByteArray(self) + # Manipulation
extend_direct(_context, "PutPixel", c_core.GP_PutPixel, diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i index 88f9450..59b17e8 100644 --- a/pylib/gfxprim/core/core.i +++ b/pylib/gfxprim/core/core.i @@ -70,6 +70,13 @@ const GP_PixelTypeDescription *GP_PixelTypes_access(GP_PixelType no) %rename("_%s") "GP_Context::bit_endian"; %rename("_%s") "GP_Context::free_pixels";
+%inline %{ +PyObject *GP_ContextToByteArray(GP_Context *self) +{ + return PyByteArray_FromStringAndSize((char*)self->pixels, + self->bytes_per_row * self->h); +} +%}
%feature("autodoc", "Proxy of C GP_Context struct
-----------------------------------------------------------------------
Summary of changes: pylib/gfxprim/core/__init__.py | 6 ++++++ pylib/gfxprim/core/core.i | 7 +++++++ 2 files changed, 13 insertions(+), 0 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.