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/0489beeb9e8eb9c66e5700a6d998003440219...
commit 0489beeb9e8eb9c66e5700a6d998003440219087 Author: Cyril Hrubis metan@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/cb9fe9ad6b062ca96ea2c4a78204290094bfa...
commit cb9fe9ad6b062ca96ea2c4a78204290094bfa0dd Author: Cyril Hrubis metan@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@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.