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 5cdba1dbc960776f21bdd7e9a07a4546ad918ea3 (commit)
via 86f0ef66d88f47ebb9ac8b9a1a30a83e3b449d2b (commit)
from eb0fe417461ded37e79ffa76e90cedf1b39af555 (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/5cdba1dbc960776f21bdd7e9a07a4546ad91…
commit 5cdba1dbc960776f21bdd7e9a07a4546ad918ea3
Merge: 86f0ef6 eb0fe41
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 23:31:25 2011 +0100
Merge branch 'master' of git://repo.or.cz/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/86f0ef66d88f47ebb9ac8b9a1a30a83e3b44…
commit 86f0ef66d88f47ebb9ac8b9a1a30a83e3b449d2b
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 23:24:11 2011 +0100
Fix GP_ContextConvert
... a little, still not ideal, but IMO not worth it
diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c
index 7079901..73e926e 100644
--- a/libs/core/GP_Context.c
+++ b/libs/core/GP_Context.c
@@ -110,11 +110,13 @@ GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type)
GP_Context *GP_ContextConvert(const GP_Context *src,
GP_PixelType dst_pixel_type)
{
- GP_Context *ret = GP_ContextAlloc(src->w, src->h, dst_pixel_type);
+ int w = GP_ContextW(src);
+ int h = GP_ContextH(src);
+ GP_Context *ret = GP_ContextAlloc(w, h, dst_pixel_type);
if (ret == NULL)
return NULL;
- GP_Blit_Naive(src, 0, 0, src->w, src->h, ret, 0, 0);
+ GP_Blit(src, 0, 0, w, h, ret, 0, 0);
return ret;
}
-----------------------------------------------------------------------
Summary of changes:
libs/core/GP_Context.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 eb0fe417461ded37e79ffa76e90cedf1b39af555 (commit)
from cc5f16de4ff693a60f55a5b335367b3a8ffd3a40 (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/eb0fe417461ded37e79ffa76e90cedf1b39a…
commit eb0fe417461ded37e79ffa76e90cedf1b39af555
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 26 23:23:35 2011 +0100
fbshow: Switch to bicubic integer implementation.
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c
index 4510312..3943ffc 100644
--- a/demos/fbshow/fbshow.c
+++ b/demos/fbshow/fbshow.c
@@ -155,12 +155,12 @@ static void *image_loader(void *ptr)
GP_Context *ret;
- callback.priv = "Blurring Image";
- if (GP_FilterGaussianBlur(img, img, 0.3/rat, 0.3/rat, &callback) == NULL)
- return NULL;
+// callback.priv = "Blurring Image";
+// if (GP_FilterGaussianBlur(img, img, 0.3/rat, 0.3/rat, &callback) == NULL)
+// return NULL;
callback.priv = "Resampling Image";
- ret = GP_FilterResize(img, NULL, GP_INTERP_CUBIC, img->w * rat, img->h * rat, &callback);
+ ret = GP_FilterResize(img, NULL, GP_INTERP_CUBIC_INT, img->w * rat, img->h * rat, &callback);
GP_ContextFree(img);
if (ret == NULL)
-----------------------------------------------------------------------
Summary of changes:
demos/fbshow/fbshow.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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, pywrap has been updated
via d028c5b88bfbe818f650dac41671b7dc74fab584 (commit)
via 133b310ce8ca4adc61f14648dee634a00d5cf077 (commit)
via 75272ddef49127d165aa2e041fcb49f5bdf437dd (commit)
via 3428c6433249fc771dc355438cd47d7d3abfd70d (commit)
via 116c09aa2a1efd689e4c2a66ad11d55988374983 (commit)
from 9fb8ec2881f24724d6fe71bbfecb7524e95053a7 (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/d028c5b88bfbe818f650dac41671b7dc74fa…
commit d028c5b88bfbe818f650dac41671b7dc74fab584
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 20:28:53 2011 +0100
Update and move GP_Context wrapper docstring
diff --git a/include/core/gfxprim_core.swig b/include/core/gfxprim_core.swig
index 366067c..4cdb160 100644
--- a/include/core/gfxprim_core.swig
+++ b/include/core/gfxprim_core.swig
@@ -44,12 +44,10 @@
/*
- * Context manipulation
+ * GP_Context wrapping
*/
-/* Rename accestors to GP_Context attributes to _attribute */
-/* would work in swig 2.0:
- * %rename("_%s", regexmatch$name="^GP_Context::") ""; */
+/* Rename accesors to GP_Context attributes to "_attribute" */
%rename("_%s") "GP_Context::pixels";
%rename("_%s") "GP_Context::bpp";
%rename("_%s") "GP_Context::bytes_per_row";
@@ -62,8 +60,26 @@
%rename("_%s") "GP_Context::y_swap";
%rename("_%s") "GP_Context::bit_endian";
%rename("_%s") "GP_Context::free_pixels";
+/* This nice batch would work in swig 2.0, sigh:
+ * %rename("_%s", regexmatch$name="^GP_Context::") ""; */
+
%rename("Context") "GP_Context";
+%feature("autodoc", "Proxy of C GP_Context struct
+
+You can pass this class to wrapped GP_DrawSomething(...) as GP_Context.
+All attributes of GP_Context are accessible directly as _attribute
+(self._w etc.), but it is reccomended to use redefined properties:
+
+self.w: Context width (transformed)
+self.h: Context width (transformed)
+
+Some context-related methods are provided as class members for convenience.
+
+GP_Context memory allocation is handled by gfxprim, deallocation by GP_ContextFree().
+The wrapper can be used without owning the GP_Context struct by setting self.this
+and self.thisown.") GP_Context;
+
%include "GP_Context.h"
%extend GP_Context {
@@ -74,6 +90,11 @@
}
};
+
+/*
+ * Context manipulation
+ */
+
%include "GP_GetPutPixel.h"
%import "GP_GetPutPixel.gen.h"
%include "GP_WritePixel.h"
diff --git a/pylib/context.py b/pylib/context.py
index 32ed123..1837b23 100644
--- a/pylib/context.py
+++ b/pylib/context.py
@@ -33,23 +33,7 @@ def extend_context_class(_context_class = core.Context):
Called on module inicialization.
"""
- type.__setattr__(_context_class, "__doc_2__",
- """Proxy of C GP_Context struct
-
- You can pass this class to wrapped GP_DrawSomething(...) as GP_Context.
- All attributes of GP_Context are accessible directly as "_attribute"
- (self._w etc.), but it is reccomended to use redefined properties:
-
- self.w: Context width (transformed)
- self.h: Context width (transformed)
-
- Some context methods are provided as class members for convenience.
-
- GP_Context memory allocation is handled completely by gfxprim.
- You shoud NEVER even think about self.this - this pointer will point to
- free memory after self.__del__ is called (in case of owned GP_Context).
- """)
-
+ # Add "parent" attribute
extend(_context_class, name='parent')(None)
@extend(_context_class, name='__str__')
http://repo.or.cz/w/gfxprim.git/commit/133b310ce8ca4adc61f14648dee634a00d5c…
commit 133b310ce8ca4adc61f14648dee634a00d5cf077
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 20:04:12 2011 +0100
Complete rewrite of the wrapper class
Now extending the SWIG wrapper instead of delegation
Decorating tools
TODO: set docstring correctly
diff --git a/pylib/context.py b/pylib/context.py
index 1551c5c..32ed123 100644
--- a/pylib/context.py
+++ b/pylib/context.py
@@ -1,58 +1,84 @@
import gfxprim_core_c as core
import gfxprim_loaders_c as loaders
-class Context(object):
- def __init__(self, context, owns_GP_Context, parent=None):
- """Create new GP_Context wrapper.
+def extend(cls, name=None):
+ def decf(method):
+ funname = name
+ if not funname:
+ funname = method.__name__
+ type.__setattr__(cls, funname, method)
+ return method
+ return decf
- The wrapper is just a (read-only) proxy with
- some conveniently mapped context methods.
- Direct access is possible through self.context.
- """
- # GP_Context struct (pre-wrapped by SWIG)
- self.context = context
- # call GP_ContextFree on del?
- self.owns_GP_Context = owns_GP_Context
- # Parent Context of a subcontext (if any)
- # It is important to hold a ref to parent because of GC
- self.parent = parent
-
- def __del__(self):
- print "Deleting %s (owns_GP_Context: %s)" % (self, self.owns_GP_Context)
- if self.owns_GP_Context:
- core.GP_ContextFree(self.context)
-
- @property
- def w(self):
- "Context width (transformed)"
- return core.GP_ContextW(self.context)
+def add_swig_getmethod(cls, name=None):
+ def decf(method):
+ propname = name
+ if not propname:
+ propname = method.__name__
+ cls.__swig_getmethods__[propname] = method
+ return decf
- @property
- def h(self):
- "Context height (transformed)"
- return core.GP_ContextH(self.context)
+def add_swig_setmethod(cls, name=None):
+ def decf(method):
+ propname = name
+ if not propname:
+ propname = method.__name__
+ cls.__swig_setmethods__[propname] = method
+ return decf
+
+
+def extend_context_class(_context_class = core.Context):
+ """
+ Extends _context_class class with convenience methods.
+ Called on module inicialization.
+ """
+
+ type.__setattr__(_context_class, "__doc_2__",
+ """Proxy of C GP_Context struct
+
+ You can pass this class to wrapped GP_DrawSomething(...) as GP_Context.
+ All attributes of GP_Context are accessible directly as "_attribute"
+ (self._w etc.), but it is reccomended to use redefined properties:
+
+ self.w: Context width (transformed)
+ self.h: Context width (transformed)
+
+ Some context methods are provided as class members for convenience.
- @property
- def bpp(self):
- "Context bpp"
- return self.context.bpp
+ GP_Context memory allocation is handled completely by gfxprim.
+ You shoud NEVER even think about self.this - this pointer will point to
+ free memory after self.__del__ is called (in case of owned GP_Context).
+ """)
- def __str__(self):
+ extend(_context_class, name='parent')(None)
+
+ @extend(_context_class, name='__str__')
+ @extend(_context_class, name='__repr__')
+ def context_str(self):
return "<Context %dx%d, %dbpp, GP_Context %sowned, %s parent>" % (
- self.w, self.h, self.bpp,
- "" if self.owns_GP_Context else "not ",
- "with" if self.parent else "no")
- __repr__ = __str__
+ self.w, self.h, self._bpp,
+ "" if self.thisown else "not ",
+ "with" if self.parent else "no")
+
+ @add_swig_getmethod(_context_class)
+ def w(self):
+ return core.GP_ContextW(self)
+
+ @add_swig_getmethod(_context_class)
+ def h(self):
+ return core.GP_ContextH(self)
+ @extend(_context_class)
def subcontext(self, x, y, w, h):
"Create a subcontext (rectangular view)."
- c = core.GP_ContextSubContext(self.context, None, x, y, w, h)
- if not c:
- raise Exception("Error creating subcontext")
- return type(self)(c, owns_GP_Context=True, parent=self)
+ c = core.GP_ContextSubContext(self, None, x, y, w, h)
+ c.thisown = True # GP_Context IS owned (but not the pixel data)
+ c.parent = self
+ return c
+ @extend(_context_class)
def save(self, filename, format=None):
- """Save the image in given format (or guess by the extension)
+ """Save the image in given format (or guess it from the extension)
Currently, JPG, PNG and P[BGP]M are supported, but not for all
context pixel types.
@@ -61,34 +87,40 @@ class Context(object):
format = filename.rsplit('.', 1)[-1]
format = format.lower()
if format == 'jpg':
- res = loaders.GP_SaveJPG(filename, self.context, None)
+ res = loaders.GP_SaveJPG(filename, self, None)
elif format == 'png':
- res = loaders.GP_SavePNG(filename, self.context, None)
+ res = loaders.GP_SavePNG(filename, self, None)
elif format == 'pbm':
- res = loaders.GP_SavePBM(filename, self.context, None)
+ res = loaders.GP_SavePBM(filename, self, None)
elif format == 'pgm':
- res = loaders.GP_SavePGM(filename, self.context, None)
+ res = loaders.GP_SavePGM(filename, self, None)
elif format == 'ppm':
- res = loaders.GP_SavePPM(filename, self.context, None)
+ res = loaders.GP_SavePPM(filename, self, None)
else:
raise Exception("Format %r not supported.", format)
if res != 0:
raise Exception("Error saving %r (code %d)", filename, res)
- @classmethod
- def create(cls, w, h, pixeltype):
+ @extend(_context_class, name='create')
+ @staticmethod
+ def create(w, h, pixeltype):
"Allocate a new w*h bitmap of given type."
pixeltype_no = pixeltype if isinstance(pixeltype, int) else 0 # !!!
# TODO: actually accept a PixelType
c = core.GP_ContextAlloc(w, h, pixeltype_no)
- return cls(c, owns_GP_Context=True)
+ c.thisown = True
+ return c
- @classmethod
- def load(cls, filename):
+ @extend(_context_class, name='load')
+ @staticmethod
+ def load(filename):
"Load image from given file, guess type."
c = loaders.GP_LoadImage_SWIG(filename)
- if not c:
- raise Exception("Error loading %r", filename)
- return cls(c, owns_GP_Context=True)
+ c.thisown = True
+ return c
+
+
+
+extend_context_class()
http://repo.or.cz/w/gfxprim.git/commit/75272ddef49127d165aa2e041fcb49f5bdf4…
commit 75272ddef49127d165aa2e041fcb49f5bdf437dd
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 20:02:11 2011 +0100
Prepare for (more) direct wrapping of GP_Context
Add autodoc feature
Rename attributes to "_*"
Set GP_Context destructor
diff --git a/include/core/gfxprim_core.swig b/include/core/gfxprim_core.swig
index e9d68d1..366067c 100644
--- a/include/core/gfxprim_core.swig
+++ b/include/core/gfxprim_core.swig
@@ -8,6 +8,8 @@
%include <stdint.i>
+%feature("autodoc");
+
%nodefaultctor;
/*
@@ -45,8 +47,33 @@
* Context manipulation
*/
+/* Rename accestors to GP_Context attributes to _attribute */
+/* would work in swig 2.0:
+ * %rename("_%s", regexmatch$name="^GP_Context::") ""; */
+%rename("_%s") "GP_Context::pixels";
+%rename("_%s") "GP_Context::bpp";
+%rename("_%s") "GP_Context::bytes_per_row";
+%rename("_%s") "GP_Context::w";
+%rename("_%s") "GP_Context::h";
+%rename("_%s") "GP_Context::offset";
+%rename("_%s") "GP_Context::pixel_type";
+%rename("_%s") "GP_Context::axes_swap";
+%rename("_%s") "GP_Context::x_swap";
+%rename("_%s") "GP_Context::y_swap";
+%rename("_%s") "GP_Context::bit_endian";
+%rename("_%s") "GP_Context::free_pixels";
+%rename("Context") "GP_Context";
+
%include "GP_Context.h"
+%extend GP_Context {
+ ~GP_Context() {
+ GP_DEBUG(2, "[wrapper] GP_ContextFree (%dx%d raw, %dbpp, free_pixels:%d)",
+ $self->w, $self->h, $self->bpp, $self->free_pixels);
+ GP_ContextFree($self);
+ }
+};
+
%include "GP_GetPutPixel.h"
%import "GP_GetPutPixel.gen.h"
%include "GP_WritePixel.h"
http://repo.or.cz/w/gfxprim.git/commit/3428c6433249fc771dc355438cd47d7d3abf…
commit 3428c6433249fc771dc355438cd47d7d3abfd70d
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 10:39:00 2011 +0100
core SWIG cleanup, removed some internals
diff --git a/include/core/gfxprim_core.swig b/include/core/gfxprim_core.swig
index 2a96a71..e9d68d1 100644
--- a/include/core/gfxprim_core.swig
+++ b/include/core/gfxprim_core.swig
@@ -10,7 +10,9 @@
%nodefaultctor;
-/* Basic types and common methods */
+/*
+ * Basic types and common methods
+ */
%include "GP_Common.h"
%include "GP_Core.h"
@@ -23,23 +25,31 @@
%include "GP_ProgressCallback.h"
%include "GP_RetCode.h"
-/* Color and pixel types */
+
+/*
+ * Color and pixel types
+ */
%include "GP_Color.h"
-%include "GP_Context.h"
%include "GP_Pixel.h"
-%include "GP_Pixel.gen.h"
+%include "GP_Pixel.gen.h" /* Includes enum GP_PixelType definition */
%include "GP_Convert.h"
-%include "GP_Convert.gen.h"
-%include "GP_Convert_Scale.gen.h"
-%include "GP_Blit.gen.h"
+%import "GP_Convert.gen.h"
+%import "GP_Convert_Scale.gen.h"
+
+%import "GP_FnPerBpp.h"
+%import "GP_FnPerBpp.gen.h"
+
-/* Context manipulation */
+/*
+ * Context manipulation
+ */
%include "GP_Context.h"
-%include "GP_Blit.h"
-%include "GP_Blit.gen.h"
-%include "GP_FnPerBpp.h"
+
%include "GP_GetPutPixel.h"
+%import "GP_GetPutPixel.gen.h"
%include "GP_WritePixel.h"
+%include "GP_Blit.h"
+%import "GP_Blit.gen.h"
http://repo.or.cz/w/gfxprim.git/commit/116c09aa2a1efd689e4c2a66ad11d5598837…
commit 116c09aa2a1efd689e4c2a66ad11d55988374983
Author: Tomas Gavenciak <gavento(a)ucw.cz>
Date: Sat Nov 26 10:37:44 2011 +0100
Add GP_WritePixels.h to GP_Core.h
diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h
index 70c2c3f..93ce52b 100644
--- a/include/core/GP_Core.h
+++ b/include/core/GP_Core.h
@@ -50,7 +50,10 @@
/* Individual pixel access */
#include "core/GP_GetPutPixel.h"
-/* blitting */
+/* Writing pixel blocks */
+#include "GP_WritePixel.h"
+
+/* Blitting */
#include "core/GP_Blit.h"
/* Debug and debug level */
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Core.h | 5 +-
include/core/gfxprim_core.swig | 80 ++++++++++++++++++++++----
pylib/context.py | 126 ++++++++++++++++++++++-----------------
3 files changed, 144 insertions(+), 67 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")