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 439dd5a9d066e953868fb93356a8b48e362ef7c2 (commit) via d99b07df27d20a4e1ac3b076d85bc93944da2ace (commit) via a419617bbc0c241562487bd5c9657d4afaefe212 (commit) from 4a5f6e9c0502172948711721b8b455f0a0d0baec (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/439dd5a9d066e953868fb93356a8b48e362ef...
commit 439dd5a9d066e953868fb93356a8b48e362ef7c2 Author: Cyril Hrubis metan@ucw.cz Date: Sun Apr 7 11:55:08 2013 +0200
loaders: PNG: Fix errno propagation.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c index 3ed5161..42cfa23 100644 --- a/libs/loaders/GP_BMP.c +++ b/libs/loaders/GP_BMP.c @@ -618,3 +618,22 @@ GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback)
return GP_ReadBMP(f, callback); } + + + +int GP_SaveBMP(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback) +{ + FILE *f; + + switch (src->pixel_type) { + case GP_PIXEL_RGB888: + + break; + default: + errno = ENOSYS; + return 1; + } + + GP_DEBUG(1, "Saving PNG Image '%s'", dst_path); + +} diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index 1c11d54..b1b725d 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -504,7 +504,8 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path, if (prepare_png_header(src, NULL, NULL, NULL)) { GP_DEBUG(1, "Can't save png with %s pixel type", GP_PixelTypeName(src->pixel_type)); - return ENOSYS; + err = ENOSYS; + goto err0; }
f = fopen(dst_path, "wb");
http://repo.or.cz/w/gfxprim.git/commit/d99b07df27d20a4e1ac3b076d85bc93944da2...
commit d99b07df27d20a4e1ac3b076d85bc93944da2ace Author: Cyril Hrubis metan@ucw.cz Date: Sun Apr 7 11:51:10 2013 +0200
tests: loaders: Add basic tests for SavePNG().
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/loaders/PNG.c b/tests/loaders/PNG.c index ad9381e..fce0193 100644 --- a/tests/loaders/PNG.c +++ b/tests/loaders/PNG.c @@ -33,6 +33,8 @@ static int test_load_PNG(const char *path) { GP_Context *img;
+ errno = 0; + img = GP_LoadPNG(path, NULL);
if (img == NULL) { @@ -55,46 +57,114 @@ static int test_load_PNG(const char *path) return TST_SUCCESS; }
+static int test_save_PNG(GP_PixelType pixel_type) +{ + GP_Context *ctx; + int ret; + + ctx = GP_ContextAlloc(100, 100, pixel_type); + + if (ctx == NULL) { + tst_msg("Failed to allocate context"); + return TST_UNTESTED; + } + + errno = 0; + + ret = GP_SavePNG(ctx, "/dev/null", NULL); + + if (ret == 0) { + tst_msg("Saved successfully"); + GP_ContextFree(ctx); + return TST_SUCCESS; + } + + switch (errno) { + case ENOSYS: + tst_msg("Not Implemented"); + GP_ContextFree(ctx); + return TST_SUCCESS; + default: + tst_msg("Failed and errno is not ENOSYS (%i)", errno); + GP_ContextFree(ctx); + return TST_FAILED; + } +} + const struct tst_suite tst_suite = { .suite_name = "PNG", .tests = { /* PNG loader tests */ - {.name = "PNG 100x100 RGB", + {.name = "PNG Load 100x100 RGB", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-red.png", .data = "100x100-red.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - {.name = "PNG 100x100 RGB 50% alpha", + {.name = "PNG Load 100x100 RGB 50% alpha", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-red-alpha.png", .data = "100x100-red-alpha.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - {.name = "PNG 100x100 8 bit Grayscale", + {.name = "PNG Load 100x100 8 bit Grayscale", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-black-grayscale.png", .data = "100x100-black-grayscale.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - {.name = "PNG 100x100 8 bit Grayscale + alpha", + {.name = "PNG Load 100x100 8 bit Grayscale + alpha", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-black-grayscale-alpha.png", .data = "100x100-black-grayscale-alpha.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - {.name = "PNG 100x100 Palette + alpha", + {.name = "PNG Load 100x100 Palette + alpha", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-palette-alpha.png", .data = "100x100-palette-alpha.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - {.name = "PNG 100x100 Palette", + {.name = "PNG Load 100x100 Palette", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-red-palette.png", .data = "100x100-red-palette.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + + {.name = "PNG Save 100x100 G1", + .tst_fn = test_save_PNG, + .data = (void*)GP_PIXEL_G1, + .flags = TST_CHECK_MALLOC}, + + {.name = "PNG Save 100x100 G2", + .tst_fn = test_save_PNG, + .data = (void*)GP_PIXEL_G2, + .flags = TST_CHECK_MALLOC}, + + {.name = "PNG Save 100x100 G4", + .tst_fn = test_save_PNG, + .data = (void*)GP_PIXEL_G4, + .flags = TST_CHECK_MALLOC}, + + {.name = "PNG Save 100x100 G8", + .tst_fn = test_save_PNG, + .data = (void*)GP_PIXEL_G8, + .flags = TST_CHECK_MALLOC}, + + {.name = "PNG Save 100x100 RGB888", + .tst_fn = test_save_PNG, + .data = (void*)GP_PIXEL_RGB888, + .flags = TST_CHECK_MALLOC}, + + {.name = "PNG Save 100x100 BGR888", + .tst_fn = test_save_PNG, + .data = (void*)GP_PIXEL_BGR888, + .flags = TST_CHECK_MALLOC},
+ {.name = "PNG Save 100x100 G16", + .tst_fn = test_save_PNG, + .data = (void*)GP_PIXEL_G16, + .flags = TST_CHECK_MALLOC}, {.name = NULL}, } };
http://repo.or.cz/w/gfxprim.git/commit/a419617bbc0c241562487bd5c9657d4afaefe...
commit a419617bbc0c241562487bd5c9657d4afaefe212 Author: Cyril Hrubis metan@ucw.cz Date: Sun Apr 7 11:20:32 2013 +0200
doc: More work on the python backends docs.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/backends_python.txt b/doc/backends_python.txt index e2b9096..32d5d9f 100644 --- a/doc/backends_python.txt +++ b/doc/backends_python.txt @@ -13,6 +13,10 @@ structure provides unified API for controlling the drawing. There is however generic backend initialization function that takes a string as a parameter that may contain backend-specific settings.
+ +BackendX11Init +^^^^^^^^^^^^^^ + [source,python] ------------------------------------------------------------------------------- import gfxprim.backends as backends @@ -33,6 +37,16 @@ The 'x', 'y', 'w' and 'h' parameters describe the window geometry. The 'x' and
The last parameter are bitflags. TODO: Export bitflags and add a list here.
+This backends supports multiple windows. Each time you call the initialization +routine new backend structure is returned. All backend instances share the Xlib +connection so you need to wait or poll only on one of them. Each backend, on +the other hand, has its own input queue. + +TIP: See multiple windows link:example_py_x11_windows.html[example]. + + +BackendInit +^^^^^^^^^^^
[source,python] ------------------------------------------------------------------------------- @@ -53,3 +67,65 @@ import gfxprim.backends as backends Initialize the backend params by the 'backend_string'. The last parameter is a file to print help or errors to.
+TIP: See backend init link:example_py_backends.html[example]. + +Backend +^^^^^^^ + +Initialized backend has several members that allows you to draw on the screen +and control the backend behavior. + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.gfx as gfx +import gfxprim.backends as backends + + # Initialize backend + bk = backends.BackendInit("X11:100x100", "Window title", stderr) + + # Assert that inicialization was successful + assert(bk) + + # Now you can draw into the backend via bk.context + bk.context.gfx.Fill(bk.context.RGBToPixel(0, 0, 0)); + + # If backend is buffered, changes are not propagated unless the screen is + # updated via Flip() or UpdateRect() + bk.Flip() + +------------------------------------------------------------------------------- + +There are several functions to get input events such as keystrokes or pointer +movements. + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.input as input +import gfxprim.backends as backends + + + # Initialize backend + bk = backends.BackendInit("X11:100x100", "Window title", stderr) + + # Assert that inicialization was successful + assert(bk) + + # Now we can either poll for events via PollEvent() or wait via WaitEvent() + while True: + ev = WaitEvent(); + + if (ev.type == input.EV_KEY and ev.val.val == input.KEY_ESC): + sys.exit(0) + elif (ev.type == input.EV_SYS): + if (ev.code == input.EV_SYS_QUIT): + sys.exit(0) + if (ev.code == input.EV_SYS_RESIZE): + bk.ResizeAck() + redraw(bk) + +------------------------------------------------------------------------------- + + +TIP: See the complete link:example_py_backends.html[example]. diff --git a/doc/example_py_backends.txt b/doc/example_py_backends.txt new file mode 100644 index 0000000..625084c --- /dev/null +++ b/doc/example_py_backends.txt @@ -0,0 +1,8 @@ +Backend Init +------------ +.A simple program to demonstrate backend init function. + +[source,python] +------------------------------------------------------------------ +include::../demos/py_simple/backends.py[] +------------------------------------------------------------------ diff --git a/doc/example_py_x11_windows.txt b/doc/example_py_x11_windows.txt new file mode 100644 index 0000000..7d454a9 --- /dev/null +++ b/doc/example_py_x11_windows.txt @@ -0,0 +1,8 @@ +X11 Windows +----------- +.A simple program to demonstrate multiple windows with X11 + +[source,python] +------------------------------------------------------------------ +include::../demos/py_simple/x11_windows.py[] +------------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes: doc/backends_python.txt | 76 ++++++++++++++++++ ...{example_py_gfx.txt => example_py_backends.txt} | 8 +- ...ample_py_gfx.txt => example_py_x11_windows.txt} | 8 +- libs/loaders/GP_BMP.c | 19 +++++ libs/loaders/GP_PNG.c | 3 +- tests/loaders/PNG.c | 82 ++++++++++++++++++-- 6 files changed, 181 insertions(+), 15 deletions(-) copy doc/{example_py_gfx.txt => example_py_backends.txt} (54%) copy doc/{example_py_gfx.txt => example_py_x11_windows.txt} (54%)
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.