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 0489beeb9e8eb9c66e5700a6d998003440219087 (commit)
via cb9fe9ad6b062ca96ea2c4a78204290094bfa0dd (commit)
from 7c3141632bc5d4d508aa12073383ac071add934f (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/0489beeb9e8eb9c66e5700a6d99800344021…
commit 0489beeb9e8eb9c66e5700a6d998003440219087
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Mar 22 15:50:26 2013 +0100
doc: pywrap: Add brief core wrap description.
diff --git a/doc/Makefile b/doc/Makefile
index 907bebd..cb892bf 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -5,6 +5,8 @@ SOURCES=general.txt context.txt loaders.txt filters.txt basic_types.txt get_put_pixel.txt blits.txt progress_callback.txt text_api.txt event_queue.txt
+SOURCES+=core_python.txt
+
EXAMPLE_SOURCES=$(wildcard example_*.txt)
ASCIIDOC_PARAMS=--conf-file asciidoc.conf
diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf
index 4294c56..72418b7 100644
--- a/doc/asciidoc.conf
+++ b/doc/asciidoc.conf
@@ -55,6 +55,11 @@ endif::disable-javascript[]
<li><a href="backends.html">Backends</a></li>
<li><a href="input.html">Input</a></li>
</ul>
+
+ <h4>Python bindings</h4>
+ <ul>
+ <li><a href="core_python.html">Core</a></li>
+ </ul>
</div>
# Rest of the content
diff --git a/doc/core_python.txt b/doc/core_python.txt
new file mode 100644
index 0000000..57a51e6
--- /dev/null
+++ b/doc/core_python.txt
@@ -0,0 +1,143 @@
+Python Core module
+------------------
+
+The python binding maps mostly to the C API with the 'GP_' prefix stripped.
+
+Structures like 'GP_Context' are not created by the 'GP_ContextAlloc()'
+function but have proper constructor and destructor to keep the Python
+reference counting happy.
+
+There there are more complicated problems like 'GP_ProgressCallback' which
+needs a proxy function to call the python callback from the C code.
+
+Context
+~~~~~~~
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+
+ # Create 100x100 RGB888 context
+ c = core.Context(100, 100, core.C.PIXEL_RGB888)
+
+ print("w={} h={} bpp={}".format(c.w, c.h, c.bpp))
+
+-------------------------------------------------------------------------------
+
+Creates a context of a particular size and pixel type.
+
+First two parameters are 'width' and 'height' third is pixel type which is an
+enumeration
+
+May raise 'OSError' with 'ENOMEM' errno if allocation has failed.
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+
+ pixel = context.GetPixel(x, y)
+
+-------------------------------------------------------------------------------
+
+Returns a pixel value at x and y. If coordinates are outside the image zero is
+returned.
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+
+ context.PutPixel(x, y, pixel)
+
+-------------------------------------------------------------------------------
+
+Puts a pixel at specified coordinates. If coordinates are outside of the
+image nothing is done.
+
+These are basic 'Context' methods from core module. Importing other modules
+will add some other (for example gfx module adds all drawing functions).
+
+NOTE: You may want to see link:coordinate_system.html[coordinate system]
+ description.
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+
+ grayscale = context.Convert(core.C.PIXEL_G8)
+
+-------------------------------------------------------------------------------
+
+Returns context converted into the desired pixel format.
+
+The conversion is naive i.e. the values are just divided/multiplied.
+
+//TODO: link to dithering filters etc.
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+
+Blit(self, sx, sy, target, tx, ty, w=None, h=None, sx2=None, sy2=None,
+ tx2=None, ty2=None)
+
+-------------------------------------------------------------------------------
+
+Copy a rectangle from self to target. (sx,sy) and (tx,ty) define upper-left
+corners, rectangle size is given by (width, height), lower-right corner in
+source or lower-right corner in the target. Blit is clipped.
+
+Colors and Pixels
+~~~~~~~~~~~~~~~~~
+
+Pixel in gfxprim is a number large enough to store a pixel value. Pixel is
+passed as a parameter to all drawing functions.
+
+Color is a more abstract representation for example RGB triplet.
+
+There are several functions to create a pixel value for a particualr pixel
+type from color.
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+
+ # You can create a pixel from RGB and pixel type
+ black = core.RGBToPixel(0, 0, 0, core.C.PIXEL_G1)
+
+ # Or using shortcut from context
+ black = context.RGBToPixel(0, 0, 0)
+
+-------------------------------------------------------------------------------
+
+These functions creates a pixel suitable for drawing into a bitmap with
+particular pixel type.
+
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+
+ # Print all supported pixel types
+ for i in core.PixelTypes:
+ print("Pixel type '{}' size {}".format(i.name, i.size))
+
+-------------------------------------------------------------------------------
+
+The PixelTypes array stores all supported pixel types
+
+Debug Functions
+~~~~~~~~~~~~~~~
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+
+ core.GP_SetDebugLevel(10)
+
+ level = core.GP_GetDebugLevel()
+-------------------------------------------------------------------------------
+
+Sets and gets the GFXprim debug level. See link:debug.html[debug messages]
+description for more details.
+
+
http://repo.or.cz/w/gfxprim.git/commit/cb9fe9ad6b062ca96ea2c4a78204290094bf…
commit cb9fe9ad6b062ca96ea2c4a78204290094bfa0dd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Mar 22 15:49:30 2013 +0100
pywrap: common.i: Change the exception to OSError.
Which is more suitable for errno related errors.
diff --git a/pylib/gfxprim/common.i b/pylib/gfxprim/common.i
index 09dee68..e9242d7 100644
--- a/pylib/gfxprim/common.i
+++ b/pylib/gfxprim/common.i
@@ -24,7 +24,7 @@
%exception funcname {
$action
if (result == NULL)
- return PyErr_SetFromErrno(PyExc_RuntimeError);
+ return PyErr_SetFromErrno(PyExc_OSError);
}
%enddef
@@ -37,6 +37,6 @@
%exception funcname {
$action
if (result != 0)
- return PyErr_SetFromErrno(PyExc_RuntimeError);
+ return PyErr_SetFromErrno(PyExc_OSError);
}
%enddef
-----------------------------------------------------------------------
Summary of changes:
doc/Makefile | 2 +
doc/asciidoc.conf | 5 ++
doc/core_python.txt | 143 ++++++++++++++++++++++++++++++++++++++++++++++++
pylib/gfxprim/common.i | 4 +-
4 files changed, 152 insertions(+), 2 deletions(-)
create mode 100644 doc/core_python.txt
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 d5c09d5b8cd72e73f0e0df4110a3981f943d44f9 (commit)
from 81cfb3c3c3d08268a25747d38e05274c8b335300 (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/d5c09d5b8cd72e73f0e0df4110a3981f943d…
commit d5c09d5b8cd72e73f0e0df4110a3981f943d44f9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Mar 19 23:36:12 2013 +0100
pywrap: backends: The Wait and Poll returns events directly.
diff --git a/demos/py_simple/showimage.py b/demos/py_simple/showimage.py
index b952078..c61f5ff 100755
--- a/demos/py_simple/showimage.py
+++ b/demos/py_simple/showimage.py
@@ -14,15 +14,16 @@ def main():
# Load Image
img = loaders.Load(sys.argv[1])
-
+
+ # Create X11 window
bk = backends.BackendX11Init(None, 0, 0, img.w, img.h, sys.argv[1], 0)
assert(bk)
img.Blit(0, 0, bk.context, 0, 0, img.w, img.h)
bk.Flip()
+ # Event loop
while True:
- bk.Wait()
- ev = bk.GetEvent()
+ ev = bk.Wait()
input.EventDump(ev)
diff --git a/pylib/gfxprim/backends/_extend_backend.py b/pylib/gfxprim/backends/_extend_backend.py
index 97975a7..53e1700 100644
--- a/pylib/gfxprim/backends/_extend_backend.py
+++ b/pylib/gfxprim/backends/_extend_backend.py
@@ -27,12 +27,32 @@ def extend_backend(_backend):
@extend(_backend)
def Poll(self):
"Poll the backend for events."
- return c_backends.GP_BackendPoll(self)
+ ev = c_input.GP_Event();
+
+ if c_backends.GP_BackendGetEvent(self, ev) != 0:
+ return ev
+
+ c_backends.GP_BackendPoll(self)
+
+ if c_backends.GP_BackendGetEvent(self, ev) != 0:
+ return ev
+
+ return None
@extend(_backend)
def Wait(self):
"Waits for backend event"
- return c_backends.GP_BackendWait(self)
+ ev = c_input.GP_Event();
+
+ if c_backends.GP_BackendGetEvent(self, ev) != 0:
+ return ev
+
+ while c_backends.GP_BackendGetEvent(self, ev) == 0:
+ c_backends.GP_BackendWait(self)
+
+ c_backends.GP_BackendGetEvent(self, ev)
+
+ return ev
@extend(_backend)
def SetCaption(self, caption):
@@ -43,13 +63,3 @@ def extend_backend(_backend):
def Resize(self, w, h):
"Resize backend window (if possible)"
return c_backends.GP_BackendResize(self, w, h)
-
- @extend(_backend)
- def GetEvent(self):
- "Removes and returns event from the top of the event queue"
- if c_backends.GP_BackendEventsQueued(self) == 0:
- return None
- ev = c_input.GP_Event();
- if c_backends.GP_BackendGetEvent(self, ev) != 0:
- return ev
- return None
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/showimage.py | 7 +++--
pylib/gfxprim/backends/_extend_backend.py | 34 ++++++++++++++++++----------
2 files changed, 26 insertions(+), 15 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 c2fc7bc18f5c8ca729525abee47967930485ddd4 (commit)
via 1adb8662a402c4cf4bc0ea41feb1ba33dc49bfc9 (commit)
via dde06dd8f774cd24f2febdf6842631691b6733ac (commit)
from ff67d6e17905d01934074321a4a0136027dae253 (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/c2fc7bc18f5c8ca729525abee47967930485…
commit c2fc7bc18f5c8ca729525abee47967930485ddd4
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Mar 19 21:35:33 2013 +0100
demos: py_simple: Fix dither.py
diff --git a/demos/py_simple/dither.py b/demos/py_simple/dither.py
index dae8838..470d601 100755
--- a/demos/py_simple/dither.py
+++ b/demos/py_simple/dither.py
@@ -11,7 +11,7 @@ def main():
sys.exit(1)
# Load Image
- img = loaders.LoadImage(sys.argv[1], None)
+ img = loaders.Load(sys.argv[1])
# Use Floyd-Steinberg dithering
res = filters.FilterFloydSteinberg_RGB888_Alloc(img, core.C.PIXEL_G1, None)
# Save result into grayscale png
http://repo.or.cz/w/gfxprim.git/commit/1adb8662a402c4cf4bc0ea41feb1ba33dc49…
commit 1adb8662a402c4cf4bc0ea41feb1ba33dc49bfc9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Mar 19 21:34:37 2013 +0100
demos: py_simple: Fix blur.py
diff --git a/demos/py_simple/blur.py b/demos/py_simple/blur.py
index 36d9c5b..478af96 100755
--- a/demos/py_simple/blur.py
+++ b/demos/py_simple/blur.py
@@ -13,7 +13,7 @@ def main():
radii = float(sys.argv[1])
# Load Image
- img = loaders.LoadImage(sys.argv[2], None)
+ img = loaders.Load(sys.argv[2])
# Do in-place gaussian blur
filters.FilterGaussianBlur(img, img, radii, radii, None)
# Save result
http://repo.or.cz/w/gfxprim.git/commit/dde06dd8f774cd24f2febdf6842631691b67…
commit dde06dd8f774cd24f2febdf6842631691b6733ac
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Mar 19 21:29:08 2013 +0100
pywrap: filters: Add non-alloc filter variants too.
diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py
index ae3988c..32b2efd 100644
--- a/pylib/gfxprim/filters/__init__.py
+++ b/pylib/gfxprim/filters/__init__.py
@@ -13,6 +13,7 @@ def _init(module):
import_members(c_filters, module, sub=strip_GP,
include=[
'^GP_Filter.*Alloc',
+ '^GP_Filter[A-Za-z0-9]*$',
])
_init(locals())
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/blur.py | 2 +-
demos/py_simple/dither.py | 2 +-
pylib/gfxprim/filters/__init__.py | 1 +
3 files changed, 3 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 e434f9d04602003a5e0c858acc5189cac9297e36 (commit)
from ad60769920b2f3ba4ed23b13cd7973b018ebc711 (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/e434f9d04602003a5e0c858acc5189cac929…
commit e434f9d04602003a5e0c858acc5189cac9297e36
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Mar 19 20:13:43 2013 +0100
build: configure: Pick config values from env variables.
This allows us to use clang static analysis.
diff --git a/configure b/configure
index 8704716..fed17b4 100755
--- a/configure
+++ b/configure
@@ -301,7 +301,12 @@ if __name__ == '__main__':
"Checking for backtrace() ... "], "", "", ["core"]]], cfg)
parser = OptionParser();
-
+
+ # Get configuration parameters from environment variables
+ for i in cfg:
+ if i in os.environ:
+ cfg[i][0] = os.environ[i]
+
# Enable disable libraries for linking
parser.add_option("-e", "--enable", dest="enable", action="append",
help="force enable library linking", metavar="libfoo")
-----------------------------------------------------------------------
Summary of changes:
configure | 7 ++++++-
1 files changed, 6 insertions(+), 1 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.")