Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 929 discussions
13 Nov '13
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 88eea356e8494dea8645470506f2087b104d4326 (commit)
via 6bc4c8d0ca2ac207dc2a0e2feb9fd482aeff1343 (commit)
from 117f44cf3323cab17798651ccdedc9018e5a95fc (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/88eea356e8494dea8645470506f2087b104d…
commit 88eea356e8494dea8645470506f2087b104d4326
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Nov 12 23:43:45 2013 +0100
backends: X11: Flush connection when window was closed.
If one of the windows was closed the connection needs
to be flushed so that it's removed from the screen immediately.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_X11_Win.h b/libs/backends/GP_X11_Win.h
index ad0bbf5..1a81fc5 100644
--- a/libs/backends/GP_X11_Win.h
+++ b/libs/backends/GP_X11_Win.h
@@ -90,6 +90,11 @@ static struct x11_win *win_list_lookup(Window win)
return NULL;
}
+static int win_list_empty(void)
+{
+ return win_list == NULL;
+}
+
/* Send NETWM message, most modern Window Managers should understand */
static void x11_win_fullscreen(struct x11_win *win, int mode)
{
@@ -379,6 +384,9 @@ static void x11_win_close(struct x11_win *win)
XDestroyWindow(win->dpy, win->win);
+ if (!win_list_empty())
+ XFlush(win->dpy);
+
XUnlockDisplay(win->dpy);
/* Close connection/Decrease ref count */
http://repo.or.cz/w/gfxprim.git/commit/6bc4c8d0ca2ac207dc2a0e2feb9fd482aeff…
commit 6bc4c8d0ca2ac207dc2a0e2feb9fd482aeff1343
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Nov 12 23:41:40 2013 +0100
backends: X11: Avoid dereferencing closed window
If X11 backend has two windows opened and one of them
was closed the pointer to last window in event parser may
became invalid. Now it's cleared when window is closed.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index 5b64b49..ffa0b9c 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -105,20 +105,24 @@ static void x11_flip(GP_Backend *self)
XUnlockDisplay(win->dpy);
}
+static struct x11_win *last_win = NULL;
+
static void x11_ev(XEvent *ev)
{
- static struct x11_win *win = NULL;
+ struct x11_win *win;
/* Lookup for window */
- if (win == NULL || win->win != ev->xany.window) {
- win = win_list_lookup(ev->xany.window);
+ if (last_win == NULL || last_win->win != ev->xany.window) {
+ last_win = win_list_lookup(ev->xany.window);
- if (win == NULL) {
+ if (last_win == NULL) {
GP_WARN("Event for unknown window, ignoring.");
return;
}
}
+ win = last_win;
+
struct GP_Backend *self = GP_CONTAINER_OF(win, struct GP_Backend, priv);
switch (ev->type) {
@@ -546,6 +550,13 @@ static void window_close(GP_Backend *self)
static void x11_exit(GP_Backend *self)
{
+ struct x11_win *win = GP_BACKEND_PRIV(self);
+
+ GP_DEBUG(1, "Closing window %p", win);
+
+ if (win == last_win)
+ last_win = NULL;
+
window_close(self);
free(self);
diff --git a/libs/backends/GP_X11_Win.h b/libs/backends/GP_X11_Win.h
index b728bcf..ad0bbf5 100644
--- a/libs/backends/GP_X11_Win.h
+++ b/libs/backends/GP_X11_Win.h
@@ -363,6 +363,8 @@ static int x11_win_open(struct x11_wreq *wreq)
static void x11_win_close(struct x11_win *win)
{
+ GP_DEBUG(1, "Closing window");
+
XLockDisplay(win->dpy);
win_list_rem(win);
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_X11.c | 19 +++++++++++++++----
libs/backends/GP_X11_Win.h | 10 ++++++++++
2 files changed, 25 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.")
1
0
12 Nov '13
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 117f44cf3323cab17798651ccdedc9018e5a95fc (commit)
from 561ab88b80e943a571fa0aa84b3ed0816e6812eb (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/117f44cf3323cab17798651ccdedc9018e5a…
commit 117f44cf3323cab17798651ccdedc9018e5a95fc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Nov 12 22:54:47 2013 +0100
backends: X11: Warn if _NET_WM_STATE is not supported.
Print warning and don't send the client message in case NetWM window
fullscreen state is not supported.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_X11_Win.h b/libs/backends/GP_X11_Win.h
index 8466961..b728bcf 100644
--- a/libs/backends/GP_X11_Win.h
+++ b/libs/backends/GP_X11_Win.h
@@ -100,6 +100,11 @@ static void x11_win_fullscreen(struct x11_win *win, int mode)
return;
}
+ if (!x11_conn.S__NET_WM_STATE || !x11_conn.S__NET_WM_STATE_FULLSCREEN) {
+ GP_WARN("NetWM Fullscreen not supported");
+ return;
+ }
+
GP_DEBUG(2, "Requesting fullscreen mode = %u", mode);
memset(&ev, 0, sizeof(ev));
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_X11_Win.h | 5 +++++
1 files changed, 5 insertions(+), 0 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.")
1
0
12 Nov '13
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 561ab88b80e943a571fa0aa84b3ed0816e6812eb (commit)
from 378721e46cdafc7ba99e30f51b8b8395fb254de0 (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/561ab88b80e943a571fa0aa84b3ed0816e68…
commit 561ab88b80e943a571fa0aa84b3ed0816e6812eb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Nov 12 19:55:46 2013 +0100
backends: X11: Cleanup + Fullscreen fixes
* Cleanup the source
* Add NetWM Window Manager detection code
* Fix event mask for while sending fullscreen request
(Fixes fullscreen in OpenBox)
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Backend_symbols.txt b/build/syms/Backend_symbols.txt
index d2945d1..4c830bf 100644
--- a/build/syms/Backend_symbols.txt
+++ b/build/syms/Backend_symbols.txt
@@ -24,6 +24,4 @@ GP_BackendPollEvent
GP_BackendAddTimer
GP_BackendRemTimer
-GP_InputDriverX11EventPut
-GP_InputDriverX11Init
GP_InputDriverSDLEventPut
diff --git a/libs/backends/GP_InputDriverX11.h b/libs/backends/GP_InputDriverX11.h
deleted file mode 100644
index 95c3b08..0000000
--- a/libs/backends/GP_InputDriverX11.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#ifndef GP_INPUT_DRIVER_X11_H
-#define GP_INPUT_DRIVER_X11_H
-
-#include <stdint.h>
-#include <X11/Xlib.h>
-
-struct GP_EventQueue;
-
-/*
- * Loads X11 KeyCode translation table.
- */
-void GP_InputDriverX11Init(Display *dpy);
-
-/*
- * Converts X11 event to GFXprim event and puts it into the queue.
- */
-void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue,
- XEvent *ev, int w, int h);
-
-#endif /* GP_INPUT_DRIVER_X11_H */
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index 3379dd0..5b64b49 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -41,12 +41,11 @@
#include <X11/extensions/XShm.h>
#endif /* HAVE_X_SHM */
-#include "GP_InputDriverX11.h"
-
#include "backends/GP_X11.h"
#include "GP_X11_Conn.h"
#include "GP_X11_Win.h"
+#include "GP_X11_Input.h"
static int resize_ximage(GP_Backend *self, int w, int h);
static int resize_shm_ximage(GP_Backend *self, int w, int h);
@@ -166,8 +165,8 @@ static void x11_ev(XEvent *ev)
win->resized_flag = 1;
default:
//TODO: More accurate window w and h?
- GP_InputDriverX11EventPut(&self->event_queue, ev,
- self->context->w, self->context->h);
+ x11_input_event_put(&self->event_queue, ev,
+ self->context->w, self->context->h);
break;
}
}
diff --git a/libs/backends/GP_X11_Conn.h b/libs/backends/GP_X11_Conn.h
index 87a188c..3bbd683 100644
--- a/libs/backends/GP_X11_Conn.h
+++ b/libs/backends/GP_X11_Conn.h
@@ -26,7 +26,18 @@
struct x11_conn {
Display *dpy;
- /* window reference counter */
+ /* X Atoms */
+ Atom A_WM_DELETE_WINDOW;
+
+ /* NetWM Atoms */
+ Atom A__NET_WM_STATE;
+ Atom A__NET_WM_STATE_FULLSCREEN;
+
+ /* Bitflags for supported Atoms */
+ int S__NET_WM_STATE:1;
+ int S__NET_WM_STATE_FULLSCREEN:1;
+
+ /* reference counter, incremented on window creation */
unsigned int ref_cnt;
};
@@ -35,6 +46,54 @@ static struct x11_conn x11_conn = {
.ref_cnt = 0,
};
+static int x11_get_property(Atom type, Atom **args, unsigned long *count)
+{
+ int ret, format;
+ unsigned long bytesafter;
+
+ ret = XGetWindowProperty(x11_conn.dpy, XDefaultRootWindow(x11_conn.dpy),
+ type, 0, 16384, False, AnyPropertyType, &type,
+ &format, count, &bytesafter, (void*)args);
+
+ return ret == Success && *count > 0;
+}
+
+#define ATOM_SUPPORTED(name, type, atom) do { + if (x11_conn.A_##name == atom) { + GP_DEBUG(2, type " Atom '" #name "' is supported."); + x11_conn.S_##name = 1; + } +} while (0)
+
+static void x11_check_atoms(Atom at)
+{
+ ATOM_SUPPORTED(_NET_WM_STATE, "NetWM", at);
+ ATOM_SUPPORTED(_NET_WM_STATE_FULLSCREEN, "NetWM", at);
+}
+
+#define INIT_ATOM(name) x11_conn.A_##name = XInternAtom(x11_conn.dpy, #name, False)
+
+static void x11_detect_wm_features(void)
+{
+ Atom *args = NULL, at;
+ unsigned long count, i;
+
+ INIT_ATOM(WM_DELETE_WINDOW);
+ INIT_ATOM(_NET_WM_STATE);
+ INIT_ATOM(_NET_WM_STATE_FULLSCREEN);
+
+ at = XInternAtom(x11_conn.dpy, "_NET_SUPPORTED", True);
+
+ if (x11_get_property(at, &args, &count)) {
+ GP_DEBUG(1, "Window manager supports NetWM");
+
+ for (i = 0; i < count; i++)
+ x11_check_atoms(args[i]);
+ }
+}
+
+static void x11_input_init(void);
+
static unsigned int x11_open(const char *display)
{
if (x11_conn.ref_cnt != 0)
@@ -55,7 +114,8 @@ static unsigned int x11_open(const char *display)
}
/* Initialized key translation table */
- GP_InputDriverX11Init(x11_conn.dpy);
+ x11_input_init();
+ x11_detect_wm_features();
return ++x11_conn.ref_cnt;
}
diff --git a/libs/backends/GP_InputDriverX11.c b/libs/backends/GP_X11_Input.h
similarity index 92%
rename from libs/backends/GP_InputDriverX11.c
rename to libs/backends/GP_X11_Input.h
index a271360..c4364b4 100644
--- a/libs/backends/GP_InputDriverX11.c
+++ b/libs/backends/GP_X11_Input.h
@@ -20,19 +20,9 @@
* *
*****************************************************************************/
-#include "../../config.h"
-
-#include "core/GP_Debug.h"
-#include "core/GP_Common.h"
-#include "input/GP_EventQueue.h"
-
-#ifdef HAVE_LIBX11
-
#include <X11/keysym.h>
#include <X11/XF86keysym.h>
-#include "GP_InputDriverX11.h"
-
/* X11 keycodes */
static uint16_t keycode_table[] = {
0, GP_KEY_1, GP_KEY_2, GP_KEY_3,
@@ -149,7 +139,7 @@ static const struct keytable sym_to_key[] = {
{XF86XK_AudioPlay, GP_KEY_PLAYPAUSE},
};
-static void init_table(Display *dpy)
+static void x11_input_init(void)
{
GP_DEBUG(1, "Initializing X11 KeyCode table");
@@ -158,7 +148,8 @@ static void init_table(Display *dpy)
for (i = 0; i < GP_ARRAY_SIZE(sym_to_key); i++) {
unsigned int keycode;
- keycode = XKeysymToKeycode(dpy, sym_to_key[i].x_keysym);
+ keycode = XKeysymToKeycode(x11_conn.dpy,
+ sym_to_key[i].x_keysym);
if (keycode == 0) {
GP_DEBUG(1, "KeySym '%s' (%u) not defined",
@@ -203,13 +194,8 @@ static unsigned int get_key(unsigned int xkey)
return key;
}
-void GP_InputDriverX11Init(Display *dpy)
-{
- init_table(dpy);
-}
-
-void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue,
- XEvent *ev, int w, int h)
+static void x11_input_event_put(struct GP_EventQueue *event_queue,
+ XEvent *ev, int w, int h)
{
int key = 0, press = 0;
@@ -274,17 +260,12 @@ void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue,
break;
/* events from WM */
case ClientMessage:
- //TODO: We know we get WM_DELETE_WINDOW because it's the only
- // event we requested to get but we must check anyway
- GP_EventQueuePush(event_queue, GP_EV_SYS,
- GP_EV_SYS_QUIT, 0, NULL);
-#if 0
- switch (ev->xclient.message_type) {
- default:
- GP_WARN("Unknown X11 ClientMessage Atom %i",
- ev->xclient.message_type);
+ if ((Atom)ev->xclient.data.l[0] == x11_conn.A_WM_DELETE_WINDOW) {
+ GP_EventQueuePush(event_queue, GP_EV_SYS,
+ GP_EV_SYS_QUIT, 0, NULL);
+ return;
}
-#endif
+ GP_WARN("Unknown X Client Message");
break;
case MapNotify:
GP_DEBUG(1, "MapNotify event received");
@@ -299,5 +280,3 @@ void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue,
GP_WARN("Unhandled X11 event type %u", ev->type);
}
}
-
-#endif /* HAVE_LIBX11 */
diff --git a/libs/backends/GP_X11_Win.h b/libs/backends/GP_X11_Win.h
index b2dfec3..8466961 100644
--- a/libs/backends/GP_X11_Win.h
+++ b/libs/backends/GP_X11_Win.h
@@ -90,17 +90,11 @@ static struct x11_win *win_list_lookup(Window win)
return NULL;
}
-#ifndef _NET_WM_STATE_ADD
-# define _NET_WM_STATE_ADD 1
-#endif /* _NET_WM_STATE_ADD */
-
-#ifndef _NET_WM_STATE_REMOVE
-# define _NET_WM_STATE_REMOVE 0
-#endif /* _NET_WM_STATE_REMOVE */
-
/* Send NETWM message, most modern Window Managers should understand */
static void x11_win_fullscreen(struct x11_win *win, int mode)
{
+ XEvent ev;
+
if (mode < 0 || mode > 2) {
GP_WARN("Invalid fullscreen mode = %u", mode);
return;
@@ -108,31 +102,19 @@ static void x11_win_fullscreen(struct x11_win *win, int mode)
GP_DEBUG(2, "Requesting fullscreen mode = %u", mode);
- Atom wm_state, fullscreen;
-
- wm_state = XInternAtom(win->dpy, "_NET_WM_STATE", True);
- fullscreen = XInternAtom(win->dpy, "_NET_WM_STATE_FULLSCREEN", True);
-
- if (wm_state == None || fullscreen == None) {
- GP_WARN("Failed to create _NET_WM_* atoms");
- return;
- }
-
- XEvent ev;
-
memset(&ev, 0, sizeof(ev));
ev.type = ClientMessage;
ev.xclient.window = win->win;
- ev.xclient.message_type = wm_state;
+ ev.xclient.message_type = x11_conn.A__NET_WM_STATE;
ev.xclient.format = 32;
ev.xclient.data.l[0] = mode;
- ev.xclient.data.l[1] = fullscreen;
+ ev.xclient.data.l[1] = x11_conn.A__NET_WM_STATE_FULLSCREEN;
ev.xclient.data.l[2] = 0;
ev.xclient.data.l[3] = 1;
if (!XSendEvent(win->dpy, XDefaultRootWindow(win->dpy),
- False, SubstructureNotifyMask, &ev)) {
+ False, SubstructureNotifyMask|SubstructureRedirectMask, &ev)) {
GP_WARN("Failed to send _NET_WM_STATE_FULLSCREEN event");
return;
}
@@ -364,15 +346,7 @@ static int x11_win_open(struct x11_wreq *wreq)
NULL, 0, NULL, NULL, NULL);
/* Make the window close button send event */
- Atom xa = XInternAtom(win->dpy, "WM_DELETE_WINDOW", True);
-
- if (xa != None) {
- GP_DEBUG(2, "Setting WM_DELETE_WINDOW Atom to True");
-
- XSetWMProtocols(win->dpy, win->win, &xa, 1);
- } else {
- GP_DEBUG(2, "Failed to set WM_DELETE_WINDOW Atom to True");
- }
+ XSetWMProtocols(win->dpy, win->win, &x11_conn.A_WM_DELETE_WINDOW, 1);
win_list_add(win);
-----------------------------------------------------------------------
Summary of changes:
build/syms/Backend_symbols.txt | 2 -
libs/backends/GP_InputDriverX11.h | 42 -------------
libs/backends/GP_X11.c | 7 +-
libs/backends/GP_X11_Conn.h | 64 +++++++++++++++++++-
.../{GP_InputDriverX11.c => GP_X11_Input.h} | 41 +++----------
libs/backends/GP_X11_Win.h | 38 ++----------
6 files changed, 81 insertions(+), 113 deletions(-)
delete mode 100644 libs/backends/GP_InputDriverX11.h
rename libs/backends/{GP_InputDriverX11.c => GP_X11_Input.h} (92%)
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.")
1
0
12 Nov '13
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 378721e46cdafc7ba99e30f51b8b8395fb254de0 (commit)
from 5d9d976eb5371267bad2e285f6de5f02712ce86b (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/378721e46cdafc7ba99e30f51b8b8395fb25…
commit 378721e46cdafc7ba99e30f51b8b8395fb254de0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Nov 11 22:54:02 2013 +0100
backends: X11: Fix window size passed to event parser.
When SHM is not in use, the win->context field is not used to construct
the backend context and the width and height fields are uninitialized
which leads to wrong (or none) events from mouse pointer movement.
Fix this by using self->context which is correct in all cases.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index 8505edc..3379dd0 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -167,7 +167,7 @@ static void x11_ev(XEvent *ev)
default:
//TODO: More accurate window w and h?
GP_InputDriverX11EventPut(&self->event_queue, ev,
- win->context.w, win->context.h);
+ self->context->w, self->context->h);
break;
}
}
@@ -480,7 +480,6 @@ static int create_ximage(GP_Backend *self, GP_Size w, GP_Size h)
}
win->shm_flag = 0;
-
win->img->data = (char*)self->context->pixels;
return 0;
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_X11.c | 3 +--
1 files changed, 1 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.")
1
0
11 Nov '13
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 5d9d976eb5371267bad2e285f6de5f02712ce86b (commit)
via fe168a48fb444c9bccacd07549bda653bf91cbdb (commit)
from 5885e81e95f27117da33f1b68cdd7a88c3fad9c6 (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/5d9d976eb5371267bad2e285f6de5f02712c…
commit 5d9d976eb5371267bad2e285f6de5f02712ce86b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Nov 11 00:08:23 2013 +0100
gfx: GP_FillRect: Check y coords for context intersection.
This optimizes cases where y coordinate is out of the context.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/gfx/GP_Rect.c b/libs/gfx/GP_Rect.c
index be07b8b..618c788 100644
--- a/libs/gfx/GP_Rect.c
+++ b/libs/gfx/GP_Rect.c
@@ -75,6 +75,9 @@ void GP_FillRectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
if (y0 > y1)
GP_SWAP(y0, y1);
+ y0 = GP_MAX(0, y0);
+ y1 = GP_MIN(y1, (GP_Coord)context->h - 1);
+
GP_Coord y;
for (y = y0; y <= y1; y++)
GP_HLine_Raw(context, x0, x1, y, pixel);
@@ -97,7 +100,7 @@ void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_TRANSFORM_POINT(context, x0, y0);
GP_TRANSFORM_POINT(context, x1, y1);
- GP_FillRect_Raw(context, x0, y0, x1, y1, pixel);
+ GP_FillRectXYXY_Raw(context, x0, y0, x1, y1, pixel);
}
void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
http://repo.or.cz/w/gfxprim.git/commit/fe168a48fb444c9bccacd07549bda653bf91…
commit fe168a48fb444c9bccacd07549bda653bf91cbdb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Nov 10 23:47:39 2013 +0100
test: gfx: Add test for FillRect.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/gfx/FillRect.c b/tests/gfx/FillRect.c
new file mode 100644
index 0000000..bd30ad5
--- /dev/null
+++ b/tests/gfx/FillRect.c
@@ -0,0 +1,326 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <core/GP_Context.h>
+#include <gfx/GP_Rect.h>
+
+#include "tst_test.h"
+
+#include "common.h"
+
+struct testcase {
+ /* rect description */
+ GP_Coord x1;
+ GP_Coord y1;
+ GP_Coord x2;
+ GP_Coord y2;
+
+ /* expected result */
+ GP_Size w, h;
+ const char pixmap[];
+};
+
+static int test_rect(const struct testcase *t)
+{
+ GP_Context *c;
+ int err;
+
+ c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8);
+
+ if (c == NULL) {
+ tst_err("Failed to allocate context");
+ return TST_UNTESTED;
+ }
+
+ /* zero the pixels buffer */
+ memset(c->pixels, 0, c->w * c->h);
+
+ GP_FillRect(c, t->x1, t->y1, t->x2, t->y2, 1);
+
+ err = compare_buffers(t->pixmap, c);
+
+ if (err)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+struct testcase testcase_rect_1 = {
+ .x1 = 2,
+ .y1 = 2,
+ .x2 = 2,
+ .y2 = 2,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_9a = {
+ .x1 = 1,
+ .y1 = 1,
+ .x2 = 3,
+ .y2 = 3,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_9b = {
+ .x1 = 3,
+ .y1 = 3,
+ .x2 = 1,
+ .y2 = 1,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_9lu = {
+ .x1 = -2147483648,
+ .y1 = -2147483648,
+ .x2 = 2,
+ .y2 = 2,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 1, 1, 1, 0, 0,
+ 1, 1, 1, 0, 0,
+ 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_9ld = {
+ .x1 = -2147483648,
+ .y1 = 2,
+ .x2 = 2,
+ .y2 = 2147483647,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 1, 0, 0,
+ 1, 1, 1, 0, 0,
+ 1, 1, 1, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_9ru = {
+ .x1 = 2,
+ .y1 = -2147483648,
+ .x2 = 2147483647,
+ .y2 = 2,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 1, 1, 1,
+ 0, 0, 1, 1, 1,
+ 0, 0, 1, 1, 1,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_9rd = {
+ .x1 = 2,
+ .y1 = 2,
+ .x2 = 2147483647,
+ .y2 = 2147483647,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 1, 1, 1,
+ 0, 0, 1, 1, 1,
+ 0, 0, 1, 1, 1,
+ }
+};
+
+struct testcase testcase_rect_9r = {
+ .x1 = -2147483648,
+ .y1 = 3,
+ .x2 = 2,
+ .y2 = 1,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 1, 1, 1, 0, 0,
+ 1, 1, 1, 0, 0,
+ 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_9l = {
+ .x1 = 2,
+ .y1 = 3,
+ .x2 = 2147483647,
+ .y2 = 1,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 1, 1, 1,
+ 0, 0, 1, 1, 1,
+ 0, 0, 1, 1, 1,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_9u = {
+ .x1 = 1,
+ .y1 = -2147483648,
+ .x2 = 3,
+ .y2 = 2,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+struct testcase testcase_rect_9d = {
+ .x1 = 1,
+ .y1 = 2,
+ .x2 = 3,
+ .y2 = 2147483647,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ 0, 1, 1, 1, 0,
+ }
+};
+
+const struct tst_suite tst_suite = {
+ .suite_name = "FillRect Testsuite",
+ .tests = {
+ {.name = "FillRect x1=x2 y1=y2",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_1},
+
+ {.name = "FillRect x1<x2 y1<y2",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_9a},
+
+ {.name = "FillRect x1>x2 y1>y2",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_9b},
+
+ {.name = "FillRect x1,y1 out of context",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_9lu,
+ .timeout = 2},
+
+ {.name = "FillRect x1,y2 out of context",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_9ld,
+ .timeout = 2},
+
+ {.name = "FillRect x2,y1 out of context",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_9ru,
+ .timeout = 2},
+
+ {.name = "FillRect x2,y2 out of context",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_9rd,
+ .timeout = 2},
+
+ {.name = "FillRect x1 out of context",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_9r,
+ .timeout = 2},
+
+ {.name = "FillRect x2 out of context",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_9l,
+ .timeout = 2},
+
+ {.name = "FillRect y1 out of context",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_9u,
+ .timeout = 2},
+
+ {.name = "FillRect y2 out of context",
+ .tst_fn = test_rect,
+ .data = &testcase_rect_9d,
+ .timeout = 2},
+
+ {.name = NULL}
+ }
+};
diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile
index 2094107..c93bf99 100644
--- a/tests/gfx/Makefile
+++ b/tests/gfx/Makefile
@@ -5,7 +5,7 @@ CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
GENSOURCES=APICoverage.gen.c
APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon Ellipse HLine- VLine PutPixelAA HLineAA LineAA APICoverage.gen FillEllipse
+ VLine PutPixelAA HLineAA LineAA APICoverage.gen FillEllipse FillRect
Circle: common.o
FillCircle: common.o
@@ -19,6 +19,7 @@ VLine: common.o
PutPixelAA: common.o
HLineAA: common.o
LineAA: common.o
+FillRect: common.o
include ../tests.mk
diff --git a/tests/gfx/test_list.txt b/tests/gfx/test_list.txt
index ff64600..b801c5b 100644
--- a/tests/gfx/test_list.txt
+++ b/tests/gfx/test_list.txt
@@ -11,6 +11,7 @@ Ellipse
FillEllipse
CircleSeg
Polygon
+FillRect
PutPixelAA
HLineAA
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_Rect.c | 5 +-
tests/gfx/FillRect.c | 326 +++++++++++++++++++++++++++++++++++++++++++++++
tests/gfx/Makefile | 3 +-
tests/gfx/test_list.txt | 1 +
4 files changed, 333 insertions(+), 2 deletions(-)
create mode 100644 tests/gfx/FillRect.c
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.")
1
0
10 Nov '13
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 5885e81e95f27117da33f1b68cdd7a88c3fad9c6 (commit)
via 563e33e98b525b7b07f233389e7c522bbfd7aaec (commit)
via ef19efc738739865ba6ff4cb33cdec083f7ccc76 (commit)
via 9d8b39521423cbcc9702984c90e9c304036d0de5 (commit)
via 37aec8794533c757d224024fa3ab570dd3a63b2b (commit)
via 7d2fc29b64483d7cb8afafa3788e85b7080c46a3 (commit)
from 8890b06aa3269a9a264cf339ff402a746594fb16 (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/5885e81e95f27117da33f1b68cdd7a88c3fa…
commit 5885e81e95f27117da33f1b68cdd7a88c3fad9c6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Nov 10 21:45:47 2013 +0100
spiv: Add zoom modes.
Finally spiv gets support for different zoom modes.
There are three zoom options:
* Fixed / Resizeable Window
* Turn On/Off Donwscale
* Turn On/Off Upscale
+ Maximal window size, which works best if you set it
to your resolution - window decoration size.
What is still broken is fullscreen mode, we must not mess with window
size when we entered fullscreen (which needs a fix at a backend level
first.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 4b2d414..428e5ea 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -52,33 +52,16 @@ static int abort_flag = 0;
static int show_progress = 0;
static int loader_running = 0;
-enum zoom_type {
- /*
- * Resize image to fit current size of the window.
- */
- ZOOM_FIT,
-
- /*
- * Use zoom set in zoom float and zoom offsets.
- */
- ZOOM_FIXED,
-
- /*
- * Fixed zoom but spiv tries to change
- * the window size to fit the image size
- */
- ZOOM_FIXED_WIN,
-
- /*
- * Do not upscale images but downscale them
- * if they are too big.
- */
- ZOOM_FIT_DOWNSCALE,
-};
-
struct loader_params {
/* current resize ratio */
- float rat;
+ float zoom_rat;
+
+ /* offset in pixels */
+ unsigned int zoom_x_offset;
+ unsigned int zoom_y_offset;
+
+ /* flag that is turned on when user changes zoom */
+ unsigned int zoom_manual;
long show_progress_once:2;
/* use nearest neighbour resampling first */
@@ -91,14 +74,6 @@ struct loader_params {
/* slideshow sleep */
int sleep_ms;
- /* offset in pixels */
- unsigned int zoom_x_offset;
- unsigned int zoom_y_offset;
-
- /* zoom */
- enum zoom_type zoom_type;
- float zoom;
-
/* caches for loaded images */
struct image_cache *img_resized_cache;
};
@@ -141,25 +116,6 @@ static int image_loader_callback(GP_ProgressCallback *self)
static GP_Context *load_image(int elevate);
-/*
- * Ask backend to resize window may not be implemented or authorized. If
- * backend (window) is resized we will get SYS_RESIZE event, see the main event
- * loop.
- */
-static void resize_backend(float ratio, int shift_flag)
-{
- GP_Context *img = load_image(1);
-
- if (!shift_flag)
- ratio = 1.00 / ratio;
-
- unsigned int w = img->w * ratio + 0.5;
- unsigned int h = img->h * ratio + 0.5;
-
- GP_BackendResize(backend, w, h);
-}
-
-
static const char *img_name(const char *img_path)
{
int i, len = strlen(img_path);
@@ -268,26 +224,34 @@ static void show_info(struct loader_params *params, GP_Context *img,
GP_Context *context = backend->context;
const char *img_path = image_loader_img_path();
- set_caption(img_path, params->rat);
+ set_caption(img_path, params->zoom_rat);
if (!config.show_info)
return;
- GP_Size th = GP_TextHeight(NULL);
+ GP_Size th = GP_TextHeight(NULL), y = 10;
+
+ info_printf(context, 10, y, "%ux%u (%ux%u) 1:%3.3f %3.1f%%",
+ img->w, img->h, orig_img->w, orig_img->h, params->zoom_rat,
+ params->zoom_rat * 100);
+ y += th + 2;
- info_printf(context, 10, 10, "%ux%u (%ux%u) 1:%3.3f",
- img->w, img->h, orig_img->w, orig_img->h, params->rat);
+ info_printf(context, 10, y, "%s", img_name(img_path));
- info_printf(context, 10, 12 + th, "%s", img_name(img_path));
+ y += th + 2;
- info_printf(context, 10, 14 + 2 * th, "%s%s",
- params->use_low_pass && params->rat < 1 ? "Gaussian LP + " : "",
- GP_InterpolationTypeName(params->resampling_method));
+ if (params->zoom_rat != 1.00) {
+ info_printf(context, 10, y, "%s%s",
+ params->use_low_pass && params->zoom_rat < 1 ? "Gaussian LP + " : "",
+ GP_InterpolationTypeName(params->resampling_method));
+ y += th + 2;
+ }
unsigned int count = image_loader_count();
unsigned int pos = image_loader_pos() + 1;
- info_printf(context, 10, 16 + 3 * th, "%u of %u", pos, count);
+ info_printf(context, 10, y, "%u of %u", pos, count);
+ y += th + 2;
if (!image_loader_is_in_dir())
return;
@@ -295,7 +259,7 @@ static void show_info(struct loader_params *params, GP_Context *img,
unsigned int dir_count = image_loader_dir_count();
unsigned int dir_pos = image_loader_dir_pos() + 1;
- info_printf(context, 10, 18 + 4 * th,
+ info_printf(context, 10, y,
"%u of %u in directory", dir_pos, dir_count);
}
@@ -329,17 +293,22 @@ static void update_display(struct loader_params *params, GP_Context *img,
int cx = 0;
int cy = 0;
- switch (params->zoom_type) {
- case ZOOM_FIT_DOWNSCALE:
- case ZOOM_FIT:
- cx = (context->w - img->w)/2;
- cy = (context->h - img->h)/2;
- break;
- case ZOOM_FIXED:
- case ZOOM_FIXED_WIN:
+ /*
+ * Center the image, if window size is fixed and
+ * the image is smaller than window.
+ */
+ if (config.win_strategy == ZOOM_WIN_FIXED) {
+
+ if (img->w < context->w)
+ cx = (context->w - img->w)/2;
+
+ if (img->h < context->h)
+ cy = (context->h - img->h)/2;
+ }
+
+ if (params->zoom_manual) {
cx = params->zoom_x_offset;
cy = params->zoom_y_offset;
- break;
}
GP_Context sub_display;
@@ -364,6 +333,7 @@ static void update_display(struct loader_params *params, GP_Context *img,
GP_FillRectXYWH(context, 0, 0, cx, context->h, black_pixel);
GP_FillRectXYWH(context, 0, 0, context->w, cy, black_pixel);
+
int w = context->w - img->w - cx;
if (w > 0)
@@ -412,12 +382,12 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
}
/* Do low pass filter */
- if (params->use_low_pass && params->rat < 1) {
+ if (params->use_low_pass && params->zoom_rat < 1) {
cpu_timer_start(&timer, "Blur");
callback.priv = "Blurring Image";
- res = GP_FilterGaussianBlurAlloc(img, 0.4/params->rat,
- 0.4/params->rat, &callback);
+ res = GP_FilterGaussianBlurAlloc(img, 0.4/params->zoom_rat,
+ 0.4/params->zoom_rat, &callback);
if (res == NULL)
return NULL;
@@ -436,7 +406,7 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
cpu_timer_stop(&timer);
/*
- if (params->rat > 1.5) {
+ if (params->zoom_rat > 1.5) {
cpu_timer_start(&timer, "Sharpening");
callback.priv = "Sharpening";
GP_FilterEdgeSharpening(i1, i1, 0.1, &callback);
@@ -459,38 +429,89 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
static float calc_img_size(struct loader_params *params,
uint32_t img_w, uint32_t img_h,
- uint32_t src_w, uint32_t src_h)
+ uint32_t win_w, uint32_t win_h)
{
- float w_rat;
- float h_rat;
+ float w_rat, h_rat, rat;
+ unsigned int max_win_w = config.max_win_w;
+ unsigned int max_win_h = config.max_win_h;
switch (config.orientation) {
- case ROTATE_0:
- case ROTATE_180:
- default:
- break;
case ROTATE_90:
case ROTATE_270:
- GP_SWAP(src_w, src_h);
+ GP_SWAP(win_w, win_h);
+ GP_SWAP(max_win_w, max_win_h);
+ break;
+ default:
break;
}
- switch (params->zoom_type) {
- case ZOOM_FIT_DOWNSCALE:
- if (img_w <= src_w && img_h <= src_h)
+ if (params->zoom_manual) {
+ if (config.win_strategy == ZOOM_WIN_RESIZABLE) {
+ win_w = GP_MIN(max_win_w, img_w * params->zoom_rat + 0.5);
+ win_h = GP_MIN(max_win_h, img_h * params->zoom_rat + 0.5);
+
+ switch (config.orientation) {
+ case ROTATE_90:
+ case ROTATE_270:
+ GP_BackendResize(backend, win_h, win_w);
+ break;
+ default:
+ GP_BackendResize(backend, win_w, win_h);
+ }
+ }
+ return params->zoom_rat;
+ }
+
+
+ if (config.win_strategy == ZOOM_WIN_RESIZABLE) {
+ win_w = GP_MIN(max_win_w, img_w);
+ win_h = GP_MIN(max_win_h, img_h);
+
+ /*
+ * Image is larger than screen and downscale is enabled ->
+ * resize window to match image ratio.
+ */
+ if ((win_w != img_w || win_h != img_h) &&
+ config.zoom_strategy & ZOOM_IMAGE_DOWNSCALE) {
+
+ w_rat = 1.00 * win_w / img_w;
+ h_rat = 1.00 * win_h / img_h;
+
+ if (w_rat > 1)
+ w_rat = 1;
+
+ if (h_rat > 1)
+ w_rat = 1;
+
+ rat = GP_MIN(h_rat, w_rat);
+
+ win_w = rat * img_w + 0.5;
+ win_h = rat * img_h + 0.5;
+ }
+
+ switch (config.orientation) {
+ case ROTATE_90:
+ case ROTATE_270:
+ GP_BackendResize(backend, win_h, win_w);
+ break;
+ default:
+ GP_BackendResize(backend, win_w, win_h);
+ }
+ }
+
+ if (img_w <= win_w && img_h <= win_h) {
+ if (!(config.zoom_strategy & ZOOM_IMAGE_UPSCALE))
return 1.00;
- case ZOOM_FIT:
- w_rat = 1.00 * src_w / img_w;
- h_rat = 1.00 * src_h / img_h;
- return GP_MIN(w_rat, h_rat);
- case ZOOM_FIXED:
- return params->zoom;
- case ZOOM_FIXED_WIN:
- resize_backend(params->zoom, 0);
- return params->zoom;
+ } else {
+ if (!(config.zoom_strategy & ZOOM_IMAGE_DOWNSCALE))
+ return 1.00;
+
}
- return 1.00;
+ w_rat = 1.00 * win_w / img_w;
+ h_rat = 1.00 * win_h / img_h;
+
+ return GP_MIN(w_rat, h_rat);
}
static void *image_loader(void *ptr)
@@ -509,14 +530,14 @@ static void *image_loader(void *ptr)
return NULL;
}
- /* Figure out rotation */
+ /* Figure zoom */
GP_Size w, h;
- params->rat = calc_img_size(params, orig_img->w, orig_img->h,
- context->w, context->h);
+ params->zoom_rat = calc_img_size(params, orig_img->w, orig_img->h,
+ context->w, context->h);
- w = orig_img->w * params->rat + 0.5;
- h = orig_img->h * params->rat + 0.5;
+ w = orig_img->w * params->zoom_rat + 0.5;
+ h = orig_img->h * params->zoom_rat + 0.5;
/* Special case => no need to resize */
if (w == orig_img->w && h == orig_img->h) {
@@ -578,12 +599,14 @@ static void image_seek(struct loader_params *params,
* image we are currently resamling.
*/
stop_loader();
+ params->zoom_manual = 0;
image_loader_seek(offset, whence);
show_image(params);
}
static void set_zoom_offset(struct loader_params *params, int dx, int dy)
{
+ params->zoom_manual = 1;
params->zoom_x_offset += dx;
params->zoom_y_offset += dy;
show_image(params);
@@ -591,7 +614,15 @@ static void set_zoom_offset(struct loader_params *params, int dx, int dy)
static void zoom_mul(struct loader_params *params, float mul)
{
- params->zoom *= mul;
+ params->zoom_manual = 1;
+ params->zoom_rat *= mul;
+ show_image(params);
+}
+
+static void zoom_set(struct loader_params *params, float mul)
+{
+ params->zoom_manual = 1;
+ params->zoom_rat = mul;
show_image(params);
}
@@ -613,6 +644,11 @@ static void init_backend(const char *backend_opts)
fprintf(stderr, "Failed to initalize backend '%s'n", backend_opts);
exit(1);
}
+
+ if (config.full_screen) {
+ if (GP_BackendIsX11(backend))
+ GP_BackendX11RequestFullscreen(backend, 2);
+ }
}
/*
@@ -679,9 +715,6 @@ int main(int argc, char *argv[])
.show_nn_first = 0,
.resampling_method = GP_INTERP_LINEAR_LF_INT,
- .zoom_type = ZOOM_FIT,
- .zoom = 1,
-
.img_resized_cache = NULL,
.sleep_ms = 0,
@@ -867,10 +900,25 @@ int main(int argc, char *argv[])
params.show_progress_once = 1;
show_image(¶ms);
break;
- case GP_KEY_D:
+ case GP_KEY_C:
image_cache_drop(params.img_resized_cache);
image_loader_drop_cache();
break;
+ case GP_KEY_W:
+ config_win_toggle();
+ params.show_progress_once = 1;
+ show_image(¶ms);
+ break;
+ case GP_KEY_U:
+ config_upscale_toggle();
+ params.show_progress_once = 1;
+ show_image(¶ms);
+ break;
+ case GP_KEY_D:
+ config_downscale_toggle();
+ params.show_progress_once = 1;
+ show_image(¶ms);
+ break;
case GP_KEY_ESC:
case GP_KEY_ENTER:
case GP_KEY_Q:
@@ -938,21 +986,34 @@ int main(int argc, char *argv[])
image_seek(¶ms, IMG_CUR, -1);
break;
case GP_KEY_1 ... GP_KEY_9: {
- int val = ev.val.key.key - GP_KEY_1 + 1;
- resize_backend(val, shift_flag);
+ float val = ev.val.key.key - GP_KEY_1 + 1;
+
+ if (!shift_flag)
+ val = 1/val;
+
+ zoom_set(¶ms, val);
} break;
case GP_KEY_0:
- resize_backend(10, shift_flag);
+ if (shift_flag)
+ zoom_set(¶ms, 10);
+ else
+ zoom_set(¶ms, 0.1);
break;
case GP_KEY_KP_PLUS:
case GP_KEY_DOT:
params.show_progress_once = 1;
- zoom_mul(¶ms, 1.5);
+ if (shift_flag)
+ zoom_mul(¶ms, 1.1);
+ else
+ zoom_mul(¶ms, 1.5);
break;
case GP_KEY_KP_MINUS:
case GP_KEY_COMMA:
params.show_progress_once = 1;
- zoom_mul(¶ms, 1/1.5);
+ if (shift_flag)
+ zoom_mul(¶ms, 1/1.1);
+ else
+ zoom_mul(¶ms, 1/1.5);
break;
case GP_KEY_F1 ... GP_KEY_F10:
image_action_run(ev.val.key.key - GP_KEY_F1,
diff --git a/demos/spiv/spiv_config.c b/demos/spiv/spiv_config.c
index 44a16d1..166a28c 100644
--- a/demos/spiv/spiv_config.c
+++ b/demos/spiv/spiv_config.c
@@ -36,14 +36,68 @@ struct spiv_config config = {
.show_info = 0,
.backend_init = "X11",
.emul_type = GP_PIXEL_UNKNOWN,
+ .zoom_strategy = ZOOM_IMAGE_DOWNSCALE,
+ .win_strategy = ZOOM_WIN_FIXED,
+ .full_screen = 0,
+ .max_win_w = 1024,
+ .max_win_h = 768,
};
static int set_zoom_strategy(struct cfg_opt *self, unsigned int lineno)
{
- (void) lineno;
- //TODO!!!
- printf("ZoomStrategy = %sn", self->val);
+ switch (self->opt) {
+ case 'w':
+ switch (self->val[0]) {
+ case 'r':
+ case 'R':
+ config.win_strategy = ZOOM_WIN_RESIZABLE;
+ return 0;
+ case 'f':
+ case 'F':
+ config.win_strategy = ZOOM_WIN_FIXED;
+ return 0;
+ }
+ break;
+ case 'z':
+ switch (self->val[0]) {
+ case 'n':
+ case 'N':
+ config.zoom_strategy = 0;
+ return 0;
+ case 'u':
+ case 'U':
+ config.zoom_strategy = ZOOM_IMAGE_UPSCALE;
+ return 0;
+ case 'd':
+ case 'D':
+ config.zoom_strategy = ZOOM_IMAGE_DOWNSCALE;
+ return 0;
+ case 'b':
+ case 'B':
+ config.zoom_strategy = ZOOM_IMAGE_UPSCALE |
+ ZOOM_IMAGE_DOWNSCALE;
+ return 0;
+ }
+ break;
+ }
+
+ fprintf(stderr, "ERROR: %u: Invalid zoom strategy '%s'n",
+ lineno, self->val);
+ return 1;
+}
+
+static int set_win_max_size(struct cfg_opt *self, unsigned int lineno)
+{
+ unsigned int w, h;
+
+ if (sscanf(self->val, "%ux%u", &w, &h) != 2) {
+ fprintf(stderr, "ERROR: %u: Invalid max window size '%s'n",
+ lineno, self->val);
+ return 1;
+ }
+ config.max_win_w = w;
+ config.max_win_h = h;
return 0;
}
@@ -60,9 +114,12 @@ static int set_opt(struct cfg_opt *self, unsigned int lineno)
(void) lineno;
switch (self->opt) {
- case 'f':
+ case 'd':
config.floyd_steinberg = 1;
break;
+ case 'f':
+ config.full_screen = 1;
+ break;
case 'i':
config.show_info = 1;
break;
@@ -195,9 +252,9 @@ struct cfg_opt spiv_opts[] = {
.help = "Delay between images in seconds (float) for slideshow",
},
{.name_space = "Gui",
- .key = "UseFloydSteinberg",
- .opt = 'f',
- .opt_long = "floyd-steinberg",
+ .key = "Dithering",
+ .opt = 'd',
+ .opt_long = "dithering",
.opt_has_value = 0,
.set = set_opt,
.help = "Turn on Floyd-Steinberg dithering",
@@ -211,6 +268,14 @@ struct cfg_opt spiv_opts[] = {
.help = "Orientation, one of 0, 90, 180, 270",
},
{.name_space = "Gui",
+ .key = "FullScreen",
+ .opt = 'f',
+ .opt_long = "full-screen",
+ .opt_has_value = 0,
+ .set = set_opt,
+ .help = "Start fullscreen.",
+ },
+ {.name_space = "Gui",
.key = "BackendInit",
.opt = 'b',
.opt_long = "backend-init",
@@ -220,12 +285,29 @@ struct cfg_opt spiv_opts[] = {
},
{.name_space = "Zoom",
+ .key = "WindowSize",
+ .opt = 'w',
+ .opt_long = "window-size",
+ .opt_has_value = 1,
+ .set = set_zoom_strategy,
+ .help = "Window size, resizeable (-wr) or fixed (-wf)",
+ },
+ {.name_space = "Zoom",
.key = "ZoomStrategy",
.opt = 'z',
.opt_long = "zoom-strategy",
.opt_has_value = 1,
.set = set_zoom_strategy,
- .help = "Zoom strategy",
+ .help = "Zoom strategy, none (-zn), upscale (-zu), "
+ "downscale (-zd) or both (-zb)",
+ },
+ {.name_space = "Zoom",
+ .key = "MaxWinSize",
+ .opt = 'm',
+ .opt_long = "max-win-size",
+ .opt_has_value = 1,
+ .set = set_win_max_size,
+ .help = "Window maximal size, 800x600 for example",
},
diff --git a/demos/spiv/spiv_config.h b/demos/spiv/spiv_config.h
index 41a83b2..e4a5c12 100644
--- a/demos/spiv/spiv_config.h
+++ b/demos/spiv/spiv_config.h
@@ -32,19 +32,53 @@ enum orientation {
ROTATE_270,
};
+enum zoom_strategy {
+ /* Resize window to content size */
+ ZOOM_WIN_RESIZABLE = 0x00,
+ /* Do not change window size */
+ ZOOM_WIN_FIXED = 0x01,
+
+ /* Upscale image if window is bigger */
+ ZOOM_IMAGE_UPSCALE = 0x01,
+ /* Downscale image if window is smaller */
+ ZOOM_IMAGE_DOWNSCALE = 0x02,
+};
+
struct spiv_config {
float slideshow_delay;
enum orientation orientation;
+ int win_strategy:2;
+ int zoom_strategy:2;
+ /* Maximal window size */
+ unsigned int max_win_w;
+ unsigned int max_win_h;
+
int show_progress:1;
int show_info:1;
int floyd_steinberg:1;
int timers:1;
+ int full_screen:1;
char backend_init[128];
GP_PixelType emul_type;
};
extern struct spiv_config config;
+static inline void config_win_toggle(void)
+{
+ config.win_strategy = !config.win_strategy;
+}
+
+static inline void config_upscale_toggle(void)
+{
+ config.zoom_strategy ^= ZOOM_IMAGE_UPSCALE;
+}
+
+static inline void config_downscale_toggle(void)
+{
+ config.zoom_strategy ^= ZOOM_IMAGE_DOWNSCALE;
+}
+
int spiv_config_load(const char *path);
int spiv_config_parse_args(int argc, char *argv[]);
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
index 0d6a6b6..b3d25da 100644
--- a/demos/spiv/spiv_help.c
+++ b/demos/spiv/spiv_help.c
@@ -43,6 +43,9 @@ static struct key_help help_keys[] = {
{"End", "Move to the last image"},
{"R", "Rotate by 90 degrees clockwise"},
{"E", "Rotate by 90 degrees counterclockwise"},
+ {"W", "Toggle fixed, resizable window"},
+ {"D", "Turn on/off downscale when image is larger than win"},
+ {"U", "Turn on/off upscale when image is smaller than win"},
{"H", "Show help"},
{"I", "Toggle show info box"},
{"P", "Toggle show progress"},
@@ -50,16 +53,16 @@ static struct key_help help_keys[] = {
{"", ""},
{"F1-F10", "Execute action 1 - 10"},
{"", ""},
- {"<, KP Minus", "Zoom out by 50%"},
- {">, KP Plus", "Zoom in by 50%"},
- {"1", "Resize spiv window to the image size"},
- {"2", "Resize spiv window to a half of the image size"},
- {"3", "Resize spiv window to one third of the image size"},
- {"9", "Resize spiv window to one ninth of the image size"},
+ {"<, KP Minus", "Zoom out by 50% (by 10% with Shift)"},
+ {">, KP Plus", "Zoom in by 50% (by 10% with Shift)"},
+ {"1", "Resize to the image size"},
+ {"2", "Resize to a half of the image size"},
+ {"3", "Resize to one third of the image size"},
+ {"9", "Resize to one ninth of the image size"},
{"...", ""},
- {"0", "Resize spiv window to one tenth of the image size"},
- {"Shift 2", "Resize spiv window twice of the image size"},
- {"Shift 3", "Resize spiv window three times of the image size"},
+ {"0", "Resize to one tenth of the image size"},
+ {"Shift 2", "Resize twice of the image size"},
+ {"Shift 3", "Resize three times of the image size"},
{"...", ""},
{"Up", "Move image by 1px up (by 10 with Shift)"},
{"Down", "Move image by 1px down (by 10 with Shift)"},
@@ -69,7 +72,7 @@ static struct key_help help_keys[] = {
{"]", "Change to next resampling method"},
{"[", "Change to prev resampling method"},
{"L", "Toggle low pass filter"},
- {"D", "Drop image cache"},
+ {"C", "Drop image cache"},
};
static const int help_keys_len = sizeof(help_keys) / sizeof(*help_keys);
@@ -90,7 +93,7 @@ static const struct examples examples[] = {
"Runs slideshow with 5 second delay"},
{"spiv -1 'cp %F sorted' images/",
"Copies currently loaded image into directory 'sorted/' on pressing F1"},
- {"spiv -e G1 -f images/",
+ {"spiv -e G1 -d images/",
"Emulates 1-bit Grayscale display and turns on Floyd-Steinberg dithering"},
{"spiv -b 'X11:ROOT_WIN' -t 10 images/",
"Runs slideshow using X root window as backend window"},
http://repo.or.cz/w/gfxprim.git/commit/563e33e98b525b7b07f233389e7c522bbfd7…
commit 563e33e98b525b7b07f233389e7c522bbfd7aaec
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 23:21:13 2013 +0100
doc: Update dithering documentation.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/filters_dithering.txt b/doc/filters_dithering.txt
index 91ac47f..2f2605b 100644
--- a/doc/filters_dithering.txt
+++ b/doc/filters_dithering.txt
@@ -106,54 +106,6 @@ returned.
Not all pixel types all supported. If particular combination is not supported
the function returns 'NULL' and sets errno to 'ENOSYS'.
-Example Images
-^^^^^^^^^^^^^^
-All following images were generated using 'grinder'.
-(Click for bigger size)
-
-.Original Image; Floyd-Steinberg, Hilbert-Peano: 1-bit, 2-bit, 4-bit, 8-bit Grayscale; 1-bit, 2-bit, 3-bit (per channel) RGB
-image:images/dither/lenna_small.png[
- "Original Image",
- link="images/dither/lenna.png"]
-image:images/dither/lenna_G1_FS_small.png[
- "1-bit Grayscale Floyd-Steinberg",
- link="images/dither/lenna_G1_FS.png"]
-image:images/dither/lenna_G1_HP_small.png[
- "1-bit Grayscale Hilbert-Peano",
- link="images/dither/lenna_G1_HP.png"]
-image:images/dither/lenna_G2_FS_small.png[
- "2-bit Grayscale Floyd-Steinberg",
- link="images/dither/lenna_G2_FS.png"]
-image:images/dither/lenna_G2_HP_small.png[
- "2-bit Grayscale Hilbert-Peano",
- link="images/dither/lenna_G2_HP.png"]
-image:images/dither/lenna_G4_FS_small.png[
- "4-bit Grayscale Floyd-Steinberg",
- link="images/dither/lenna_G4_FS.png"]
-image:images/dither/lenna_G4_HP_small.png[
- "4-bit Grayscale Hilbert-Peano",
- link="images/dither/lenna_G4_HP.png"]
-image:images/dither/lenna_G8_FS_small.png[
- "8-bit Grayscale Floyd-Steinberg",
- link="images/dither/lenna_G8_FS.png"]
-image:images/dither/lenna_G8_HP_small.png[
- "7-bit Grayscale Hilbert-Peano",
- link="images/dither/lenna_G8_HP.png"]
-image:images/dither/lenna_RGB111_FS_small.png[
- "1-bit RGB Floyd-Steinberg",
- link="images/dither/lenna_RGB111_FS.png"]
-image:images/dither/lenna_RGB111_HP_small.png[
- "1-bit RGB Hilbert-Peano",
- link="images/dither/lenna_RGB111_HP.png"]
-image:images/dither/lenna_RGB222_FS_small.png[
- "2-bit RGB Floyd-Steinberg",
- link="images/dither/lenna_RGB222_FS.png"]
-image:images/dither/lenna_RGB222_HP_small.png[
- "2-bit RGB Hilbert-Peano",
- link="images/dither/lenna_RGB222_HP.png"]
-image:images/dither/lenna_RGB333_FS_small.png[
- "3-bit RGB Floyd-Steinberg",
- link="images/dither/lenna_RGB333_FS.png"]
-image:images/dither/lenna_RGB333_HP_small.png[
- "3-bit RGB Hilbert-Peano",
- link="images/dither/lenna_RGB333_HP.png"]
+include::images/convert/images.txt[]
+include::images/floyd_steinberg/images.txt[]
+include::images/hilbert_peano/images.txt[]
diff --git a/doc/filters_python.txt b/doc/filters_python.txt
index f1a438a..a1d260a 100644
--- a/doc/filters_python.txt
+++ b/doc/filters_python.txt
@@ -374,6 +374,10 @@ dithering documentation].
TIP: See link:example_py_dithering.html[dithering example].
+include::images/convert/images.txt[]
+include::images/floyd_steinberg/images.txt[]
+include::images/hilbert_peano/images.txt[]
+
Median
~~~~~~
diff --git a/doc/images/convert/images.txt b/doc/images/convert/images.txt
new file mode 100644
index 0000000..63b25ef
--- /dev/null
+++ b/doc/images/convert/images.txt
@@ -0,0 +1,20 @@
+.Original Image; Simple Conversion: RGB332, G8, G4, G2, G1
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/convert/lenna_small_8.png[
+ "RGB332",
+ link="images/convert/lenna_8.png"]
+image:images/convert/lenna_small_16.png[
+ "G8",
+ link="images/convert/lenna_16.png"]
+image:images/convert/lenna_small_15.png[
+ "G4",
+ link="images/convert/lenna_15.png"]
+image:images/convert/lenna_small_14.png[
+ "G2",
+ link="images/convert/lenna_14.png"]
+image:images/convert/lenna_small_13.png[
+ "G1",
+ link="images/convert/lenna_13.png"]
+
diff --git a/doc/images/convert/lenna_12.png b/doc/images/convert/lenna_12.png
new file mode 100644
index 0000000..2df6882
Binary files /dev/null and b/doc/images/convert/lenna_12.png differ
diff --git a/doc/images/convert/lenna_13.png b/doc/images/convert/lenna_13.png
new file mode 100644
index 0000000..2df6882
Binary files /dev/null and b/doc/images/convert/lenna_13.png differ
diff --git a/doc/images/convert/lenna_14.png b/doc/images/convert/lenna_14.png
new file mode 100644
index 0000000..86cf79d
Binary files /dev/null and b/doc/images/convert/lenna_14.png differ
diff --git a/doc/images/convert/lenna_15.png b/doc/images/convert/lenna_15.png
new file mode 100644
index 0000000..2edb82b
Binary files /dev/null and b/doc/images/convert/lenna_15.png differ
diff --git a/doc/images/convert/lenna_16.png b/doc/images/convert/lenna_16.png
new file mode 100644
index 0000000..4a4641d
Binary files /dev/null and b/doc/images/convert/lenna_16.png differ
diff --git a/doc/images/convert/lenna_5.png b/doc/images/convert/lenna_5.png
new file mode 100644
index 0000000..a2ec3ad
Binary files /dev/null and b/doc/images/convert/lenna_5.png differ
diff --git a/doc/images/convert/lenna_6.png b/doc/images/convert/lenna_6.png
new file mode 100644
index 0000000..71866be
Binary files /dev/null and b/doc/images/convert/lenna_6.png differ
diff --git a/doc/images/convert/lenna_8.png b/doc/images/convert/lenna_8.png
new file mode 100644
index 0000000..0be1aa1
Binary files /dev/null and b/doc/images/convert/lenna_8.png differ
diff --git a/doc/images/convert/lenna_small_12.png b/doc/images/convert/lenna_small_12.png
new file mode 100644
index 0000000..d8206be
Binary files /dev/null and b/doc/images/convert/lenna_small_12.png differ
diff --git a/doc/images/convert/lenna_small_13.png b/doc/images/convert/lenna_small_13.png
new file mode 100644
index 0000000..d8206be
Binary files /dev/null and b/doc/images/convert/lenna_small_13.png differ
diff --git a/doc/images/convert/lenna_small_14.png b/doc/images/convert/lenna_small_14.png
new file mode 100644
index 0000000..993fd55
Binary files /dev/null and b/doc/images/convert/lenna_small_14.png differ
diff --git a/doc/images/convert/lenna_small_15.png b/doc/images/convert/lenna_small_15.png
new file mode 100644
index 0000000..e89cbd3
Binary files /dev/null and b/doc/images/convert/lenna_small_15.png differ
diff --git a/doc/images/convert/lenna_small_16.png b/doc/images/convert/lenna_small_16.png
new file mode 100644
index 0000000..8815db9
Binary files /dev/null and b/doc/images/convert/lenna_small_16.png differ
diff --git a/doc/images/convert/lenna_small_5.png b/doc/images/convert/lenna_small_5.png
new file mode 100644
index 0000000..3ae10da
Binary files /dev/null and b/doc/images/convert/lenna_small_5.png differ
diff --git a/doc/images/convert/lenna_small_6.png b/doc/images/convert/lenna_small_6.png
new file mode 100644
index 0000000..5d9e3bd
Binary files /dev/null and b/doc/images/convert/lenna_small_6.png differ
diff --git a/doc/images/convert/lenna_small_8.png b/doc/images/convert/lenna_small_8.png
new file mode 100644
index 0000000..0fc857f
Binary files /dev/null and b/doc/images/convert/lenna_small_8.png differ
diff --git a/doc/images/convolution/images.txt b/doc/images/convolution/images.txt
index cf82020..b323b37 100644
--- a/doc/images/convolution/images.txt
+++ b/doc/images/convolution/images.txt
@@ -1,4 +1,4 @@
-.Original Image; 3x3 Box Blur, 5x5 Box Blur, 3x3 Laplacian, 3x3 Sobel, 3x3 Roberts
+.Original Image; Convolution: 3x3 Box Blur, 5x5 Box Blur, 3x3 Laplacian, 3x3 Sobel, 3x3 Roberts
image:images/orig/lenna_small.png[
"Original Image",
link="images/orig/lenna.png"]
diff --git a/doc/images/dither/lenna.png b/doc/images/dither/lenna.png
deleted file mode 100644
index 475bc7a..0000000
Binary files a/doc/images/dither/lenna.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G1_FS.png b/doc/images/dither/lenna_G1_FS.png
deleted file mode 100644
index 9f0e2c4..0000000
Binary files a/doc/images/dither/lenna_G1_FS.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G1_FS_small.png b/doc/images/dither/lenna_G1_FS_small.png
deleted file mode 100644
index 0083f5d..0000000
Binary files a/doc/images/dither/lenna_G1_FS_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G1_HP.png b/doc/images/dither/lenna_G1_HP.png
deleted file mode 100644
index f4db5f5..0000000
Binary files a/doc/images/dither/lenna_G1_HP.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G1_HP_small.png b/doc/images/dither/lenna_G1_HP_small.png
deleted file mode 100644
index 328f1c0..0000000
Binary files a/doc/images/dither/lenna_G1_HP_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G2_FS.png b/doc/images/dither/lenna_G2_FS.png
deleted file mode 100644
index 8854b47..0000000
Binary files a/doc/images/dither/lenna_G2_FS.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G2_FS_small.png b/doc/images/dither/lenna_G2_FS_small.png
deleted file mode 100644
index 3c43f97..0000000
Binary files a/doc/images/dither/lenna_G2_FS_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G2_HP.png b/doc/images/dither/lenna_G2_HP.png
deleted file mode 100644
index 2c15fc0..0000000
Binary files a/doc/images/dither/lenna_G2_HP.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G2_HP_small.png b/doc/images/dither/lenna_G2_HP_small.png
deleted file mode 100644
index 292cab6..0000000
Binary files a/doc/images/dither/lenna_G2_HP_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G4_FS.png b/doc/images/dither/lenna_G4_FS.png
deleted file mode 100644
index 207f703..0000000
Binary files a/doc/images/dither/lenna_G4_FS.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G4_FS_small.png b/doc/images/dither/lenna_G4_FS_small.png
deleted file mode 100644
index f5017c5..0000000
Binary files a/doc/images/dither/lenna_G4_FS_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G4_HP.png b/doc/images/dither/lenna_G4_HP.png
deleted file mode 100644
index ae696a3..0000000
Binary files a/doc/images/dither/lenna_G4_HP.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G4_HP_small.png b/doc/images/dither/lenna_G4_HP_small.png
deleted file mode 100644
index 9ff7370..0000000
Binary files a/doc/images/dither/lenna_G4_HP_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G8_FS.png b/doc/images/dither/lenna_G8_FS.png
deleted file mode 100644
index 976e32a..0000000
Binary files a/doc/images/dither/lenna_G8_FS.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G8_FS_small.png b/doc/images/dither/lenna_G8_FS_small.png
deleted file mode 100644
index f0f6fdf..0000000
Binary files a/doc/images/dither/lenna_G8_FS_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G8_HP.png b/doc/images/dither/lenna_G8_HP.png
deleted file mode 100644
index 976e32a..0000000
Binary files a/doc/images/dither/lenna_G8_HP.png and /dev/null differ
diff --git a/doc/images/dither/lenna_G8_HP_small.png b/doc/images/dither/lenna_G8_HP_small.png
deleted file mode 100644
index f0f6fdf..0000000
Binary files a/doc/images/dither/lenna_G8_HP_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB111_FS.png b/doc/images/dither/lenna_RGB111_FS.png
deleted file mode 100644
index 732ba24..0000000
Binary files a/doc/images/dither/lenna_RGB111_FS.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB111_FS_small.png b/doc/images/dither/lenna_RGB111_FS_small.png
deleted file mode 100644
index 759ab88..0000000
Binary files a/doc/images/dither/lenna_RGB111_FS_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB111_HP.png b/doc/images/dither/lenna_RGB111_HP.png
deleted file mode 100644
index 33a471f..0000000
Binary files a/doc/images/dither/lenna_RGB111_HP.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB111_HP_small.png b/doc/images/dither/lenna_RGB111_HP_small.png
deleted file mode 100644
index 444a1bf..0000000
Binary files a/doc/images/dither/lenna_RGB111_HP_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB222_FS.png b/doc/images/dither/lenna_RGB222_FS.png
deleted file mode 100644
index 9d91a5e..0000000
Binary files a/doc/images/dither/lenna_RGB222_FS.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB222_FS_small.png b/doc/images/dither/lenna_RGB222_FS_small.png
deleted file mode 100644
index 92a03d2..0000000
Binary files a/doc/images/dither/lenna_RGB222_FS_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB222_HP.png b/doc/images/dither/lenna_RGB222_HP.png
deleted file mode 100644
index fd22e14..0000000
Binary files a/doc/images/dither/lenna_RGB222_HP.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB222_HP_small.png b/doc/images/dither/lenna_RGB222_HP_small.png
deleted file mode 100644
index e1296aa..0000000
Binary files a/doc/images/dither/lenna_RGB222_HP_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB333_FS.png b/doc/images/dither/lenna_RGB333_FS.png
deleted file mode 100644
index 7b2d4c9..0000000
Binary files a/doc/images/dither/lenna_RGB333_FS.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB333_FS_small.png b/doc/images/dither/lenna_RGB333_FS_small.png
deleted file mode 100644
index 45f62c9..0000000
Binary files a/doc/images/dither/lenna_RGB333_FS_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB333_HP.png b/doc/images/dither/lenna_RGB333_HP.png
deleted file mode 100644
index a155107..0000000
Binary files a/doc/images/dither/lenna_RGB333_HP.png and /dev/null differ
diff --git a/doc/images/dither/lenna_RGB333_HP_small.png b/doc/images/dither/lenna_RGB333_HP_small.png
deleted file mode 100644
index 0fecb6b..0000000
Binary files a/doc/images/dither/lenna_RGB333_HP_small.png and /dev/null differ
diff --git a/doc/images/dither/lenna_small.png b/doc/images/dither/lenna_small.png
deleted file mode 100644
index ad258a1..0000000
Binary files a/doc/images/dither/lenna_small.png and /dev/null differ
diff --git a/doc/images/floyd_steinberg/images.txt b/doc/images/floyd_steinberg/images.txt
new file mode 100644
index 0000000..f25d162
--- /dev/null
+++ b/doc/images/floyd_steinberg/images.txt
@@ -0,0 +1,20 @@
+.Original Image; Floyd Steinberg Dithering: RGB332, G8, G4, G2, G1
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/floyd_steinberg/lenna_small_8.png[
+ "RGB332",
+ link="images/floyd_steinberg/lenna_8.png"]
+image:images/floyd_steinberg/lenna_small_16.png[
+ "G8",
+ link="images/floyd_steinberg/lenna_16.png"]
+image:images/floyd_steinberg/lenna_small_15.png[
+ "G4",
+ link="images/floyd_steinberg/lenna_15.png"]
+image:images/floyd_steinberg/lenna_small_14.png[
+ "G2",
+ link="images/floyd_steinberg/lenna_14.png"]
+image:images/floyd_steinberg/lenna_small_13.png[
+ "G1",
+ link="images/floyd_steinberg/lenna_13.png"]
+
diff --git a/doc/images/floyd_steinberg/lenna_12.png b/doc/images/floyd_steinberg/lenna_12.png
new file mode 100644
index 0000000..664d364
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_12.png differ
diff --git a/doc/images/floyd_steinberg/lenna_13.png b/doc/images/floyd_steinberg/lenna_13.png
new file mode 100644
index 0000000..664d364
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_13.png differ
diff --git a/doc/images/floyd_steinberg/lenna_14.png b/doc/images/floyd_steinberg/lenna_14.png
new file mode 100644
index 0000000..115fe52
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_14.png differ
diff --git a/doc/images/floyd_steinberg/lenna_15.png b/doc/images/floyd_steinberg/lenna_15.png
new file mode 100644
index 0000000..377b417
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_15.png differ
diff --git a/doc/images/floyd_steinberg/lenna_16.png b/doc/images/floyd_steinberg/lenna_16.png
new file mode 100644
index 0000000..8ebeb93
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_16.png differ
diff --git a/doc/images/floyd_steinberg/lenna_5.png b/doc/images/floyd_steinberg/lenna_5.png
new file mode 100644
index 0000000..fdc023d
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_5.png differ
diff --git a/doc/images/floyd_steinberg/lenna_6.png b/doc/images/floyd_steinberg/lenna_6.png
new file mode 100644
index 0000000..cc39931
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_6.png differ
diff --git a/doc/images/floyd_steinberg/lenna_8.png b/doc/images/floyd_steinberg/lenna_8.png
new file mode 100644
index 0000000..706c876
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_8.png differ
diff --git a/doc/images/floyd_steinberg/lenna_small_12.png b/doc/images/floyd_steinberg/lenna_small_12.png
new file mode 100644
index 0000000..79b8220
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_small_12.png differ
diff --git a/doc/images/floyd_steinberg/lenna_small_13.png b/doc/images/floyd_steinberg/lenna_small_13.png
new file mode 100644
index 0000000..79b8220
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_small_13.png differ
diff --git a/doc/images/floyd_steinberg/lenna_small_14.png b/doc/images/floyd_steinberg/lenna_small_14.png
new file mode 100644
index 0000000..035c94e
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_small_14.png differ
diff --git a/doc/images/floyd_steinberg/lenna_small_15.png b/doc/images/floyd_steinberg/lenna_small_15.png
new file mode 100644
index 0000000..42a89fb
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_small_15.png differ
diff --git a/doc/images/floyd_steinberg/lenna_small_16.png b/doc/images/floyd_steinberg/lenna_small_16.png
new file mode 100644
index 0000000..35c4e6a
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_small_16.png differ
diff --git a/doc/images/floyd_steinberg/lenna_small_5.png b/doc/images/floyd_steinberg/lenna_small_5.png
new file mode 100644
index 0000000..a1ac89f
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_small_5.png differ
diff --git a/doc/images/floyd_steinberg/lenna_small_6.png b/doc/images/floyd_steinberg/lenna_small_6.png
new file mode 100644
index 0000000..4f752a7
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_small_6.png differ
diff --git a/doc/images/floyd_steinberg/lenna_small_8.png b/doc/images/floyd_steinberg/lenna_small_8.png
new file mode 100644
index 0000000..8fb3b13
Binary files /dev/null and b/doc/images/floyd_steinberg/lenna_small_8.png differ
diff --git a/doc/images/hilbert_peano/images.txt b/doc/images/hilbert_peano/images.txt
new file mode 100644
index 0000000..31f4b85
--- /dev/null
+++ b/doc/images/hilbert_peano/images.txt
@@ -0,0 +1,20 @@
+.Original Image; Hilbert Peano Dithering: RGB332, G8, G4, G2, G1
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/hilbert_peano/lenna_small_8.png[
+ "RGB332",
+ link="images/hilbert_peano/lenna_8.png"]
+image:images/hilbert_peano/lenna_small_16.png[
+ "G8",
+ link="images/hilbert_peano/lenna_16.png"]
+image:images/hilbert_peano/lenna_small_15.png[
+ "G4",
+ link="images/hilbert_peano/lenna_15.png"]
+image:images/hilbert_peano/lenna_small_14.png[
+ "G2",
+ link="images/hilbert_peano/lenna_14.png"]
+image:images/hilbert_peano/lenna_small_13.png[
+ "G1",
+ link="images/hilbert_peano/lenna_13.png"]
+
diff --git a/doc/images/hilbert_peano/lenna_12.png b/doc/images/hilbert_peano/lenna_12.png
new file mode 100644
index 0000000..beeaecc
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_12.png differ
diff --git a/doc/images/hilbert_peano/lenna_13.png b/doc/images/hilbert_peano/lenna_13.png
new file mode 100644
index 0000000..beeaecc
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_13.png differ
diff --git a/doc/images/hilbert_peano/lenna_14.png b/doc/images/hilbert_peano/lenna_14.png
new file mode 100644
index 0000000..44c1323
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_14.png differ
diff --git a/doc/images/hilbert_peano/lenna_15.png b/doc/images/hilbert_peano/lenna_15.png
new file mode 100644
index 0000000..fa0a067
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_15.png differ
diff --git a/doc/images/hilbert_peano/lenna_16.png b/doc/images/hilbert_peano/lenna_16.png
new file mode 100644
index 0000000..acb2c11
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_16.png differ
diff --git a/doc/images/hilbert_peano/lenna_5.png b/doc/images/hilbert_peano/lenna_5.png
new file mode 100644
index 0000000..35eb618
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_5.png differ
diff --git a/doc/images/hilbert_peano/lenna_6.png b/doc/images/hilbert_peano/lenna_6.png
new file mode 100644
index 0000000..105f9d1
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_6.png differ
diff --git a/doc/images/hilbert_peano/lenna_8.png b/doc/images/hilbert_peano/lenna_8.png
new file mode 100644
index 0000000..5201263
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_8.png differ
diff --git a/doc/images/hilbert_peano/lenna_small_12.png b/doc/images/hilbert_peano/lenna_small_12.png
new file mode 100644
index 0000000..399e7de
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_small_12.png differ
diff --git a/doc/images/hilbert_peano/lenna_small_13.png b/doc/images/hilbert_peano/lenna_small_13.png
new file mode 100644
index 0000000..399e7de
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_small_13.png differ
diff --git a/doc/images/hilbert_peano/lenna_small_14.png b/doc/images/hilbert_peano/lenna_small_14.png
new file mode 100644
index 0000000..f470468
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_small_14.png differ
diff --git a/doc/images/hilbert_peano/lenna_small_15.png b/doc/images/hilbert_peano/lenna_small_15.png
new file mode 100644
index 0000000..6746191
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_small_15.png differ
diff --git a/doc/images/hilbert_peano/lenna_small_16.png b/doc/images/hilbert_peano/lenna_small_16.png
new file mode 100644
index 0000000..9988d3d
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_small_16.png differ
diff --git a/doc/images/hilbert_peano/lenna_small_5.png b/doc/images/hilbert_peano/lenna_small_5.png
new file mode 100644
index 0000000..0c72eea
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_small_5.png differ
diff --git a/doc/images/hilbert_peano/lenna_small_6.png b/doc/images/hilbert_peano/lenna_small_6.png
new file mode 100644
index 0000000..106c8b3
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_small_6.png differ
diff --git a/doc/images/hilbert_peano/lenna_small_8.png b/doc/images/hilbert_peano/lenna_small_8.png
new file mode 100644
index 0000000..e9eda29
Binary files /dev/null and b/doc/images/hilbert_peano/lenna_small_8.png differ
diff --git a/doc/images/regen.py b/doc/images/regen.py
index 3e01756..ba540aa 100755
--- a/doc/images/regen.py
+++ b/doc/images/regen.py
@@ -33,6 +33,11 @@ def to_str(x, to_str):
return res
+def convert(ctx):
+ if (ctx.pixel_type == core.C.PIXEL_RGB332):
+ return ctx.Convert(core.C.PIXEL_RGB888)
+ return ctx
+
class ImgGen:
def __init__(self, orig_path):
self.orig_path = orig_path
@@ -66,7 +71,7 @@ class ImgGen:
str(x[i]) for i in range(0, len(x))]), func_params_arr))
if (descs is not None):
- head = ', '.join(descs)
+ head = func_name + ': ' + ', '.join(descs)
self.write_asciidoc_head(dst_path, head)
@@ -86,10 +91,10 @@ class ImgGen:
self.write_img_asciidoc(desc, fname, fname_small)
- res = func(self.img, *params)
+ res = convert(func(self.img, *params))
res.loaders.Save('../' + fname)
- res = func(self.img_small, *params)
+ res = convert(func(self.img_small, *params))
res.loaders.Save('../' + fname_small)
self.write_asciidoc_tail()
@@ -180,5 +185,42 @@ def main():
'3x3 Sobel',
'3x3 Roberts'])
+ imggen.gen(core.Convert, ['p'],
+ [
+ [core.C.PIXEL_RGB332],
+ [core.C.PIXEL_G8],
+ [core.C.PIXEL_G4],
+ [core.C.PIXEL_G2],
+ [core.C.PIXEL_G1],
+ ],
+ 'images/convert/',
+ 'Simple Conversion',
+ ['RGB332', 'G8', 'G4', 'G2', 'G1'])
+
+ imggen.gen(filters.FloydSteinbergAlloc, ['p'],
+ [
+ [core.C.PIXEL_RGB332],
+ [core.C.PIXEL_G8],
+ [core.C.PIXEL_G4],
+ [core.C.PIXEL_G2],
+ [core.C.PIXEL_G1],
+ ],
+ 'images/floyd_steinberg/',
+ 'Floyd Steinberg Dithering',
+ ['RGB332', 'G8', 'G4', 'G2', 'G1'])
+
+ imggen.gen(filters.HilbertPeanoAlloc, ['p'],
+ [
+ [core.C.PIXEL_RGB332],
+ [core.C.PIXEL_G8],
+ [core.C.PIXEL_G4],
+ [core.C.PIXEL_G2],
+ [core.C.PIXEL_G1],
+ ],
+ 'images/hilbert_peano/',
+ 'Hilbert Peano Dithering',
+ ['RGB332', 'G8', 'G4', 'G2', 'G1'])
+
+
if __name__ == '__main__':
main()
http://repo.or.cz/w/gfxprim.git/commit/ef19efc738739865ba6ff4cb33cdec083f7c…
commit ef19efc738739865ba6ff4cb33cdec083f7ccc76
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 23:17:13 2013 +0100
gfxprim_config.py: Add RGB332 8BPP.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/gfxprim_config.py b/gfxprim_config.py
index 4dcba55..b972c0e 100644
--- a/gfxprim_config.py
+++ b/gfxprim_config.py
@@ -81,6 +81,11 @@ config = GfxPrimConfig(
('G', 6, 6),
('B', 0, 6)]),
+ PixelType(name='RGB332', pixelsize=PS_8BPP, chanslist=[
+ ('R', 5, 3),
+ ('G', 2, 3),
+ ('B', 0, 2)]),
+
#
# CMYK
#
http://repo.or.cz/w/gfxprim.git/commit/9d8b39521423cbcc9702984c90e9c304036d…
commit 9d8b39521423cbcc9702984c90e9c304036d0de5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 23:10:08 2013 +0100
pywrap: core: Add Convert to module.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/core/__init__.py b/pylib/gfxprim/core/__init__.py
index 9ad8eea..00bba2a 100644
--- a/pylib/gfxprim/core/__init__.py
+++ b/pylib/gfxprim/core/__init__.py
@@ -195,9 +195,10 @@ def _init(module):
'^GP_PixelRGB.*$', # ...Lookup and ...Match
'^GP_PixelToRGB.*$', # Needs love
'^GP_RGB.*$', # Needs filtering
- #'^GP_ProgressCallback.*$', # Needs work
])
+ module['Convert'] = c_core.GP_ContextConvertAlloc
+
_init(locals())
del _init
http://repo.or.cz/w/gfxprim.git/commit/37aec8794533c757d224024fa3ab570dd3a6…
commit 37aec8794533c757d224024fa3ab570dd3a63b2b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 22:10:14 2013 +0100
doc: Fix typos.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/core_python.txt b/doc/core_python.txt
index cd60469..033846d 100644
--- a/doc/core_python.txt
+++ b/doc/core_python.txt
@@ -142,9 +142,9 @@ Debug Functions
-------------------------------------------------------------------------------
import gfxprim.core as core
- core.GP_SetDebugLevel(10)
+ core.SetDebugLevel(10)
- level = core.GP_GetDebugLevel()
+ level = core.GetDebugLevel()
-------------------------------------------------------------------------------
Sets and gets the GFXprim debug level. See link:debug.html[debug messages]
http://repo.or.cz/w/gfxprim.git/commit/7d2fc29b64483d7cb8afafa3788e85b7080c…
commit 7d2fc29b64483d7cb8afafa3788e85b7080c46a3
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 22:00:28 2013 +0100
doc: Update the about page.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/about.txt b/doc/about.txt
index 1dc7ce5..7029823 100644
--- a/doc/about.txt
+++ b/doc/about.txt
@@ -127,8 +127,10 @@ image filters.
[width="100%",options="header"]
|=============================================================================
| Filter Name | Supported Pixel Type | Multithreaded
-| Brightness | All | No
-| Contrast | All | No
+| Brightness | All | Not Applicable
+| Contrast | All | Not Applicable
+| Invert | All | Not Applicable
+| Posterize | All | Not Applicable
|=============================================================================
.Currently Implemented Linear Filters
@@ -142,12 +144,7 @@ image filters.
| Prewitt Edge Detection | RGB888 | Yes
|=============================================================================
-NOTE: Linear filters are implemented using generic convolution filters, once
- convolution is rewritten to run for all pixel types the rest of filters
- will support them automatically.
-
-
-.Currently Implemented Linear Filters
+.Currently Implemented Aritmetic Filters
[width="100%",options="header"]
|=============================================================================
| Filter Name | Supported Pixel Type | Multithreaded
@@ -211,10 +208,10 @@ backend of any pixel type on the top of other backends.
Python bindings
---------------
-Python bindings currently covers most of the library, there is (not yet
-finished) documentation for link:core_python.html[Core],
-link:gfx_python.html[Gfx], link:loaders_python.html[Loaders] and
-link:backends_python.html[Backends].
+Python bindings currently covers most of the library, there is (work in
+progress) documentation for link:core_python.html[Core],
+link:gfx_python.html[Gfx], link:loaders_python.html[Loaders],
+link:filters_python.html[Filters] and link:backends_python.html[Backends].
Work in progress
----------------
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 283 +++++++++++++++----------
demos/spiv/spiv_config.c | 98 ++++++++-
demos/spiv/spiv_config.h | 34 +++
demos/spiv/spiv_help.c | 25 ++-
doc/about.txt | 21 +-
doc/core_python.txt | 4 +-
doc/filters_dithering.txt | 54 +-----
doc/filters_python.txt | 4 +
doc/images/convert/images.txt | 20 ++
doc/images/convert/lenna_12.png | Bin 0 -> 3848 bytes
doc/images/convert/lenna_13.png | Bin 0 -> 3848 bytes
doc/images/convert/lenna_14.png | Bin 0 -> 13581 bytes
doc/images/convert/lenna_15.png | Bin 0 -> 49011 bytes
doc/images/convert/lenna_16.png | Bin 0 -> 133711 bytes
doc/images/convert/lenna_5.png | Bin 0 -> 222762 bytes
doc/images/convert/lenna_6.png | Bin 0 -> 256908 bytes
doc/images/convert/lenna_8.png | Bin 0 -> 94823 bytes
doc/images/convert/lenna_small_12.png | Bin 0 -> 525 bytes
doc/images/convert/lenna_small_13.png | Bin 0 -> 525 bytes
doc/images/convert/lenna_small_14.png | Bin 0 -> 1594 bytes
doc/images/convert/lenna_small_15.png | Bin 0 -> 4711 bytes
doc/images/convert/lenna_small_16.png | Bin 0 -> 10649 bytes
doc/images/convert/lenna_small_5.png | Bin 0 -> 19379 bytes
doc/images/convert/lenna_small_6.png | Bin 0 -> 21801 bytes
doc/images/convert/lenna_small_8.png | Bin 0 -> 9433 bytes
doc/images/convolution/images.txt | 2 +-
doc/images/dither/lenna.png | Bin 394244 -> 0 bytes
doc/images/dither/lenna_G1_FS.png | Bin 44134 -> 0 bytes
doc/images/dither/lenna_G1_FS_small.png | Bin 11690 -> 0 bytes
doc/images/dither/lenna_G1_HP.png | Bin 54940 -> 0 bytes
doc/images/dither/lenna_G1_HP_small.png | Bin 14357 -> 0 bytes
doc/images/dither/lenna_G2_FS.png | Bin 69665 -> 0 bytes
doc/images/dither/lenna_G2_FS_small.png | Bin 18380 -> 0 bytes
doc/images/dither/lenna_G2_HP.png | Bin 74316 -> 0 bytes
doc/images/dither/lenna_G2_HP_small.png | Bin 20234 -> 0 bytes
doc/images/dither/lenna_G4_FS.png | Bin 92560 -> 0 bytes
doc/images/dither/lenna_G4_FS_small.png | Bin 26452 -> 0 bytes
doc/images/dither/lenna_G4_HP.png | Bin 116264 -> 0 bytes
doc/images/dither/lenna_G4_HP_small.png | Bin 31754 -> 0 bytes
doc/images/dither/lenna_G8_FS.png | Bin 221478 -> 0 bytes
doc/images/dither/lenna_G8_FS_small.png | Bin 67801 -> 0 bytes
doc/images/dither/lenna_G8_HP.png | Bin 221478 -> 0 bytes
doc/images/dither/lenna_G8_HP_small.png | Bin 67801 -> 0 bytes
doc/images/dither/lenna_RGB111_FS.png | Bin 109889 -> 0 bytes
doc/images/dither/lenna_RGB111_FS_small.png | Bin 27757 -> 0 bytes
doc/images/dither/lenna_RGB111_HP.png | Bin 124334 -> 0 bytes
doc/images/dither/lenna_RGB111_HP_small.png | Bin 31358 -> 0 bytes
doc/images/dither/lenna_RGB222_FS.png | Bin 162688 -> 0 bytes
doc/images/dither/lenna_RGB222_FS_small.png | Bin 41646 -> 0 bytes
doc/images/dither/lenna_RGB222_HP.png | Bin 167382 -> 0 bytes
doc/images/dither/lenna_RGB222_HP_small.png | Bin 43323 -> 0 bytes
doc/images/dither/lenna_RGB333_FS.png | Bin 196644 -> 0 bytes
doc/images/dither/lenna_RGB333_FS_small.png | Bin 52995 -> 0 bytes
doc/images/dither/lenna_RGB333_HP.png | Bin 227055 -> 0 bytes
doc/images/dither/lenna_RGB333_HP_small.png | Bin 63795 -> 0 bytes
doc/images/dither/lenna_small.png | Bin 116129 -> 0 bytes
doc/images/floyd_steinberg/images.txt | 20 ++
doc/images/floyd_steinberg/lenna_12.png | Bin 0 -> 25518 bytes
doc/images/floyd_steinberg/lenna_13.png | Bin 0 -> 25518 bytes
doc/images/floyd_steinberg/lenna_14.png | Bin 0 -> 32906 bytes
doc/images/floyd_steinberg/lenna_15.png | Bin 0 -> 57697 bytes
doc/images/floyd_steinberg/lenna_16.png | Bin 0 -> 134574 bytes
doc/images/floyd_steinberg/lenna_5.png | Bin 0 -> 283437 bytes
doc/images/floyd_steinberg/lenna_6.png | Bin 0 -> 313739 bytes
doc/images/floyd_steinberg/lenna_8.png | Bin 0 -> 202928 bytes
doc/images/floyd_steinberg/lenna_small_12.png | Bin 0 -> 1860 bytes
doc/images/floyd_steinberg/lenna_small_13.png | Bin 0 -> 1860 bytes
doc/images/floyd_steinberg/lenna_small_14.png | Bin 0 -> 2589 bytes
doc/images/floyd_steinberg/lenna_small_15.png | Bin 0 -> 4878 bytes
doc/images/floyd_steinberg/lenna_small_16.png | Bin 0 -> 10663 bytes
doc/images/floyd_steinberg/lenna_small_5.png | Bin 0 -> 21023 bytes
doc/images/floyd_steinberg/lenna_small_6.png | Bin 0 -> 23240 bytes
doc/images/floyd_steinberg/lenna_small_8.png | Bin 0 -> 14641 bytes
doc/images/hilbert_peano/images.txt | 20 ++
doc/images/hilbert_peano/lenna_12.png | Bin 0 -> 29715 bytes
doc/images/hilbert_peano/lenna_13.png | Bin 0 -> 29715 bytes
doc/images/hilbert_peano/lenna_14.png | Bin 0 -> 38462 bytes
doc/images/hilbert_peano/lenna_15.png | Bin 0 -> 62785 bytes
doc/images/hilbert_peano/lenna_16.png | Bin 0 -> 134812 bytes
doc/images/hilbert_peano/lenna_5.png | Bin 0 -> 323202 bytes
doc/images/hilbert_peano/lenna_6.png | Bin 0 -> 347587 bytes
doc/images/hilbert_peano/lenna_8.png | Bin 0 -> 222712 bytes
doc/images/hilbert_peano/lenna_small_12.png | Bin 0 -> 2067 bytes
doc/images/hilbert_peano/lenna_small_13.png | Bin 0 -> 2067 bytes
doc/images/hilbert_peano/lenna_small_14.png | Bin 0 -> 2847 bytes
doc/images/hilbert_peano/lenna_small_15.png | Bin 0 -> 5233 bytes
doc/images/hilbert_peano/lenna_small_16.png | Bin 0 -> 10687 bytes
doc/images/hilbert_peano/lenna_small_5.png | Bin 0 -> 22327 bytes
doc/images/hilbert_peano/lenna_small_6.png | Bin 0 -> 24315 bytes
doc/images/hilbert_peano/lenna_small_8.png | Bin 0 -> 17012 bytes
doc/images/regen.py | 48 ++++-
gfxprim_config.py | 5 +
pylib/gfxprim/core/__init__.py | 3 +-
93 files changed, 441 insertions(+), 200 deletions(-)
create mode 100644 doc/images/convert/images.txt
create mode 100644 doc/images/convert/lenna_12.png
create mode 100644 doc/images/convert/lenna_13.png
create mode 100644 doc/images/convert/lenna_14.png
create mode 100644 doc/images/convert/lenna_15.png
create mode 100644 doc/images/convert/lenna_16.png
create mode 100644 doc/images/convert/lenna_5.png
create mode 100644 doc/images/convert/lenna_6.png
create mode 100644 doc/images/convert/lenna_8.png
create mode 100644 doc/images/convert/lenna_small_12.png
create mode 100644 doc/images/convert/lenna_small_13.png
create mode 100644 doc/images/convert/lenna_small_14.png
create mode 100644 doc/images/convert/lenna_small_15.png
create mode 100644 doc/images/convert/lenna_small_16.png
create mode 100644 doc/images/convert/lenna_small_5.png
create mode 100644 doc/images/convert/lenna_small_6.png
create mode 100644 doc/images/convert/lenna_small_8.png
delete mode 100644 doc/images/dither/lenna.png
delete mode 100644 doc/images/dither/lenna_G1_FS.png
delete mode 100644 doc/images/dither/lenna_G1_FS_small.png
delete mode 100644 doc/images/dither/lenna_G1_HP.png
delete mode 100644 doc/images/dither/lenna_G1_HP_small.png
delete mode 100644 doc/images/dither/lenna_G2_FS.png
delete mode 100644 doc/images/dither/lenna_G2_FS_small.png
delete mode 100644 doc/images/dither/lenna_G2_HP.png
delete mode 100644 doc/images/dither/lenna_G2_HP_small.png
delete mode 100644 doc/images/dither/lenna_G4_FS.png
delete mode 100644 doc/images/dither/lenna_G4_FS_small.png
delete mode 100644 doc/images/dither/lenna_G4_HP.png
delete mode 100644 doc/images/dither/lenna_G4_HP_small.png
delete mode 100644 doc/images/dither/lenna_G8_FS.png
delete mode 100644 doc/images/dither/lenna_G8_FS_small.png
delete mode 100644 doc/images/dither/lenna_G8_HP.png
delete mode 100644 doc/images/dither/lenna_G8_HP_small.png
delete mode 100644 doc/images/dither/lenna_RGB111_FS.png
delete mode 100644 doc/images/dither/lenna_RGB111_FS_small.png
delete mode 100644 doc/images/dither/lenna_RGB111_HP.png
delete mode 100644 doc/images/dither/lenna_RGB111_HP_small.png
delete mode 100644 doc/images/dither/lenna_RGB222_FS.png
delete mode 100644 doc/images/dither/lenna_RGB222_FS_small.png
delete mode 100644 doc/images/dither/lenna_RGB222_HP.png
delete mode 100644 doc/images/dither/lenna_RGB222_HP_small.png
delete mode 100644 doc/images/dither/lenna_RGB333_FS.png
delete mode 100644 doc/images/dither/lenna_RGB333_FS_small.png
delete mode 100644 doc/images/dither/lenna_RGB333_HP.png
delete mode 100644 doc/images/dither/lenna_RGB333_HP_small.png
delete mode 100644 doc/images/dither/lenna_small.png
create mode 100644 doc/images/floyd_steinberg/images.txt
create mode 100644 doc/images/floyd_steinberg/lenna_12.png
create mode 100644 doc/images/floyd_steinberg/lenna_13.png
create mode 100644 doc/images/floyd_steinberg/lenna_14.png
create mode 100644 doc/images/floyd_steinberg/lenna_15.png
create mode 100644 doc/images/floyd_steinberg/lenna_16.png
create mode 100644 doc/images/floyd_steinberg/lenna_5.png
create mode 100644 doc/images/floyd_steinberg/lenna_6.png
create mode 100644 doc/images/floyd_steinberg/lenna_8.png
create mode 100644 doc/images/floyd_steinberg/lenna_small_12.png
create mode 100644 doc/images/floyd_steinberg/lenna_small_13.png
create mode 100644 doc/images/floyd_steinberg/lenna_small_14.png
create mode 100644 doc/images/floyd_steinberg/lenna_small_15.png
create mode 100644 doc/images/floyd_steinberg/lenna_small_16.png
create mode 100644 doc/images/floyd_steinberg/lenna_small_5.png
create mode 100644 doc/images/floyd_steinberg/lenna_small_6.png
create mode 100644 doc/images/floyd_steinberg/lenna_small_8.png
create mode 100644 doc/images/hilbert_peano/images.txt
create mode 100644 doc/images/hilbert_peano/lenna_12.png
create mode 100644 doc/images/hilbert_peano/lenna_13.png
create mode 100644 doc/images/hilbert_peano/lenna_14.png
create mode 100644 doc/images/hilbert_peano/lenna_15.png
create mode 100644 doc/images/hilbert_peano/lenna_16.png
create mode 100644 doc/images/hilbert_peano/lenna_5.png
create mode 100644 doc/images/hilbert_peano/lenna_6.png
create mode 100644 doc/images/hilbert_peano/lenna_8.png
create mode 100644 doc/images/hilbert_peano/lenna_small_12.png
create mode 100644 doc/images/hilbert_peano/lenna_small_13.png
create mode 100644 doc/images/hilbert_peano/lenna_small_14.png
create mode 100644 doc/images/hilbert_peano/lenna_small_15.png
create mode 100644 doc/images/hilbert_peano/lenna_small_16.png
create mode 100644 doc/images/hilbert_peano/lenna_small_5.png
create mode 100644 doc/images/hilbert_peano/lenna_small_6.png
create mode 100644 doc/images/hilbert_peano/lenna_small_8.png
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.")
1
0
09 Nov '13
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 8890b06aa3269a9a264cf339ff402a746594fb16 (commit)
via 43bc4241af8b359fcaf7c9cf088602f57ef22bc9 (commit)
via 7ef8350018a08f4e825deac1f6079375b3f74b74 (commit)
from 34e163b7791258eea5d8a0fc467e84f983e4273c (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/8890b06aa3269a9a264cf339ff402a746594…
commit 8890b06aa3269a9a264cf339ff402a746594fb16
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 21:12:13 2013 +0100
doc: Update/Add convolution docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/example_py_convolution.txt b/doc/example_py_convolution.txt
new file mode 100644
index 0000000..0cdfe06
--- /dev/null
+++ b/doc/example_py_convolution.txt
@@ -0,0 +1,8 @@
+Block Blur Convolution Example
+------------------------------
+.A simple program that loads image, blurs it and saves result
+
+[source,python]
+------------------------------------------------------------------
+include::../demos/py_simple/convolution.py[]
+------------------------------------------------------------------
diff --git a/doc/filters.txt b/doc/filters.txt
index 93a2888..8cedbf9 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -458,8 +458,8 @@ into two one dimensional kernels (these when combined yields back the original
kernel). Such convolution then could be applied as two one dimensional
convolutions which is faster operation (especially for big kernels).
-Generic Linear Convolution
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+Bilinear Convolution
+^^^^^^^^^^^^^^^^^^^^
Following paragraph describes linear convolution implementation as well as a
little of the math background skip it if you just need to use one of the
@@ -521,6 +521,8 @@ O(x,y)={1 over kern_div} cdot
NOTE: The number of kernel rows and columns is expected to be odd number.
+include::images/convolution/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Linear.h>
diff --git a/doc/filters_python.txt b/doc/filters_python.txt
index 1d374e3..f1a438a 100644
--- a/doc/filters_python.txt
+++ b/doc/filters_python.txt
@@ -270,6 +270,60 @@ image:laplacian_edge_sharpening.png["Laplacian Edge Sharpening"]
include::images/edge_sharpening/images.txt[]
+Convolution
+~~~~~~~~~~~
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Does in-place bilinear convolution with 3x3 box blur kernel
+ filters.Convolution(img, img, [[1, 1, 1],
+ [1, 1, 1],
+ [1, 1, 1]], 9, callback=None)
+
+ # Does bilinear convolution with 3x3 box blur kernel.
+ #
+ # The image data from source starting at 20,20 of a size 250x250 are
+ # stored at 100,100 in res.
+ filters.ConvolutionEx(img, 20, 20, 250, 250, res, 100, 100,
+ [[1, 1, 1],
+ [1, 1, 1],
+ [1, 1, 1]], 9, callback=None)
+
+ # Returns newly allocated image convolution with Laplacian 3x3 kernel
+ res = img.filters.ConvolutionAlloc([[ 0.00, -0.25, 0.00],
+ [-0.25, 1.00, -0.25],
+ [ 0.00, -0.25, 0.00]],
+ 1, callback=None)
+
+ # Returns newly allocated subimage convolution with Sobel 3x3 kernel
+ res = img.filters.ConvolutionExAlloc(50, 50, 100, 100,
+ [[ 1, 0, -1],
+ [ 2, 0, -2],
+ [ 1, 0, -1]], 1, callback=None)
+-------------------------------------------------------------------------------
+
+Bilinear convolution. The kernel is specified as two dimensional array of
+numbers, the second number is divisor of the kernel weighed sum of pixels.
+
+////
+Generated in filters.txt
+////
+
+The pixel value is computed as:
+image:discrete_linear_convolution_alg1.png["Bilinear Convolution"]
+
+Which is the same as:
+image:discrete_linear_convolution_alg2.png["Bilinear Convolution"]
+
+NOTE: The number of kernel rows and columns is expected to be odd number.
+
+TIP: See link:example_py_convolution.html[convolution example].
+
+
+include::images/convolution/images.txt[]
Blurs
~~~~~
http://repo.or.cz/w/gfxprim.git/commit/43bc4241af8b359fcaf7c9cf088602f57ef2…
commit 43bc4241af8b359fcaf7c9cf088602f57ef22bc9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 20:54:26 2013 +0100
doc: Add Convolution examples to image generator.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/images/Makefile b/doc/images/Makefile
index 76c4501..4762f35 100644
--- a/doc/images/Makefile
+++ b/doc/images/Makefile
@@ -1,7 +1,7 @@
-SUBDIRS=blur median edge_sharpening gaussian_noise
+SUBDIRS=$(dir $(wildcard */images.txt))
-TARGETS=$(addsuffix /images.txt,$(SUBDIRS))
-IMGS=$(addsuffix /*.png,$(SUBDIRS))
+TARGETS=$(addsuffix images.txt,$(SUBDIRS))
+IMGS=$(addsuffix *.png,$(SUBDIRS))
all: $(TARGETS)
diff --git a/doc/images/blur/images.txt b/doc/images/blur/images.txt
index 2c0d697..28113c0 100644
--- a/doc/images/blur/images.txt
+++ b/doc/images/blur/images.txt
@@ -2,19 +2,19 @@
image:images/orig/lenna_small.png[
"Original Image",
link="images/orig/lenna.png"]
-image:images/blur/lenna_small_2_2.png[
+image:images/blur/lenna_small_2,2.png[
"Gaussian Blur 2 2",
- link="images/blur/lenna_2_2.png"]
-image:images/blur/lenna_small_0_4.png[
+ link="images/blur/lenna_2,2.png"]
+image:images/blur/lenna_small_0,4.png[
"Gaussian Blur 0 4",
- link="images/blur/lenna_0_4.png"]
-image:images/blur/lenna_small_4_0.png[
+ link="images/blur/lenna_0,4.png"]
+image:images/blur/lenna_small_4,0.png[
"Gaussian Blur 4 0",
- link="images/blur/lenna_4_0.png"]
-image:images/blur/lenna_small_4_4.png[
+ link="images/blur/lenna_4,0.png"]
+image:images/blur/lenna_small_4,4.png[
"Gaussian Blur 4 4",
- link="images/blur/lenna_4_4.png"]
-image:images/blur/lenna_small_10_10.png[
+ link="images/blur/lenna_4,4.png"]
+image:images/blur/lenna_small_10,10.png[
"Gaussian Blur 10 10",
- link="images/blur/lenna_10_10.png"]
+ link="images/blur/lenna_10,10.png"]
diff --git a/doc/images/brightness_contrast/images.txt b/doc/images/brightness_contrast/images.txt
index 85812c3..f6412ef 100644
--- a/doc/images/brightness_contrast/images.txt
+++ b/doc/images/brightness_contrast/images.txt
@@ -2,16 +2,16 @@
image:images/orig/lenna_small.png[
"Original Image",
link="images/orig/lenna.png"]
-image:images/brightness_contrast/lenna_small_-0.2_0.8.png[
+image:images/brightness_contrast/lenna_small_-0.2,0.8.png[
"BrightnessContrast -0.2 0.8",
- link="images/brightness_contrast/lenna_-0.2_0.8.png"]
-image:images/brightness_contrast/lenna_small_-0.5_2.png[
+ link="images/brightness_contrast/lenna_-0.2,0.8.png"]
+image:images/brightness_contrast/lenna_small_-0.5,2.png[
"BrightnessContrast -0.5 2",
- link="images/brightness_contrast/lenna_-0.5_2.png"]
-image:images/brightness_contrast/lenna_small_0.2_0.8.png[
+ link="images/brightness_contrast/lenna_-0.5,2.png"]
+image:images/brightness_contrast/lenna_small_0.2,0.8.png[
"BrightnessContrast 0.2 0.8",
- link="images/brightness_contrast/lenna_0.2_0.8.png"]
-image:images/brightness_contrast/lenna_small_0.2_1.5.png[
+ link="images/brightness_contrast/lenna_0.2,0.8.png"]
+image:images/brightness_contrast/lenna_small_0.2,1.5.png[
"BrightnessContrast 0.2 1.5",
- link="images/brightness_contrast/lenna_0.2_1.5.png"]
+ link="images/brightness_contrast/lenna_0.2,1.5.png"]
diff --git a/doc/images/brightness_contrast/lenna_0.2_0.5.png b/doc/images/brightness_contrast/lenna_0.2_0.5.png
deleted file mode 100644
index 611122d..0000000
Binary files a/doc/images/brightness_contrast/lenna_0.2_0.5.png and /dev/null differ
diff --git a/doc/images/brightness_contrast/lenna_0.4_0.5.png b/doc/images/brightness_contrast/lenna_0.4_0.5.png
deleted file mode 100644
index 68cb7b1..0000000
Binary files a/doc/images/brightness_contrast/lenna_0.4_0.5.png and /dev/null differ
diff --git a/doc/images/brightness_contrast/lenna_small_0.2_0.5.png b/doc/images/brightness_contrast/lenna_small_0.2_0.5.png
deleted file mode 100644
index 6752bfb..0000000
Binary files a/doc/images/brightness_contrast/lenna_small_0.2_0.5.png and /dev/null differ
diff --git a/doc/images/brightness_contrast/lenna_small_0.4_0.5.png b/doc/images/brightness_contrast/lenna_small_0.4_0.5.png
deleted file mode 100644
index b6af555..0000000
Binary files a/doc/images/brightness_contrast/lenna_small_0.4_0.5.png and /dev/null differ
diff --git a/doc/images/contrast/lenna_0.1.png b/doc/images/contrast/lenna_0.1.png
deleted file mode 100644
index 9f20010..0000000
Binary files a/doc/images/contrast/lenna_0.1.png and /dev/null differ
diff --git a/doc/images/contrast/lenna_4.png b/doc/images/contrast/lenna_4.png
deleted file mode 100644
index ca033c8..0000000
Binary files a/doc/images/contrast/lenna_4.png and /dev/null differ
diff --git a/doc/images/contrast/lenna_small_0.1.png b/doc/images/contrast/lenna_small_0.1.png
deleted file mode 100644
index 529a120..0000000
Binary files a/doc/images/contrast/lenna_small_0.1.png and /dev/null differ
diff --git a/doc/images/contrast/lenna_small_4.png b/doc/images/contrast/lenna_small_4.png
deleted file mode 100644
index c8537e4..0000000
Binary files a/doc/images/contrast/lenna_small_4.png and /dev/null differ
diff --git a/doc/images/convolution/images.txt b/doc/images/convolution/images.txt
new file mode 100644
index 0000000..cf82020
--- /dev/null
+++ b/doc/images/convolution/images.txt
@@ -0,0 +1,20 @@
+.Original Image; 3x3 Box Blur, 5x5 Box Blur, 3x3 Laplacian, 3x3 Sobel, 3x3 Roberts
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/convolution/lenna_small_(1,1,1)(1,1,1)(1,1,1),9.png[
+ "3x3 Box Blur",
+ link="images/convolution/lenna_(1,1,1)(1,1,1)(1,1,1),9.png"]
+image:images/convolution/lenna_small_(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png[
+ "5x5 Box Blur",
+ link="images/convolution/lenna_(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png"]
+image:images/convolution/lenna_small_(0,-1,0)(-1,4,-1)(0,-1,0),1.png[
+ "3x3 Laplacian",
+ link="images/convolution/lenna_(0,-1,0)(-1,4,-1)(0,-1,0),1.png"]
+image:images/convolution/lenna_small_(1,0,-1)(2,0,-2)(1,0,-1),1.png[
+ "3x3 Sobel",
+ link="images/convolution/lenna_(1,0,-1)(2,0,-2)(1,0,-1),1.png"]
+image:images/convolution/lenna_small_(0,0,0)(1,-1,0)(0,0,0),1.png[
+ "3x3 Roberts",
+ link="images/convolution/lenna_(0,0,0)(1,-1,0)(0,0,0),1.png"]
+
diff --git a/doc/images/convolution/lenna_(0,-1,0)(-1,4,-1)(0,-1,0),1.png b/doc/images/convolution/lenna_(0,-1,0)(-1,4,-1)(0,-1,0),1.png
new file mode 100644
index 0000000..cfd3fd9
Binary files /dev/null and b/doc/images/convolution/lenna_(0,-1,0)(-1,4,-1)(0,-1,0),1.png differ
diff --git a/doc/images/convolution/lenna_(0,0,0)(1,-1,0)(0,0,0),1.png b/doc/images/convolution/lenna_(0,0,0)(1,-1,0)(0,0,0),1.png
new file mode 100644
index 0000000..9da5f24
Binary files /dev/null and b/doc/images/convolution/lenna_(0,0,0)(1,-1,0)(0,0,0),1.png differ
diff --git a/doc/images/convolution/lenna_(1,0,-1)(2,0,-2)(1,0,-1),1.png b/doc/images/convolution/lenna_(1,0,-1)(2,0,-2)(1,0,-1),1.png
new file mode 100644
index 0000000..8db35ea
Binary files /dev/null and b/doc/images/convolution/lenna_(1,0,-1)(2,0,-2)(1,0,-1),1.png differ
diff --git a/doc/images/convolution/lenna_(1,1,1)(1,1,1)(1,1,1),9.png b/doc/images/convolution/lenna_(1,1,1)(1,1,1)(1,1,1),9.png
new file mode 100644
index 0000000..d271e37
Binary files /dev/null and b/doc/images/convolution/lenna_(1,1,1)(1,1,1)(1,1,1),9.png differ
diff --git a/doc/images/convolution/lenna_(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png b/doc/images/convolution/lenna_(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png
new file mode 100644
index 0000000..b0b4e60
Binary files /dev/null and b/doc/images/convolution/lenna_(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png differ
diff --git a/doc/images/convolution/lenna_small_(0,-1,0)(-1,4,-1)(0,-1,0),1.png b/doc/images/convolution/lenna_small_(0,-1,0)(-1,4,-1)(0,-1,0),1.png
new file mode 100644
index 0000000..17764a0
Binary files /dev/null and b/doc/images/convolution/lenna_small_(0,-1,0)(-1,4,-1)(0,-1,0),1.png differ
diff --git a/doc/images/convolution/lenna_small_(0,0,0)(1,-1,0)(0,0,0),1.png b/doc/images/convolution/lenna_small_(0,0,0)(1,-1,0)(0,0,0),1.png
new file mode 100644
index 0000000..95ced2e
Binary files /dev/null and b/doc/images/convolution/lenna_small_(0,0,0)(1,-1,0)(0,0,0),1.png differ
diff --git a/doc/images/convolution/lenna_small_(1,0,-1)(2,0,-2)(1,0,-1),1.png b/doc/images/convolution/lenna_small_(1,0,-1)(2,0,-2)(1,0,-1),1.png
new file mode 100644
index 0000000..299c4f4
Binary files /dev/null and b/doc/images/convolution/lenna_small_(1,0,-1)(2,0,-2)(1,0,-1),1.png differ
diff --git a/doc/images/convolution/lenna_small_(1,1,1)(1,1,1)(1,1,1),9.png b/doc/images/convolution/lenna_small_(1,1,1)(1,1,1)(1,1,1),9.png
new file mode 100644
index 0000000..be202b1
Binary files /dev/null and b/doc/images/convolution/lenna_small_(1,1,1)(1,1,1)(1,1,1),9.png differ
diff --git a/doc/images/convolution/lenna_small_(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png b/doc/images/convolution/lenna_small_(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png
new file mode 100644
index 0000000..d498a09
Binary files /dev/null and b/doc/images/convolution/lenna_small_(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png differ
diff --git a/doc/images/gaussian_noise/images.txt b/doc/images/gaussian_noise/images.txt
index a173f04..54781e3 100644
--- a/doc/images/gaussian_noise/images.txt
+++ b/doc/images/gaussian_noise/images.txt
@@ -2,19 +2,19 @@
image:images/orig/lenna_small.png[
"Original Image",
link="images/orig/lenna.png"]
-image:images/gaussian_noise/lenna_small_0.03_0.png[
+image:images/gaussian_noise/lenna_small_0.03,0.png[
"Gaussian Additive Noise 0.03 0",
- link="images/gaussian_noise/lenna_0.03_0.png"]
-image:images/gaussian_noise/lenna_small_0.05_0.png[
+ link="images/gaussian_noise/lenna_0.03,0.png"]
+image:images/gaussian_noise/lenna_small_0.05,0.png[
"Gaussian Additive Noise 0.05 0",
- link="images/gaussian_noise/lenna_0.05_0.png"]
-image:images/gaussian_noise/lenna_small_0.05_-0.1.png[
+ link="images/gaussian_noise/lenna_0.05,0.png"]
+image:images/gaussian_noise/lenna_small_0.05,-0.1.png[
"Gaussian Additive Noise 0.05 -0.1",
- link="images/gaussian_noise/lenna_0.05_-0.1.png"]
-image:images/gaussian_noise/lenna_small_0.05_0.1.png[
+ link="images/gaussian_noise/lenna_0.05,-0.1.png"]
+image:images/gaussian_noise/lenna_small_0.05,0.1.png[
"Gaussian Additive Noise 0.05 0.1",
- link="images/gaussian_noise/lenna_0.05_0.1.png"]
-image:images/gaussian_noise/lenna_small_0.07_0.0.png[
+ link="images/gaussian_noise/lenna_0.05,0.1.png"]
+image:images/gaussian_noise/lenna_small_0.07,0.0.png[
"Gaussian Additive Noise 0.07 0.0",
- link="images/gaussian_noise/lenna_0.07_0.0.png"]
+ link="images/gaussian_noise/lenna_0.07,0.0.png"]
diff --git a/doc/images/gaussian_noise/lenna_0.02_0.png b/doc/images/gaussian_noise/lenna_0.02_0.png
deleted file mode 100644
index dbdd21a..0000000
Binary files a/doc/images/gaussian_noise/lenna_0.02_0.png and /dev/null differ
diff --git a/doc/images/gaussian_noise/lenna_small_0.02_0.png b/doc/images/gaussian_noise/lenna_small_0.02_0.png
deleted file mode 100644
index c658937..0000000
Binary files a/doc/images/gaussian_noise/lenna_small_0.02_0.png and /dev/null differ
diff --git a/doc/images/median/images.txt b/doc/images/median/images.txt
index f656ca8..5def1a3 100644
--- a/doc/images/median/images.txt
+++ b/doc/images/median/images.txt
@@ -2,19 +2,19 @@
image:images/orig/lenna_small.png[
"Original Image",
link="images/orig/lenna.png"]
-image:images/median/lenna_small_3_3.png[
+image:images/median/lenna_small_3,3.png[
"Median 3 3",
- link="images/median/lenna_3_3.png"]
-image:images/median/lenna_small_5_5.png[
+ link="images/median/lenna_3,3.png"]
+image:images/median/lenna_small_5,5.png[
"Median 5 5",
- link="images/median/lenna_5_5.png"]
-image:images/median/lenna_small_7_7.png[
+ link="images/median/lenna_5,5.png"]
+image:images/median/lenna_small_7,7.png[
"Median 7 7",
- link="images/median/lenna_7_7.png"]
-image:images/median/lenna_small_9_9.png[
+ link="images/median/lenna_7,7.png"]
+image:images/median/lenna_small_9,9.png[
"Median 9 9",
- link="images/median/lenna_9_9.png"]
-image:images/median/lenna_small_12_12.png[
+ link="images/median/lenna_9,9.png"]
+image:images/median/lenna_small_12,12.png[
"Median 12 12",
- link="images/median/lenna_12_12.png"]
+ link="images/median/lenna_12,12.png"]
diff --git a/doc/images/regen.py b/doc/images/regen.py
index 6aaeb34..3e01756 100755
--- a/doc/images/regen.py
+++ b/doc/images/regen.py
@@ -6,13 +6,39 @@ import gfxprim.core as core
import gfxprim.loaders as loaders
import gfxprim.filters as filters
+def str_esc(x):
+ res = str(x)
+ if (res[0] == '-'):
+ res = '\' + res
+ return res
+
+def to_str(x, to_str):
+ res = ''
+ if hasattr(x, '__iter__'):
+ for i in x:
+ if hasattr(i, '__iter__'):
+ res += ('(')
+ first = 1
+ for j in i:
+ if (first):
+ first = 0
+ else:
+ res += ','
+ res += to_str(j)
+ res += (')')
+ else:
+ res += ('(' + to_str(i)+ ')')
+ else:
+ return to_str(x)
+
+ return res
+
class ImgGen:
def __init__(self, orig_path):
self.orig_path = orig_path
self.img = loaders.Load('../' + orig_path + 'lenna.png')
self.img_small = loaders.Load('../' + orig_path + 'lenna_small.png')
-
def write_asciidoc_head(self, dst_path, heading):
self.f = open('../' + dst_path + 'images.txt', 'w')
f = self.f
@@ -31,29 +57,39 @@ class ImgGen:
self.f.write('n')
self.f.close()
- def gen(self, func, func_param_desc, func_params_arr, dst_path, func_name):
+ def gen(self, func, func_param_desc, func_params_arr, dst_path, func_name, descs=None):
print("Generating " + func_name)
- self.write_asciidoc_head(dst_path, func_name + ' ' +
- ', '.join(map(lambda x: ' '.join([func_param_desc[i] + '=' +
- str(x[i]) for i in range(0, len(x))]), func_params_arr)))
+ head = func_name + ' '
+ head += ', '.join(map(lambda x: ' '.join([func_param_desc[i] + '=' +
+ str(x[i]) for i in range(0, len(x))]), func_params_arr))
+
+ if (descs is not None):
+ head = ', '.join(descs)
+
+ self.write_asciidoc_head(dst_path, head)
+
+ for i in range(0, len(func_params_arr)):
+ params = func_params_arr[i]
+ str_pars = [to_str(x, str) for x in params]
- for i in func_params_arr:
- str_i = [str(x) for x in i]
- desc = func_name + ' ' + ' '.join(str_i)
+ if (descs is not None):
+ desc = descs[i]
+ else:
+ desc = func_name + ' ' + ' '.join(str_pars)
print(' > ' + desc)
- fname = dst_path + 'lenna_' + '_'.join(str_i) + '.png'
- fname_small = dst_path + 'lenna_small_' + '_'.join(str_i) + '.png'
+ fname = dst_path + 'lenna_' + ','.join(str_pars) + '.png'
+ fname_small = dst_path + 'lenna_small_' + ','.join(str_pars) + '.png'
self.write_img_asciidoc(desc, fname, fname_small)
- res = func(self.img, *i)
+ res = func(self.img, *params)
res.loaders.Save('../' + fname)
- res = func(self.img_small, *i)
+ res = func(self.img_small, *params)
res.loaders.Save('../' + fname_small)
self.write_asciidoc_tail()
@@ -63,59 +99,86 @@ def main():
imggen.gen(filters.InvertAlloc, [],
[[]],
- 'images/invert/', 'Inverted')
+ 'images/invert/', 'Inverted')
imggen.gen(filters.BrightnessAlloc, ['p'],
[[-.5], [-.2], [.2], [.5]],
- 'images/brightness/', 'Brightness')
+ 'images/brightness/', 'Brightness')
imggen.gen(filters.ContrastAlloc, ['p'],
[[.2], [.5], [1.5], [2], [3]],
- 'images/contrast/', 'Contrast')
+ 'images/contrast/', 'Contrast')
imggen.gen(filters.BrightnessContrastAlloc, ['b', 'c'],
[[-.2, .8], [-.5, 2], [.2, .8], [.2, 1.5]],
- 'images/brightness_contrast/', 'BrightnessContrast')
+ 'images/brightness_contrast/', 'BrightnessContrast')
imggen.gen(filters.PosterizeAlloc, ['s'],
[[2], [3], [4], [5], [6]],
- 'images/posterize/', 'Posterize')
+ 'images/posterize/', 'Posterize')
imggen.gen(filters.MirrorHAlloc, [],
[[]],
- 'images/mirror_h/', 'Mirrored Horizontally')
+ 'images/mirror_h/', 'Mirrored Horizontally')
imggen.gen(filters.MirrorVAlloc, [],
[[]],
- 'images/mirror_v/', 'Mirrored Vertically')
+ 'images/mirror_v/', 'Mirrored Vertically')
imggen.gen(filters.Rotate90Alloc, [],
[[]],
- 'images/rotate_90/', 'Rotated by 90 degrees')
+ 'images/rotate_90/', 'Rotated by 90 degrees')
imggen.gen(filters.Rotate180Alloc, [],
[[]],
- 'images/rotate_180/', 'Rotated by 180 degrees')
+ 'images/rotate_180/', 'Rotated by 180 degrees')
imggen.gen(filters.Rotate270Alloc, [],
[[]],
- 'images/rotate_270/', 'Rotated by 270 degrees')
+ 'images/rotate_270/', 'Rotated by 270 degrees')
imggen.gen(filters.GaussianBlurAlloc, ['xsig', 'ysig'],
[[2, 2], [0, 4], [4, 0], [4, 4], [10, 10]],
- 'images/blur/', 'Gaussian Blur')
+ 'images/blur/', 'Gaussian Blur')
imggen.gen(filters.MedianAlloc, ['xr', 'yr'],
[[3, 3], [5, 5], [7, 7], [9, 9], [12, 12]],
- 'images/median/', 'Median')
+ 'images/median/', 'Median')
imggen.gen(filters.EdgeSharpeningAlloc, ['w'],
[[0.1], [0.3], [0.5], [0.8], [1.0]],
- 'images/edge_sharpening/', 'Edge Sharpening')
+ 'images/edge_sharpening/', 'Edge Sharpening')
imggen.gen(filters.GaussianNoiseAddAlloc, ['s', 'm'],
[[0.03, 0], [0.05, 0], [0.05, -0.1], [0.05, 0.1], [0.07, 0.0]],
- 'images/gaussian_noise/', 'Gaussian Additive Noise')
+ 'images/gaussian_noise/', 'Gaussian Additive Noise')
+
+ imggen.gen(filters.ConvolutionAlloc, ['k', 'kd'],
+ [
+ [[[1, 1, 1],
+ [1, 1, 1],
+ [1, 1, 1]], 9],
+ [[[1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1]], 25],
+ [[[ 0, -1, 0],
+ [-1, 4, -1],
+ [ 0, -1, 0]], 1],
+ [[[1, 0, -1],
+ [2, 0, -2],
+ [1, 0, -1]], 1],
+ [[[0, 0, 0],
+ [1, -1, 0],
+ [0, 0, 0]], 1],
+ ],
+ 'images/convolution/', 'Convolution',
+ ['3x3 Box Blur',
+ '5x5 Box Blur',
+ '3x3 Laplacian',
+ '3x3 Sobel',
+ '3x3 Roberts'])
if __name__ == '__main__':
main()
http://repo.or.cz/w/gfxprim.git/commit/7ef8350018a08f4e825deac1f6079375b3f7…
commit 7ef8350018a08f4e825deac1f6079375b3f74b74
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 17:57:43 2013 +0100
pywrap: Add wrapping around Convolution kernel
Now the python bindings converts python two dimensional array into
GP_FilterKernel2D structure, yay!
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/py_simple/convolution.py b/demos/py_simple/convolution.py
new file mode 100755
index 0000000..3dbc975
--- /dev/null
+++ b/demos/py_simple/convolution.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+import sys
+
+import gfxprim.core as core
+import gfxprim.loaders as loaders
+import gfxprim.filters as filters
+
+def main():
+ if len(sys.argv) != 2:
+ print("usage: convolution.py image")
+ sys.exit(1)
+
+ # Load Image
+ img = loaders.Load(sys.argv[1])
+ # Box blur kernel
+ kern = [[1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1],
+ [1, 1, 1, 1, 1]]
+ res = img.filters.ConvolutionAlloc(kern, 25);
+ # Save result into png
+ res.loaders.SavePNG("out.png")
+
+if __name__ == '__main__':
+ main()
diff --git a/demos/py_simple/invert.py b/demos/py_simple/invert.py
index 84a5b6f..684facc 100755
--- a/demos/py_simple/invert.py
+++ b/demos/py_simple/invert.py
@@ -14,7 +14,7 @@ def main():
img = loaders.Load(sys.argv[1])
# Invert image in-place
img.filters.Invert(img);
- # Save result into grayscale png
+ # Save result into png
img.loaders.SavePNG("out.png")
if __name__ == '__main__':
diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py
index d8bdd97..1ac3acb 100644
--- a/pylib/gfxprim/filters/__init__.py
+++ b/pylib/gfxprim/filters/__init__.py
@@ -10,7 +10,7 @@ from . import c_filters
def _init(module):
"Extend Context with filters submodule"
- from ..utils import extend_submodule
+ from ..utils import extend, extend_submodule
from ..core import Context as _context
# New Context submodule
@@ -44,6 +44,94 @@ def _init(module):
'HilbertPeano', 'HilbertPeanoAlloc']:
extend_submodule(FiltersSubmodule, name, c_filters.__getattribute__('GP_Filter' + name))
+ def array_to_kern(kernel, kernel_div):
+ h = len(kernel)
+ w = len(kernel[0])
+
+ # Assert that array is matrix of numbers
+ for i in range(0, h):
+ assert(len(kernel[i]) == w)
+
+ for j in kernel[i]:
+ assert(isinstance(j, float) or isinstance(j, int))
+
+ # flatten the python array into C array
+ karr = c_filters.new_float_array(w * h)
+
+ for i in range(0, h):
+ for j in range(0, w):
+ c_filters.float_array_setitem(karr, i * w + j, kernel[i][j])
+
+ kern = c_filters.GP_FilterKernel2D(w, h, karr, kernel_div)
+
+ return kern
+
+ def array_del(kern):
+ c_filters.delete_float_array(kern.kernel)
+
+ def Convolution(src, dst, kernel, kernel_div, callback=None):
+ """
+ Convolution(src, dst, kernel, kernel_div, callback=None)
+
+ Bilinear convolution. The kernel is two dimensional array of coefficients,
+ kern_div is used to divide the kernel weigthed sum.
+ """
+ kern = array_to_kern(kernel, kernel_div)
+ ret = c_filters.GP_FilterConvolution(src, dst, kern, callback)
+ array_del(kern)
+ return ret
+
+ extend_submodule(FiltersSubmodule, 'Convolution', Convolution)
+
+ def ConvolutionEx(src, x_src, y_src, w_src, h_src, dst, x_dst, y_dst,
+ kernel, kernel_div, callback=None):
+ """
+ ConvolutionEx(src, x_src, y_src, w_src, h_src, dst, x_dst, y_dst,
+ kernel, kernel_div, callback=None)
+
+ Bilinear convolution. The kernel is two dimensional array of coefficients,
+ kern_div is used to divide the kernel weigthed sum.
+ """
+ kern = array_to_kern(kernel, kernel_div);
+ ret = c_filters.GP_FilterConvolutionEx(src, x_src, y_src,
+ w_src, h_src, dst, x_dst, y_dst,
+ kern, callback)
+ array_del(kern)
+ return ret
+
+ extend_submodule(FiltersSubmodule, 'ConvolutionEx', ConvolutionEx)
+
+ def ConvolutionAlloc(src, kernel, kernel_div, callback=None):
+ """
+ ConvolutionAlloc(src, kernel, kernel_div, callback=None)
+
+ Bilinear convolution. The kernel is two dimensional array of coefficients,
+ kern_div is used to divide the kernel weigthed sum.
+ """
+ kern = array_to_kern(kernel, kernel_div);
+ ret = c_filters.GP_FilterConvolutionAlloc(src, kern, callback)
+ array_del(kern)
+ return ret
+
+ extend_submodule(FiltersSubmodule, 'ConvolutionAlloc', ConvolutionAlloc)
+
+ def ConvolutionExAlloc(src, x_src, y_src, w_src, h_src,
+ kernel, kernel_div, callback=None):
+ """
+ ConvolutionExAlloc(src, x_src, y_src, w_src, h_src,
+ kernel, kernel_div, callback=None)
+
+ Bilinear convolution. The kernel is two dimensional array of coefficients,
+ kern_div is used to divide the kernel weigthed sum.
+ """
+ kern = array_to_kern(kernel, kernel_div);
+ ret = c_filters.GP_FilterConvolutionExAlloc(src, x_src, y_src,
+ w_src, h_src, kern, callback)
+ array_del(kern)
+ return ret
+
+ extend_submodule(FiltersSubmodule, 'ConvolutionExAlloc', ConvolutionExAlloc)
+
# Imports from the SWIG module
import re
def strip_GP_Filter(s):
@@ -57,5 +145,10 @@ def _init(module):
'^GP_Filter[A-Za-z0-9]*$',
])
+ module['Convolution'] = Convolution
+ module['ConvolutionAlloc'] = ConvolutionAlloc
+ module['ConvolutionEx'] = ConvolutionEx
+ module['ConvolutionExAlloc'] = ConvolutionExAlloc
+
_init(locals())
del _init
diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i
index 9bd6daf..8bec204 100644
--- a/pylib/gfxprim/filters/filters.i
+++ b/pylib/gfxprim/filters/filters.i
@@ -1,5 +1,6 @@
%include "../common.i"
%module(package="gfxprim.filters") c_filters
+%include "carrays.i"
%{
#include "filters/GP_Filters.h"
@@ -17,17 +18,6 @@ ERROR_ON_NULL(GP_Filter ## funcname ## Alloc);
ERROR_ON_NONZERO(GP_Filter ## funcname);
%enddef
-/* Listed in GP_Filters.h: */
-%extend GP_FilterParam {
- ~GP_FilterParam() {
- GP_DEBUG(2, "[wrapper] GP_FilterParamFree");
- GP_FilterParamDestroy($self);
- }
-}
-
-%newobject GP_FilterParamCreate;
-%include "GP_FilterParam.h"
-
FILTER_FUNC(Invert);
FILTER_FUNC(Brightness);
FILTER_FUNC(Contrast);
@@ -58,6 +48,32 @@ FILTER_FUNC(Symmetry);
/* Convolutions */
FILTER_FUNC(Convolution);
FILTER_FUNC(ConvolutionEx);
+
+%array_functions(float, float_array);
+
+%extend GP_FilterKernel2D {
+ ~GP_FilterKernel2D() {
+ free($self);
+ }
+ GP_FilterKernel2D(unsigned int w, unsigned int h,
+ float *kern, float kern_div) {
+
+ GP_FilterKernel2D *kernel = malloc(sizeof(GP_FilterKernel2D));
+
+ if (!kernel) {
+ GP_DEBUG(1, "Malloc failed :(");
+ return NULL;
+ }
+
+ kernel->w = w;
+ kernel->h = h;
+ kernel->div = kern_div;
+ kernel->kernel = kern;
+
+ return kernel;
+ }
+};
+
%include "GP_Convolution.h"
/* Blur */
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/{dither.py => convolution.py} | 13 ++-
demos/py_simple/invert.py | 2 +-
...mple_py_blur.txt => example_py_convolution.txt} | 6 +-
doc/filters.txt | 6 +-
doc/filters_python.txt | 54 +++++++++
doc/images/Makefile | 6 +-
doc/images/blur/images.txt | 20 ++--
doc/images/blur/{lenna_0_4.png => lenna_0,4.png} | Bin 236705 -> 236705 bytes
.../blur/{lenna_10_10.png => lenna_10,10.png} | Bin 143058 -> 143058 bytes
doc/images/blur/{lenna_2_2.png => lenna_2,2.png} | Bin 229699 -> 229699 bytes
doc/images/blur/{lenna_4_0.png => lenna_4,0.png} | Bin 231739 -> 231739 bytes
doc/images/blur/{lenna_4_4.png => lenna_4,4.png} | Bin 178703 -> 178703 bytes
.../{lenna_small_0_4.png => lenna_small_0,4.png} | Bin 19492 -> 19492 bytes
...lenna_small_10_10.png => lenna_small_10,10.png} | Bin 10638 -> 10638 bytes
.../{lenna_small_2_2.png => lenna_small_2,2.png} | Bin 18849 -> 18849 bytes
.../{lenna_small_4_0.png => lenna_small_4,0.png} | Bin 18565 -> 18565 bytes
.../{lenna_small_4_4.png => lenna_small_4,4.png} | Bin 14816 -> 14816 bytes
doc/images/brightness_contrast/images.txt | 16 ++--
.../{lenna_-0.2_0.8.png => lenna_-0.2,0.8.png} | Bin 288118 -> 288118 bytes
.../{lenna_-0.5_2.png => lenna_-0.5,2.png} | Bin 330382 -> 330382 bytes
.../{lenna_0.2_0.8.png => lenna_0.2,0.8.png} | Bin 372199 -> 372199 bytes
.../{lenna_0.2_1.5.png => lenna_0.2,1.5.png} | Bin 388546 -> 388546 bytes
doc/images/brightness_contrast/lenna_0.2_0.5.png | Bin 313679 -> 0 bytes
doc/images/brightness_contrast/lenna_0.4_0.5.png | Bin 314067 -> 0 bytes
...small_-0.2_0.8.png => lenna_small_-0.2,0.8.png} | Bin 24114 -> 24114 bytes
...nna_small_-0.5_2.png => lenna_small_-0.5,2.png} | Bin 26923 -> 26923 bytes
...a_small_0.2_0.8.png => lenna_small_0.2,0.8.png} | Bin 30145 -> 30145 bytes
...a_small_0.2_1.5.png => lenna_small_0.2,1.5.png} | Bin 30713 -> 30713 bytes
.../brightness_contrast/lenna_small_0.2_0.5.png | Bin 26101 -> 0 bytes
.../brightness_contrast/lenna_small_0.4_0.5.png | Bin 26099 -> 0 bytes
doc/images/contrast/lenna_0.1.png | Bin 161387 -> 0 bytes
doc/images/contrast/lenna_4.png | Bin 222137 -> 0 bytes
doc/images/contrast/lenna_small_0.1.png | Bin 14173 -> 0 bytes
doc/images/contrast/lenna_small_4.png | Bin 18249 -> 0 bytes
doc/images/convolution/images.txt | 20 ++++
.../lenna_(0,-1,0)(-1,4,-1)(0,-1,0),1.png | Bin 0 -> 375033 bytes
.../convolution/lenna_(0,0,0)(1,-1,0)(0,0,0),1.png | Bin 0 -> 285516 bytes
.../lenna_(1,0,-1)(2,0,-2)(1,0,-1),1.png | Bin 0 -> 412063 bytes
.../convolution/lenna_(1,1,1)(1,1,1)(1,1,1),9.png | Bin 0 -> 312990 bytes
...,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png | Bin 0 -> 260462 bytes
.../lenna_small_(0,-1,0)(-1,4,-1)(0,-1,0),1.png | Bin 0 -> 25284 bytes
.../lenna_small_(0,0,0)(1,-1,0)(0,0,0),1.png | Bin 0 -> 23982 bytes
.../lenna_small_(1,0,-1)(2,0,-2)(1,0,-1),1.png | Bin 0 -> 26170 bytes
.../lenna_small_(1,1,1)(1,1,1)(1,1,1),9.png | Bin 0 -> 24041 bytes
...,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png | Bin 0 -> 21102 bytes
doc/images/gaussian_noise/images.txt | 20 ++--
doc/images/gaussian_noise/lenna_0.02_0.png | Bin 499974 -> 0 bytes
.../{lenna_0.03_0.png => lenna_0.03,0.png} | Bin 534481 -> 534481 bytes
.../{lenna_0.05_-0.1.png => lenna_0.05,-0.1.png} | Bin 595526 -> 595526 bytes
.../{lenna_0.05_0.1.png => lenna_0.05,0.1.png} | Bin 600660 -> 600660 bytes
.../{lenna_0.05_0.png => lenna_0.05,0.png} | Bin 597194 -> 597194 bytes
.../{lenna_0.07_0.0.png => lenna_0.07,0.0.png} | Bin 640739 -> 640739 bytes
doc/images/gaussian_noise/lenna_small_0.02_0.png | Bin 35601 -> 0 bytes
...nna_small_0.03_0.png => lenna_small_0.03,0.png} | Bin 36875 -> 36875 bytes
...all_0.05_-0.1.png => lenna_small_0.05,-0.1.png} | Bin 39579 -> 39579 bytes
...small_0.05_0.1.png => lenna_small_0.05,0.1.png} | Bin 39898 -> 39898 bytes
...nna_small_0.05_0.png => lenna_small_0.05,0.png} | Bin 39680 -> 39680 bytes
...small_0.07_0.0.png => lenna_small_0.07,0.0.png} | Bin 41654 -> 41654 bytes
doc/images/median/images.txt | 20 ++--
.../median/{lenna_12_12.png => lenna_12,12.png} | Bin 174531 -> 174531 bytes
doc/images/median/{lenna_3_3.png => lenna_3,3.png} | Bin 259580 -> 259580 bytes
doc/images/median/{lenna_5_5.png => lenna_5,5.png} | Bin 224934 -> 224934 bytes
doc/images/median/{lenna_7_7.png => lenna_7,7.png} | Bin 204463 -> 204463 bytes
doc/images/median/{lenna_9_9.png => lenna_9,9.png} | Bin 190419 -> 190419 bytes
...lenna_small_12_12.png => lenna_small_12,12.png} | Bin 15174 -> 15174 bytes
.../{lenna_small_3_3.png => lenna_small_3,3.png} | Bin 20584 -> 20584 bytes
.../{lenna_small_5_5.png => lenna_small_5,5.png} | Bin 18652 -> 18652 bytes
.../{lenna_small_7_7.png => lenna_small_7,7.png} | Bin 17299 -> 17299 bytes
.../{lenna_small_9_9.png => lenna_small_9,9.png} | Bin 16276 -> 16276 bytes
doc/images/regen.py | 115 +++++++++++++++-----
pylib/gfxprim/filters/__init__.py | 95 ++++++++++++++++-
pylib/gfxprim/filters/filters.i | 38 +++++--
72 files changed, 342 insertions(+), 89 deletions(-)
copy demos/py_simple/{dither.py => convolution.py} (52%)
copy doc/{example_py_blur.txt => example_py_convolution.txt} (66%)
rename doc/images/blur/{lenna_0_4.png => lenna_0,4.png} (100%)
rename doc/images/blur/{lenna_10_10.png => lenna_10,10.png} (100%)
rename doc/images/blur/{lenna_2_2.png => lenna_2,2.png} (100%)
rename doc/images/blur/{lenna_4_0.png => lenna_4,0.png} (100%)
rename doc/images/blur/{lenna_4_4.png => lenna_4,4.png} (100%)
rename doc/images/blur/{lenna_small_0_4.png => lenna_small_0,4.png} (100%)
rename doc/images/blur/{lenna_small_10_10.png => lenna_small_10,10.png} (100%)
rename doc/images/blur/{lenna_small_2_2.png => lenna_small_2,2.png} (100%)
rename doc/images/blur/{lenna_small_4_0.png => lenna_small_4,0.png} (100%)
rename doc/images/blur/{lenna_small_4_4.png => lenna_small_4,4.png} (100%)
rename doc/images/brightness_contrast/{lenna_-0.2_0.8.png => lenna_-0.2,0.8.png} (100%)
rename doc/images/brightness_contrast/{lenna_-0.5_2.png => lenna_-0.5,2.png} (100%)
rename doc/images/brightness_contrast/{lenna_0.2_0.8.png => lenna_0.2,0.8.png} (100%)
rename doc/images/brightness_contrast/{lenna_0.2_1.5.png => lenna_0.2,1.5.png} (100%)
delete mode 100644 doc/images/brightness_contrast/lenna_0.2_0.5.png
delete mode 100644 doc/images/brightness_contrast/lenna_0.4_0.5.png
rename doc/images/brightness_contrast/{lenna_small_-0.2_0.8.png => lenna_small_-0.2,0.8.png} (100%)
rename doc/images/brightness_contrast/{lenna_small_-0.5_2.png => lenna_small_-0.5,2.png} (100%)
rename doc/images/brightness_contrast/{lenna_small_0.2_0.8.png => lenna_small_0.2,0.8.png} (100%)
rename doc/images/brightness_contrast/{lenna_small_0.2_1.5.png => lenna_small_0.2,1.5.png} (100%)
delete mode 100644 doc/images/brightness_contrast/lenna_small_0.2_0.5.png
delete mode 100644 doc/images/brightness_contrast/lenna_small_0.4_0.5.png
delete mode 100644 doc/images/contrast/lenna_0.1.png
delete mode 100644 doc/images/contrast/lenna_4.png
delete mode 100644 doc/images/contrast/lenna_small_0.1.png
delete mode 100644 doc/images/contrast/lenna_small_4.png
create mode 100644 doc/images/convolution/images.txt
create mode 100644 doc/images/convolution/lenna_(0,-1,0)(-1,4,-1)(0,-1,0),1.png
create mode 100644 doc/images/convolution/lenna_(0,0,0)(1,-1,0)(0,0,0),1.png
create mode 100644 doc/images/convolution/lenna_(1,0,-1)(2,0,-2)(1,0,-1),1.png
create mode 100644 doc/images/convolution/lenna_(1,1,1)(1,1,1)(1,1,1),9.png
create mode 100644 doc/images/convolution/lenna_(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png
create mode 100644 doc/images/convolution/lenna_small_(0,-1,0)(-1,4,-1)(0,-1,0),1.png
create mode 100644 doc/images/convolution/lenna_small_(0,0,0)(1,-1,0)(0,0,0),1.png
create mode 100644 doc/images/convolution/lenna_small_(1,0,-1)(2,0,-2)(1,0,-1),1.png
create mode 100644 doc/images/convolution/lenna_small_(1,1,1)(1,1,1)(1,1,1),9.png
create mode 100644 doc/images/convolution/lenna_small_(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1)(1,1,1,1,1),25.png
delete mode 100644 doc/images/gaussian_noise/lenna_0.02_0.png
rename doc/images/gaussian_noise/{lenna_0.03_0.png => lenna_0.03,0.png} (100%)
rename doc/images/gaussian_noise/{lenna_0.05_-0.1.png => lenna_0.05,-0.1.png} (100%)
rename doc/images/gaussian_noise/{lenna_0.05_0.1.png => lenna_0.05,0.1.png} (100%)
rename doc/images/gaussian_noise/{lenna_0.05_0.png => lenna_0.05,0.png} (100%)
rename doc/images/gaussian_noise/{lenna_0.07_0.0.png => lenna_0.07,0.0.png} (100%)
delete mode 100644 doc/images/gaussian_noise/lenna_small_0.02_0.png
rename doc/images/gaussian_noise/{lenna_small_0.03_0.png => lenna_small_0.03,0.png} (100%)
rename doc/images/gaussian_noise/{lenna_small_0.05_-0.1.png => lenna_small_0.05,-0.1.png} (100%)
rename doc/images/gaussian_noise/{lenna_small_0.05_0.1.png => lenna_small_0.05,0.1.png} (100%)
rename doc/images/gaussian_noise/{lenna_small_0.05_0.png => lenna_small_0.05,0.png} (100%)
rename doc/images/gaussian_noise/{lenna_small_0.07_0.0.png => lenna_small_0.07,0.0.png} (100%)
rename doc/images/median/{lenna_12_12.png => lenna_12,12.png} (100%)
rename doc/images/median/{lenna_3_3.png => lenna_3,3.png} (100%)
rename doc/images/median/{lenna_5_5.png => lenna_5,5.png} (100%)
rename doc/images/median/{lenna_7_7.png => lenna_7,7.png} (100%)
rename doc/images/median/{lenna_9_9.png => lenna_9,9.png} (100%)
rename doc/images/median/{lenna_small_12_12.png => lenna_small_12,12.png} (100%)
rename doc/images/median/{lenna_small_3_3.png => lenna_small_3,3.png} (100%)
rename doc/images/median/{lenna_small_5_5.png => lenna_small_5,5.png} (100%)
rename doc/images/median/{lenna_small_7_7.png => lenna_small_7,7.png} (100%)
rename doc/images/median/{lenna_small_9_9.png => lenna_small_9,9.png} (100%)
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.")
1
0
09 Nov '13
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 34e163b7791258eea5d8a0fc467e84f983e4273c (commit)
via 3ae0e5346bd38347c6642829238bf2db9d4716a3 (commit)
via a5806c8cd1c03efe50cef124116278d067fdc793 (commit)
via acb23fffacdae415b778e2effdc506d8d3b8b420 (commit)
via 280e32f1a1d6f25018f19a0a793f470144650eef (commit)
via 6a4ef1c559652d3f2e1d7c1e69d47f214364a9d6 (commit)
via 445b1c8edfd8a95ad0f40e13f20eade2f6fbed10 (commit)
via ef943c2310c1345dbc8bd34c3cdd26648ed79420 (commit)
via 6a0865b80f90e2397d90d13e836b0db3f8aaa372 (commit)
via ddaf9058d046bbde16edfe2c4655a5690b043883 (commit)
from ed36869f7b525df87a66c7403485f8ddd8491457 (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/34e163b7791258eea5d8a0fc467e84f983e4…
commit 34e163b7791258eea5d8a0fc467e84f983e4273c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 00:37:52 2013 +0100
doc: filters_python: Add rotation and symmetry filters.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/filters_python.txt b/doc/filters_python.txt
index 6802510..1d374e3 100644
--- a/doc/filters_python.txt
+++ b/doc/filters_python.txt
@@ -114,6 +114,109 @@ The pixel channel values are quantized into number of levels.
include::images/posterize/images.txt[]
+Rotations and Mirroring
+~~~~~~~~~~~~~~~~~~~~~~~
+
+MirrorH
+^^^^^^^
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Mirrors in-place image horizontally
+ img.filters.MirrorH(img, callback=None)
+
+ # Mirrors image horizontally
+ res = img.filters.MirrorHAlloc(callback=None)
+
+-------------------------------------------------------------------------------
+
+Mirrors image horizontally.
+
+include::images/mirror_h/images.txt[]
+
+MirrorV
+^^^^^^^
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Mirrors in-place image vertically
+ img.filters.MirrorV(img, callback=None)
+
+ # Mirrors image vertically
+ res = img.filters.MirrorVAlloc(callback=None)
+
+-------------------------------------------------------------------------------
+
+Mirrors image vertically.
+
+include::images/mirror_v/images.txt[]
+
+Rotate90
+^^^^^^^^
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Rotate in-place by 90 degrees
+ img.filters.Rotate90(img, callback=None)
+
+ # Rotate by 90 degrees
+ res = img.filters.Rotate90Alloc(callback=None)
+
+-------------------------------------------------------------------------------
+
+Rotate image by 90 degrees clockwise.
+
+include::images/rotate_90/images.txt[]
+
+Rotate180
+^^^^^^^^^
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Rotate in-place by 180 degrees
+ img.filters.Rotate180(img, callback=None)
+
+ # Rotate by 180 degrees
+ res = img.filters.Rotate180Alloc(callback=None)
+
+-------------------------------------------------------------------------------
+
+Rotate image by 180 degrees clockwise.
+
+include::images/rotate_180/images.txt[]
+
+Rotate270
+^^^^^^^^^
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Rotate in-place by 270 degrees
+ img.filters.Rotate270(img, callback=None)
+
+ # Rotate by 270 degrees
+ res = img.filters.Rotate270Alloc(callback=None)
+
+-------------------------------------------------------------------------------
+
+Rotate image by 270 degrees clockwise.
+
+include::images/rotate_270/images.txt[]
+
Gaussian Additive Noise
~~~~~~~~~~~~~~~~~~~~~~~
@@ -136,6 +239,7 @@ interval.
include::images/gaussian_noise/images.txt[]
+
Laplacian Edge Sharpening
~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/images/mirror_h/images.txt b/doc/images/mirror_h/images.txt
new file mode 100644
index 0000000..14edc6b
--- /dev/null
+++ b/doc/images/mirror_h/images.txt
@@ -0,0 +1,8 @@
+.Original Image; Mirrored Horizontally
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/mirror_h/lenna_small_.png[
+ "Mirrored Horizontally ",
+ link="images/mirror_h/lenna_.png"]
+
diff --git a/doc/images/mirror_h/lenna_.png b/doc/images/mirror_h/lenna_.png
new file mode 100644
index 0000000..90d4dc8
Binary files /dev/null and b/doc/images/mirror_h/lenna_.png differ
diff --git a/doc/images/mirror_h/lenna_small_.png b/doc/images/mirror_h/lenna_small_.png
new file mode 100644
index 0000000..b5625a0
Binary files /dev/null and b/doc/images/mirror_h/lenna_small_.png differ
diff --git a/doc/images/mirror_v/images.txt b/doc/images/mirror_v/images.txt
new file mode 100644
index 0000000..b37b76e
--- /dev/null
+++ b/doc/images/mirror_v/images.txt
@@ -0,0 +1,8 @@
+.Original Image; Mirrored Vertically
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/mirror_v/lenna_small_.png[
+ "Mirrored Vertically ",
+ link="images/mirror_v/lenna_.png"]
+
diff --git a/doc/images/mirror_v/lenna_.png b/doc/images/mirror_v/lenna_.png
new file mode 100644
index 0000000..6bb590c
Binary files /dev/null and b/doc/images/mirror_v/lenna_.png differ
diff --git a/doc/images/mirror_v/lenna_small_.png b/doc/images/mirror_v/lenna_small_.png
new file mode 100644
index 0000000..bae1469
Binary files /dev/null and b/doc/images/mirror_v/lenna_small_.png differ
diff --git a/doc/images/regen.py b/doc/images/regen.py
index ace7e6a..6aaeb34 100755
--- a/doc/images/regen.py
+++ b/doc/images/regen.py
@@ -81,6 +81,26 @@ def main():
[[2], [3], [4], [5], [6]],
'images/posterize/', 'Posterize')
+ imggen.gen(filters.MirrorHAlloc, [],
+ [[]],
+ 'images/mirror_h/', 'Mirrored Horizontally')
+
+ imggen.gen(filters.MirrorVAlloc, [],
+ [[]],
+ 'images/mirror_v/', 'Mirrored Vertically')
+
+ imggen.gen(filters.Rotate90Alloc, [],
+ [[]],
+ 'images/rotate_90/', 'Rotated by 90 degrees')
+
+ imggen.gen(filters.Rotate180Alloc, [],
+ [[]],
+ 'images/rotate_180/', 'Rotated by 180 degrees')
+
+ imggen.gen(filters.Rotate270Alloc, [],
+ [[]],
+ 'images/rotate_270/', 'Rotated by 270 degrees')
+
imggen.gen(filters.GaussianBlurAlloc, ['xsig', 'ysig'],
[[2, 2], [0, 4], [4, 0], [4, 4], [10, 10]],
'images/blur/', 'Gaussian Blur')
diff --git a/doc/images/rotate_180/images.txt b/doc/images/rotate_180/images.txt
new file mode 100644
index 0000000..c992eb5
--- /dev/null
+++ b/doc/images/rotate_180/images.txt
@@ -0,0 +1,8 @@
+.Original Image; Rotated by 180 degrees
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/rotate_180/lenna_small_.png[
+ "Rotated by 180 degrees ",
+ link="images/rotate_180/lenna_.png"]
+
diff --git a/doc/images/rotate_180/lenna_.png b/doc/images/rotate_180/lenna_.png
new file mode 100644
index 0000000..650a3cf
Binary files /dev/null and b/doc/images/rotate_180/lenna_.png differ
diff --git a/doc/images/rotate_180/lenna_small_.png b/doc/images/rotate_180/lenna_small_.png
new file mode 100644
index 0000000..35df519
Binary files /dev/null and b/doc/images/rotate_180/lenna_small_.png differ
diff --git a/doc/images/rotate_270/images.txt b/doc/images/rotate_270/images.txt
new file mode 100644
index 0000000..7f1a560
--- /dev/null
+++ b/doc/images/rotate_270/images.txt
@@ -0,0 +1,8 @@
+.Original Image; Rotated by 270 degrees
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/rotate_270/lenna_small_.png[
+ "Rotated by 270 degrees ",
+ link="images/rotate_270/lenna_.png"]
+
diff --git a/doc/images/rotate_270/lenna_.png b/doc/images/rotate_270/lenna_.png
new file mode 100644
index 0000000..c93aaeb
Binary files /dev/null and b/doc/images/rotate_270/lenna_.png differ
diff --git a/doc/images/rotate_270/lenna_small_.png b/doc/images/rotate_270/lenna_small_.png
new file mode 100644
index 0000000..7a43342
Binary files /dev/null and b/doc/images/rotate_270/lenna_small_.png differ
diff --git a/doc/images/rotate_90/images.txt b/doc/images/rotate_90/images.txt
new file mode 100644
index 0000000..d8e3f38
--- /dev/null
+++ b/doc/images/rotate_90/images.txt
@@ -0,0 +1,8 @@
+.Original Image; Rotated by 90 degrees
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/rotate_90/lenna_small_.png[
+ "Rotated by 90 degrees ",
+ link="images/rotate_90/lenna_.png"]
+
diff --git a/doc/images/rotate_90/lenna_.png b/doc/images/rotate_90/lenna_.png
new file mode 100644
index 0000000..897940c
Binary files /dev/null and b/doc/images/rotate_90/lenna_.png differ
diff --git a/doc/images/rotate_90/lenna_small_.png b/doc/images/rotate_90/lenna_small_.png
new file mode 100644
index 0000000..8690302
Binary files /dev/null and b/doc/images/rotate_90/lenna_small_.png differ
http://repo.or.cz/w/gfxprim.git/commit/3ae0e5346bd38347c6642829238bf2db9d47…
commit 3ae0e5346bd38347c6642829238bf2db9d4716a3
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 00:30:30 2013 +0100
build: Update list of filter exported symbols.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Filters_symbols.txt b/build/syms/Filters_symbols.txt
index 8350180..9b5b73b 100644
--- a/build/syms/Filters_symbols.txt
+++ b/build/syms/Filters_symbols.txt
@@ -14,6 +14,12 @@ GP_FilterBrightnessExAlloc
GP_FilterContrastEx
GP_FilterContrastExAlloc
+GP_FilterBrightnessContrastEx
+GP_FilterBrightnessContrastExAlloc
+
+GP_FilterPosterizeEx
+GP_FilterPosterizeExAlloc
+
GP_FilterAddition
GP_FilterAdditionAlloc
GP_FilterAddition_Raw
@@ -83,9 +89,6 @@ GP_FilterMultiply
GP_FilterMultiplyAlloc
GP_FilterMultiply_Raw
-GP_FilterNoise
-GP_FilterNoise_Raw
-
GP_FilterParamChannel
GP_FilterParamChannels
GP_FilterParamCheckChannels
@@ -107,9 +110,6 @@ GP_FilterParamSetPtrAll
GP_FilterParamSetUInt
GP_FilterParamSetUIntAll
-GP_FilterPoint
-GP_FilterPoint_Raw
-
GP_FilterResize
GP_FilterResizeAlloc
http://repo.or.cz/w/gfxprim.git/commit/a5806c8cd1c03efe50cef124116278d067fd…
commit a5806c8cd1c03efe50cef124116278d067fdc793
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 00:28:42 2013 +0100
filters: Remove unused GP_Noise.gen.c.t and GP_Point.gen.c.t
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_Noise.gen.c.t b/libs/filters/GP_Noise.gen.c.t
deleted file mode 100644
index e48d72c..0000000
--- a/libs/filters/GP_Noise.gen.c.t
+++ /dev/null
@@ -1,56 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "filter.point.c.t"
-
-{% block descr %}Noise filter -- Adds noise to an image.{% endblock %}
-
-%% block body
-
-{{ filter_point_include() }}
-
-%% macro filter_op(chann_name, chann_size)
-{{ chann_name }} = {{ chann_name }} + (random() % ({{ chann_name }}_max * 2)) - {{ chann_name }}_max;
-{{ filter_clamp_val(chann_name, chann_size) }}
-%% endmacro
-
-/*
- * Generated noise filters.
- */
-%% call(pt) filter_point_per_channel('Noise', 'GP_FilterParam ratio[]', filter_op)
-{{ filter_params(pt, 'ratio', 'float ', '_rat', 'f') }}
-%% for chann in pt.chanslist
- int {{ chann[0] }}_max = {{ chann[0] }}_rat * {{ 2 ** chann[2] - 1}} + 0.5;
-%% endfor
-%% endcall
-
-/*
- * Generated noise filters for pixels with one channel.
- */
-%% call(ps) filter_point_per_bpp('Noise', 'GP_FilterParam ratio[]', filter_op)
-{{ filter_param(ps, 'ratio', 'float ', '_rat', 'f') }}
- int pix_max = pix_rat * {{ 2 ** ps.size - 1}} + 0.5;
-%% endcall
-
-{{ filter_functions('Noise', 'GP_FilterParam ratio[]', 'ratio') }}
-
-%% endblock body
diff --git a/libs/filters/GP_Point.gen.c.t b/libs/filters/GP_Point.gen.c.t
deleted file mode 100644
index 74c96b2..0000000
--- a/libs/filters/GP_Point.gen.c.t
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2011 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-%% extends "filter.point.c.t"
-
-%% block descr
-Point filters -- General point filter.
-%% endblock
-
-%% block body
-
-{{ filter_point_include() }}
-
-typedef uint32_t (*func)(uint32_t, uint8_t, GP_FilterParam *priv);
-
-%% macro filter_op(chan_name, chan_size)
-{{ chan_name }} = {{ chan_name }}_func({{ chan_name }}, {{ chan_size }}, {{ chan_name }}_priv);
-%% endmacro
-
-/*
- * Generated point filters for pixels with several channels.
- */
-%% call(pt) filter_point_per_channel('Point', 'GP_FilterParam filter_callbacks[], GP_FilterParam priv[]', filter_op)
-{{ filter_params(pt, 'filter_callbacks', 'func ', '_func', 'ptr') }}
-{{ filter_params_raw(pt, 'priv', '_priv') }}
-%% endcall
-
-/*
- * Generated point filters for pixels with one channel.
- */
-%% call(ps) filter_point_per_bpp('Point', 'GP_FilterParam filter_callbacks[], GP_FilterParam priv[]', filter_op)
-{{ filter_param(ps, 'filter_callbacks', 'func ', '_func', 'ptr') }}
-{{ filter_param_raw(ps, 'priv', '_priv') }}
-%% endcall
-
-{{ filter_functions('Point', 'GP_FilterParam filter_callbacks[], GP_FilterParam priv[]', 'filter_callbacks, priv') }}
-
-%% endblock body
http://repo.or.cz/w/gfxprim.git/commit/acb23fffacdae415b778e2effdc506d8d3b8…
commit acb23fffacdae415b778e2effdc506d8d3b8b420
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 00:25:01 2013 +0100
filters: Rotate: Remove the _Raw variants from API.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Filters_symbols.txt b/build/syms/Filters_symbols.txt
index 1e8b74b..8350180 100644
--- a/build/syms/Filters_symbols.txt
+++ b/build/syms/Filters_symbols.txt
@@ -121,15 +121,12 @@ GP_FilterResizeCubic
GP_FilterRotate180
GP_FilterRotate180Alloc
-GP_FilterRotate180_Raw
GP_FilterRotate270
GP_FilterRotate270Alloc
-GP_FilterRotate270_Raw
GP_FilterRotate90
GP_FilterRotate90Alloc
-GP_FilterRotate90_Raw
GP_FilterSigmaEx
GP_FilterSigmaExAlloc
diff --git a/libs/filters/GP_MirrorH.gen.c.t b/libs/filters/GP_MirrorH.gen.c.t
index 4194eab..e190c37 100644
--- a/libs/filters/GP_MirrorH.gen.c.t
+++ b/libs/filters/GP_MirrorH.gen.c.t
@@ -65,11 +65,46 @@ static int GP_MirrorH_Raw_{{ ps.suffix }}(const GP_Context *src,
%% endfor
-int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
+static int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
{
GP_FN_RET_PER_BPP_CONTEXT(GP_MirrorH_Raw, src, src, dst, callback);
return 1;
}
+int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ GP_ASSERT(src->pixel_type == dst->pixel_type,
+ "The src and dst pixel types must match");
+ GP_ASSERT(src->w <= dst->w && src->h <= dst->h,
+ "Destination is not large enough");
+
+ if (GP_FilterMirrorH_Raw(src, dst, callback)) {
+ GP_DEBUG(1, "Operation aborted");
+ return 1;
+ }
+
+ return 0;
+}
+
+GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
+ GP_ProgressCallback *callback)
+{
+ GP_Context *res;
+
+ res = GP_ContextCopy(src, 0);
+
+ if (res == NULL)
+ return NULL;
+
+ if (GP_FilterMirrorH_Raw(src, res, callback)) {
+ GP_ContextFree(res);
+ return NULL;
+ }
+
+ return res;
+}
+
+
%% endblock body
diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c
index 5200b55..1b3f741 100644
--- a/libs/filters/GP_Rotate.c
+++ b/libs/filters/GP_Rotate.c
@@ -105,145 +105,6 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src,
return res;
}
-int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- GP_ASSERT(src->pixel_type == dst->pixel_type,
- "The src and dst pixel types must match");
- GP_ASSERT(src->w <= dst->w && src->h <= dst->h,
- "Destination is not large enough");
-
- if (GP_FilterMirrorH_Raw(src, dst, callback)) {
- GP_DEBUG(1, "Operation aborted");
- return 1;
- }
-
- return 0;
-}
-
-GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
- GP_ProgressCallback *callback)
-{
- GP_Context *res;
-
- res = GP_ContextCopy(src, 0);
-
- if (res == NULL)
- return NULL;
-
- if (GP_FilterMirrorH_Raw(src, res, callback)) {
- GP_ContextFree(res);
- return NULL;
- }
-
- return res;
-}
-
-int GP_FilterRotate90(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- GP_ASSERT(src->pixel_type == dst->pixel_type,
- "The src and dst pixel types must match");
- GP_ASSERT(src->w <= dst->h && src->h <= dst->w,
- "Destination is not large enough");
-
- if (GP_FilterRotate90_Raw(src, dst, callback)) {
- GP_DEBUG(1, "Operation aborted");
- return 1;
- }
-
- return 0;
-}
-
-GP_Context *GP_FilterRotate90Alloc(const GP_Context *src,
- GP_ProgressCallback *callback)
-{
- GP_Context *res;
-
- res = GP_ContextAlloc(src->h, src->w, src->pixel_type);
-
- if (res == NULL)
- return NULL;
-
- if (GP_FilterRotate90_Raw(src, res, callback)) {
- GP_DEBUG(1, "Operation aborted");
- GP_ContextFree(res);
- return NULL;
- }
-
- return res;
-}
-
-int GP_FilterRotate180(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- GP_ASSERT(src->pixel_type == dst->pixel_type,
- "The src and dst pixel types must match");
- GP_ASSERT(src->w <= dst->w && src->h <= dst->h,
- "Destination is not large enough");
-
- if (GP_FilterRotate180_Raw(src, dst, callback)) {
- GP_DEBUG(1, "Operation aborted");
- return 1;
- }
-
- return 0;
-}
-
-GP_Context *GP_FilterRotate180Alloc(const GP_Context *src,
- GP_ProgressCallback *callback)
-{
- GP_Context *res;
-
- res = GP_ContextCopy(src, 0);
-
- if (res == NULL)
- return NULL;
-
- if (GP_FilterRotate180_Raw(src, res, callback)) {
- GP_DEBUG(1, "Operation aborted");
- GP_ContextFree(res);
- return NULL;
- }
-
- return res;
-}
-
-int GP_FilterRotate270(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- GP_ASSERT(src->pixel_type == dst->pixel_type,
- "The src and dst pixel types must match");
- GP_ASSERT(src->w <= dst->h && src->h <= dst->w,
- "Destination is not large enough");
-
- if (GP_FilterRotate270_Raw(src, dst, callback)) {
- GP_DEBUG(1, "Operation aborted");
- return 1;
- }
-
- return 0;
-}
-
-GP_Context *GP_FilterRotate270Alloc(const GP_Context *src,
- GP_ProgressCallback *callback)
-{
- GP_Context *res;
-
- res = GP_ContextAlloc(src->h, src->w, src->pixel_type);
-
- if (res == NULL)
- return NULL;
-
- if (GP_FilterRotate270_Raw(src, res, callback)) {
- GP_DEBUG(1, "Operation aborted");
- GP_ContextFree(res);
- return NULL;
- }
-
- return res;
-}
-
static const char *symmetry_names[] = {
"90",
"180",
diff --git a/libs/filters/GP_Rotate.gen.c.t b/libs/filters/GP_Rotate.gen.c.t
index 364dd77..05c404c 100644
--- a/libs/filters/GP_Rotate.gen.c.t
+++ b/libs/filters/GP_Rotate.gen.c.t
@@ -54,13 +54,48 @@ static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Conte
%% endfor
-int GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
+static int GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
{
GP_FN_RET_PER_BPP_CONTEXT(GP_FilterRotate90_Raw, src, src, dst, callback);
return 1;
}
+int GP_FilterRotate90(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ GP_ASSERT(src->pixel_type == dst->pixel_type,
+ "The src and dst pixel types must match");
+ GP_ASSERT(src->w <= dst->h && src->h <= dst->w,
+ "Destination is not large enough");
+
+ if (GP_FilterRotate90_Raw(src, dst, callback)) {
+ GP_DEBUG(1, "Operation aborted");
+ return 1;
+ }
+
+ return 0;
+}
+
+GP_Context *GP_FilterRotate90Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback)
+{
+ GP_Context *res;
+
+ res = GP_ContextAlloc(src->h, src->w, src->pixel_type);
+
+ if (res == NULL)
+ return NULL;
+
+ if (GP_FilterRotate90_Raw(src, res, callback)) {
+ GP_DEBUG(1, "Operation aborted");
+ GP_ContextFree(res);
+ return NULL;
+ }
+
+ return res;
+}
+
%% macro swap_pixels(ps, src, dst, x0, y0, x1, y1)
GP_Pixel pix0 = GP_GetPixel_Raw_{{ ps.suffix }}({{ src }}, {{ x0 }}, {{ y0 }});
GP_Pixel pix1 = GP_GetPixel_Raw_{{ ps.suffix }}({{ src }}, {{ x1 }}, {{ y1 }});
@@ -94,13 +129,48 @@ static int GP_FilterRotate180_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont
%% endfor
-int GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
+static int GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
{
GP_FN_RET_PER_BPP_CONTEXT(GP_FilterRotate180_Raw, src, src, dst, callback);
return 1;
}
+int GP_FilterRotate180(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ GP_ASSERT(src->pixel_type == dst->pixel_type,
+ "The src and dst pixel types must match");
+ GP_ASSERT(src->w <= dst->w && src->h <= dst->h,
+ "Destination is not large enough");
+
+ if (GP_FilterRotate180_Raw(src, dst, callback)) {
+ GP_DEBUG(1, "Operation aborted");
+ return 1;
+ }
+
+ return 0;
+}
+
+GP_Context *GP_FilterRotate180Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback)
+{
+ GP_Context *res;
+
+ res = GP_ContextCopy(src, 0);
+
+ if (res == NULL)
+ return NULL;
+
+ if (GP_FilterRotate180_Raw(src, res, callback)) {
+ GP_DEBUG(1, "Operation aborted");
+ GP_ContextFree(res);
+ return NULL;
+ }
+
+ return res;
+}
+
%% for ps in pixelsizes
static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
@@ -125,11 +195,46 @@ static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont
%% endfor
-int GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
+static int GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
{
GP_FN_RET_PER_BPP_CONTEXT(GP_FilterRotate270_Raw, src, src, dst, callback);
return 1;
}
+int GP_FilterRotate270(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ GP_ASSERT(src->pixel_type == dst->pixel_type,
+ "The src and dst pixel types must match");
+ GP_ASSERT(src->w <= dst->h && src->h <= dst->w,
+ "Destination is not large enough");
+
+ if (GP_FilterRotate270_Raw(src, dst, callback)) {
+ GP_DEBUG(1, "Operation aborted");
+ return 1;
+ }
+
+ return 0;
+}
+
+GP_Context *GP_FilterRotate270Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback)
+{
+ GP_Context *res;
+
+ res = GP_ContextAlloc(src->h, src->w, src->pixel_type);
+
+ if (res == NULL)
+ return NULL;
+
+ if (GP_FilterRotate270_Raw(src, res, callback)) {
+ GP_DEBUG(1, "Operation aborted");
+ GP_ContextFree(res);
+ return NULL;
+ }
+
+ return res;
+}
+
%% endblock body
http://repo.or.cz/w/gfxprim.git/commit/280e32f1a1d6f25018f19a0a793f47014465…
commit 280e32f1a1d6f25018f19a0a793f470144650eef
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 00:15:01 2013 +0100
filters: Rotate: Remove _Raw prototypes from header.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/filters/GP_Rotate.h b/include/filters/GP_Rotate.h
index 356ceb1..f156068 100644
--- a/include/filters/GP_Rotate.h
+++ b/include/filters/GP_Rotate.h
@@ -33,16 +33,6 @@
#include "GP_Filter.h"
/*
- * Mirror horizontally.
- *
- * Works 'in place'. The contexts must have equal pixel_type and size.
- *
- * This is semi-internal function without any assertions on destination.
- */
-int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
-
-/*
* Mirrors bitmap horizontally.
*
* The dst must be at least as big as source.
@@ -66,16 +56,6 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
GP_ProgressCallback *callback);
/*
- * Mirror vertically
- *
- * Works 'in place'. The contexts must have equal pixel_type and size.
- *
- * This is semi-internal function without any assertions on destination.
- */
-int GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
-
-/*
* Mirrors bitmap vertically.
*
* The dst must be at least as big as source.
@@ -99,23 +79,6 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src,
GP_ProgressCallback *callback);
/*
- * Rotate context by 90, 180 and 270.
- *
- * Doesn't work 'in place'. The contexts must have equal pixel_type size must
- * match the rotated size (is equal for 180 and swapped for 90 and 270).
- *
- * These are semi-internal functions without any assertions on destination.
- */
-int GP_FilterRotate90_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
-
-int GP_FilterRotate180_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
-
-int GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
-
-/*
* Rotate the context by 90, 180, 270.
*
* Returns pointer to destination bitmap or NULL if allocation failed.
http://repo.or.cz/w/gfxprim.git/commit/6a4ef1c559652d3f2e1d7c1e69d47f214364…
commit 6a4ef1c559652d3f2e1d7c1e69d47f214364a9d6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 00:13:34 2013 +0100
filters: Swap GP_MirrorH() and GP_MirrorV()
I've got it wrong when I was implementing them...
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_MirrorV.gen.c.t b/libs/filters/GP_MirrorH.gen.c.t
similarity index 89%
rename from libs/filters/GP_MirrorV.gen.c.t
rename to libs/filters/GP_MirrorH.gen.c.t
index 99599af..4194eab 100644
--- a/libs/filters/GP_MirrorV.gen.c.t
+++ b/libs/filters/GP_MirrorH.gen.c.t
@@ -22,7 +22,7 @@
%% extends "base.c.t"
-{% block descr %}Vertical Mirror alogorithm{% endblock %}
+{% block descr %}Horizontal Mirror alogorithm{% endblock %}
%% block body
@@ -31,14 +31,14 @@
#include "GP_Rotate.h"
%% for ps in pixelsizes
-static int GP_MirrorV_Raw_{{ ps.suffix }}(const GP_Context *src,
+static int GP_MirrorH_Raw_{{ ps.suffix }}(const GP_Context *src,
GP_Context *dst,
GP_ProgressCallback *callback)
{
uint32_t x, y;
GP_Pixel tmp;
- GP_DEBUG(1, "Mirroring image vertically %ux%u", src->w, src->h);
+ GP_DEBUG(1, "Mirroring image %ux%u horizontally", src->w, src->h);
for (x = 0; x < src->w/2; x++) {
uint32_t xm = src->w - x - 1;
@@ -65,10 +65,10 @@ static int GP_MirrorV_Raw_{{ ps.suffix }}(const GP_Context *src,
%% endfor
-int GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst,
+int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
- GP_FN_RET_PER_BPP_CONTEXT(GP_MirrorV_Raw, src, src, dst, callback);
+ GP_FN_RET_PER_BPP_CONTEXT(GP_MirrorH_Raw, src, src, dst, callback);
return 1;
}
diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c
index 0e53645..5200b55 100644
--- a/libs/filters/GP_Rotate.c
+++ b/libs/filters/GP_Rotate.c
@@ -29,14 +29,14 @@
#include <string.h>
-int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst,
+int GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
uint32_t bpr = src->bytes_per_row;
uint8_t buf[bpr];
unsigned int y;
- GP_DEBUG(1, "Mirroring image horizontally %ux%u", src->w, src->h);
+ GP_DEBUG(1, "Mirroring image %ux%u vertically", src->w, src->h);
#warning FIXME: non byte aligned pixels
@@ -72,7 +72,7 @@ int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst,
return 0;
}
-int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
+int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
GP_ASSERT(src->pixel_type == dst->pixel_type,
@@ -81,13 +81,13 @@ int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
GP_ASSERT(src->w <= dst->w && src->h <= dst->h,
"Destination is not large enough");
- if (GP_FilterMirrorH_Raw(src, dst, callback))
+ if (GP_FilterMirrorV_Raw(src, dst, callback))
return 1;
return 0;
}
-GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
+GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_Context *res;
@@ -97,7 +97,7 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
if (res == NULL)
return NULL;
- if (GP_FilterMirrorH_Raw(src, res, callback)) {
+ if (GP_FilterMirrorV_Raw(src, res, callback)) {
GP_ContextFree(res);
return NULL;
}
@@ -105,7 +105,7 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
return res;
}
-int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst,
+int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
GP_ASSERT(src->pixel_type == dst->pixel_type,
@@ -113,7 +113,7 @@ int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst,
GP_ASSERT(src->w <= dst->w && src->h <= dst->h,
"Destination is not large enough");
- if (GP_FilterMirrorV_Raw(src, dst, callback)) {
+ if (GP_FilterMirrorH_Raw(src, dst, callback)) {
GP_DEBUG(1, "Operation aborted");
return 1;
}
@@ -121,7 +121,7 @@ int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst,
return 0;
}
-GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src,
+GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_Context *res;
@@ -131,7 +131,7 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src,
if (res == NULL)
return NULL;
- if (GP_FilterMirrorV_Raw(src, res, callback)) {
+ if (GP_FilterMirrorH_Raw(src, res, callback)) {
GP_ContextFree(res);
return NULL;
}
diff --git a/libs/filters/Makefile b/libs/filters/Makefile
index c929aa7..d1a909c 100644
--- a/libs/filters/Makefile
+++ b/libs/filters/Makefile
@@ -13,7 +13,7 @@ ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c RESAMPLING_FILTERS=GP_ResizeNN.gen.c GP_Cubic.gen.c GP_ResizeCubic.gen.c GP_ResizeLinear.gen.c
-GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_FloydSteinberg.gen.c GP_HilbertPeano.gen.c+GENSOURCES=GP_MirrorH.gen.c GP_Rotate.gen.c GP_FloydSteinberg.gen.c GP_HilbertPeano.gen.c $(POINT_FILTERS) $(ARITHMETIC_FILTERS) $(STATS_FILTERS) $(RESAMPLING_FILTERS) GP_LinearConvolution.gen.c
http://repo.or.cz/w/gfxprim.git/commit/445b1c8edfd8a95ad0f40e13f20eade2f6fb…
commit 445b1c8edfd8a95ad0f40e13f20eade2f6fbed10
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Nov 9 00:03:40 2013 +0100
filters: GP_Rotate.c: Fix whitespaces.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c
index 6aff0ba..0e53645 100644
--- a/libs/filters/GP_Rotate.c
+++ b/libs/filters/GP_Rotate.c
@@ -125,9 +125,9 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_Context *res;
-
+
res = GP_ContextCopy(src, 0);
-
+
if (res == NULL)
return NULL;
@@ -135,7 +135,7 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src,
GP_ContextFree(res);
return NULL;
}
-
+
return res;
}
@@ -159,9 +159,9 @@ GP_Context *GP_FilterRotate90Alloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_Context *res;
-
+
res = GP_ContextAlloc(src->h, src->w, src->pixel_type);
-
+
if (res == NULL)
return NULL;
@@ -194,9 +194,9 @@ GP_Context *GP_FilterRotate180Alloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_Context *res;
-
+
res = GP_ContextCopy(src, 0);
-
+
if (res == NULL)
return NULL;
@@ -229,9 +229,9 @@ GP_Context *GP_FilterRotate270Alloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_Context *res;
-
+
res = GP_ContextAlloc(src->h, src->w, src->pixel_type);
-
+
if (res == NULL)
return NULL;
http://repo.or.cz/w/gfxprim.git/commit/ef943c2310c1345dbc8bd34c3cdd26648ed7…
commit ef943c2310c1345dbc8bd34c3cdd26648ed79420
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 8 23:41:15 2013 +0100
doc: Update/Add point filters docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/filters.txt b/doc/filters.txt
index ed39486..93a2888 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -54,204 +54,116 @@ GP_Context *GP_FilterFooAlloc(const GP_Context *src,
-------------------------------------------------------------------------------
-Filters also exists in _Raw variant whose interface is similar to the first
-type of filter function. These filter APIs are used for internal
-implementation and shouldn't be called by user as the destination is expected
-to be crafted exactly for storing the filter result and there are 'NO' sanity
-checks in place.
+Point Filters
+~~~~~~~~~~~~~
-'You could use these at your own risk'
-
-[source,c]
--------------------------------------------------------------------------------
-/*
- * Raw filter common API.
- */
-int GP_FilterFoo_Raw(const GP_Context *src, GP_Context *dst,
- foo params ...,
- GP_ProgressCallback *callback);
--------------------------------------------------------------------------------
-
-Filter Parameters
-~~~~~~~~~~~~~~~~~
+Point operations are filters that works with pixels as with independent values
+(the value of destination pixel depends only on the pixel on the same
+coordinates in source image). All of these filters works 'in-place' and the
+result has always the same size as the source.
-In order to pass, per-channel, filter parameters to a filter, structure called
-GP_FilterParams was created.
+Invert
+^^^^^^
[source,c]
-------------------------------------------------------------------------------
#include <GP.h>
/* or */
-#include <filters/GP_FilterParam.h>
+#include <filters/GP_Point.h>
-typedef union GP_FilterParamVal {
- float f;
- uint32_t ui;
- int32_t i;
- void *ptr;
-} GP_FilterParamVal;
+int GP_FilterInvert(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback);
-typedef struct GP_FilterParam {
- char channel_name[2];
- union GP_FilterParamVal val;
-} GP_FilterParam;
+GP_Context *GP_FilterInvertAlloc(const GP_Context *src,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Some filters do take an empty channel_name terminated (empty channel_name is
-empty string i.e. "0") array of GP_FilterParam, which is used to describe
-per-channel parameters.
+The pixel channel values are counted as +chann_max - val+.
+include::images/invert/images.txt[]
-There are two methods how to construct GP_FilterParam structure. First one is
-to use macro that expands to a code which declares and initializes the array on
-the stack second uses memory allocated by a malloc(). In both cases the
-structure is has initialized channel names and terminator.
+Brightness
+^^^^^^^^^^
[source,c]
-------------------------------------------------------------------------------
#include <GP.h>
/* or */
-#include <filters/GP_FilterParam.h>
-
-#define GP_FILTER_PARAMS(pixel_type, name) - GP_FilterParam name[GP_PixelTypes[pixel_type].numchannels + 1]; - GP_FilterParamInitChannels(name, pixel_type);
--------------------------------------------------------------------------------
+#include <filters/GP_Point.h>
-Macro that declares and initializes GP_FilterParam structure for a given
-pixel_type.
+int GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
+ float p, GP_ProgressCallback *callback);
-[source,c]
+GP_Context *GP_FilterBrightnessAlloc(const GP_Context *src, float p,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-#include <GP.h>
-/* or */
-#include <filters/GP_FilterParam.h>
-GP_FilterParam *GP_FilterParamCreate(GP_PixelType pixel_type);
+The pixel channel values are counted as +val + chann_max * p+.
-void GP_FilterParamDestroy(GP_FilterParam *self);
--------------------------------------------------------------------------------
+include::images/brightness/images.txt[]
-Second possible way allocates memory using malloc().
-
-Functions for manipulating and querying existing GP_FilterParam follows.
+Contrast
+^^^^^^^^
[source,c]
-------------------------------------------------------------------------------
#include <GP.h>
/* or */
-#include <filters/GP_FilterParam.h>
-
-void GP_FilterParamInitChannels(GP_FilterParam params[],
- GP_PixelType pixel_type);
--------------------------------------------------------------------------------
+#include <filters/GP_Point.h>
-Initializes filter param array channel names (accordingly to pixel type) and
-terminator. The params array must be large enough to hold number of pixel type
-channels plus one.
+int GP_FilterContrast(const GP_Context *src, GP_Context *dst,
+ float p, GP_ProgressCallback *callback);
-[source,c]
--------------------------------------------------------------------------------
-#include <GP.h>
-/* or */
-#include <filters/GP_FilterParam.h>
-
-GP_FilterParam *GP_FilterParamChannel(GP_FilterParam params[],
- const char *channel_name);
+GP_Context *GP_FilterContrastAlloc(const GP_Context *src, float p,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Does lookup for a given channel name and returns, if found, corresponding
-GP_FilterParam, otherwise 'NULL' is returned.
-
-This function is primary used in filters, where filter, at the start, resolves
-all it's parameters.
-
-[source,c]
--------------------------------------------------------------------------------
-#include <GP.h>
-/* or */
-#include <filters/GP_FilterParam.h>
+The pixel channel values are counted as +val * p+.
-int GP_FilterParamCheckPixelType(GP_FilterParam params[],
- GP_PixelType pixel_type);
--------------------------------------------------------------------------------
+include::images/contrast/images.txt[]
-Matches param structure against pixel_type. Returns zero if params describes
-exactly same channels like pixel_type, non-zero otherwise.
+BrightnessContrast
+^^^^^^^^^^^^^^^^^^
[source,c]
-------------------------------------------------------------------------------
#include <GP.h>
/* or */
-#include <filters/GP_FilterParam.h>
-
-void GP_FilterParamSetIntAll(GP_FilterParam params[], int32_t val);
-
-int GP_FilterParamSetInt(GP_FilterParam params[], const char *channel_name,
- int32_t val);
-
-void GP_FilterParamSetFloatAll(GP_FilterParam params[], float val);
-
-int GP_FilterParamSetFloat(GP_FilterParam params[], const char *channel_name,
- float val);
-
-void GP_FilterParamSetUIntAll(GP_FilterParam params[], uint32_t val);
+#include <filters/GP_Point.h>
-int GP_FilterParamSetUInt(GP_FilterParam params[], const char *channel_name,
- uint32_t val);
-
-void GP_FilterParamSetPtrAll(GP_FilterParam params[], void *ptr);
-
-int GP_FilterParamSetPtr(GP_FilterParam params[], const char *channel_name,
- void *ptr);
+int GP_FilterBrightnessContrast(const GP_Context *src, GP_Context *dst,
+ float b, float c,
+ GP_ProgressCallback *callback);
-void GP_FilterParamFreePtrAll(GP_FilterParam params[]);
+GP_Context *GP_FilterBrightnessContrastAlloc(const GP_Context *src,
+ float b, float c,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Parameter setters. Those that sets individual value returns zero on success
-(i.e. channel was found) and non-zero otherwise.
+The pixel channel values are counted as +val * c + chann_max * b+.
-The last one calls free() on all param pointers, which is used to free
-allocate memory.
+include::images/brightness_contrast/images.txt[]
-Point operation filters
-~~~~~~~~~~~~~~~~~~~~~~~
-
-Point operations are filters that works with pixels as with independent values
-(the value of destination pixel depends only on the pixel on the same
-coordinates in source image). All of these filters works 'in-place' and the
-result has always the same size as the source.
+Posterize
+^^^^^^^^^
[source,c]
-------------------------------------------------------------------------------
-#include <GP_Filters.h>
-
-GP_Context *GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
- int32_t inc, GP_ProgressCallback *callback);
--------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <filters/GP_Point.h>
-Brightness filter, increments all pixel channels by a fixed value.
+int GP_FilterPosterize(const GP_Context *src, GP_Context *dst,
+ unsigned int levels, GP_ProgressCallback *callback);
-[source,c]
--------------------------------------------------------------------------------
-#include <GP_Filters.h>
-
-GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst,
- float mul, GP_ProgressCallback *callback);
+GP_Context *GP_FilterPosterizeAlloc(const GP_Context *src, unsigned int levels,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Contrast filter, multiplies all pixel channels by a fixed value.
-
-[source,c]
--------------------------------------------------------------------------------
-#include <GP_Filters.h>
+The pixel channel values are quantized into number of levels.
-GP_Context *GP_FilterInvert(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
--------------------------------------------------------------------------------
+include::images/posterize/images.txt[]
-Inverts the image, for each channel the result value is computed as "chan_max
-- val".
Gaussian additive noise filter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/filters_python.txt b/doc/filters_python.txt
index db7eb9d..6802510 100644
--- a/doc/filters_python.txt
+++ b/doc/filters_python.txt
@@ -11,6 +11,109 @@ image is passed automatically as a first parameter.
If filter has been aborted from callback 'OSError' with 'errno' set to
'ECANCELED' is raised.
+Point Filters
+~~~~~~~~~~~~~
+
+Invert
+^^^^^^
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Inverts image in-place
+ img.filters.Invert(img, callback=None)
+
+ # Returns newly allocated inverted image
+ res = img.filters.InvertAlloc(callback=None)
+
+-------------------------------------------------------------------------------
+
+The pixel channel values are counted as +chann_max - val+.
+
+include::images/invert/images.txt[]
+
+Brightness
+^^^^^^^^^^
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Increses images brightness in-place by channel_max * 0.2
+ img.filters.Brightness(img, 0.2, callback=None)
+
+ # Returns image with brightness decreased by channel_max * -0.5
+ res = img.filters.BrightnessAlloc(img, -0.5, callback=None)
+
+-------------------------------------------------------------------------------
+
+The pixel channel values are counted as +val + chann_max * p+.
+
+include::images/brightness/images.txt[]
+
+Contrast
+^^^^^^^^
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Increses images contrast by 1.2
+ img.filters.Contrast(img, 1.2, callback=None)
+
+ # Returns image with contrast decreased by 0.2
+ res = img.filters.ContrastAlloc(img, 0.2, callback=None)
+
+-------------------------------------------------------------------------------
+
+The pixel channel values are counted as +val * p+.
+
+include::images/contrast/images.txt[]
+
+BrightnessContrast
+^^^^^^^^^^^^^^^^^^
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Increses images contrast by 1.2 decreases brightness by -0.2
+ img.filters.BrightnessContrast(img, -0.2, 1.2, callback=None)
+
+ # Returns image with contrast decreased by 0.2 brightness increased by .5
+ res = img.filters.BrightnessContrastAlloc(img, 0.5, 0.2, callback=None)
+
+-------------------------------------------------------------------------------
+
+The pixel channel values are counted as +val * c + chann_max * b+.
+
+include::images/brightness_contrast/images.txt[]
+
+Posterize
+^^^^^^^^^
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.core as core
+import gfxprim.filters as filters
+
+ # Posterizes image using 2 steps
+ img.filters.Posterize(img, 2, callback=None)
+
+ # Returns image posterized into 4 levels
+ res = img.filters.PosterizeAlloc(img, 4, callback=None)
+
+-------------------------------------------------------------------------------
+
+The pixel channel values are quantized into number of levels.
+
+include::images/posterize/images.txt[]
+
Gaussian Additive Noise
~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/images/brightness/images.txt b/doc/images/brightness/images.txt
new file mode 100644
index 0000000..37836f4
--- /dev/null
+++ b/doc/images/brightness/images.txt
@@ -0,0 +1,17 @@
+.Original Image; Brightness p=-0.5, p=-0.2, p=0.2, p=0.5
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/brightness/lenna_small_-0.5.png[
+ "Brightness -0.5",
+ link="images/brightness/lenna_-0.5.png"]
+image:images/brightness/lenna_small_-0.2.png[
+ "Brightness -0.2",
+ link="images/brightness/lenna_-0.2.png"]
+image:images/brightness/lenna_small_0.2.png[
+ "Brightness 0.2",
+ link="images/brightness/lenna_0.2.png"]
+image:images/brightness/lenna_small_0.5.png[
+ "Brightness 0.5",
+ link="images/brightness/lenna_0.5.png"]
+
diff --git a/doc/images/brightness/lenna_-0.2.png b/doc/images/brightness/lenna_-0.2.png
new file mode 100644
index 0000000..dd6c2ab
Binary files /dev/null and b/doc/images/brightness/lenna_-0.2.png differ
diff --git a/doc/images/brightness/lenna_-0.5.png b/doc/images/brightness/lenna_-0.5.png
new file mode 100644
index 0000000..4305294
Binary files /dev/null and b/doc/images/brightness/lenna_-0.5.png differ
diff --git a/doc/images/brightness/lenna_0.2.png b/doc/images/brightness/lenna_0.2.png
new file mode 100644
index 0000000..35b17ab
Binary files /dev/null and b/doc/images/brightness/lenna_0.2.png differ
diff --git a/doc/images/brightness/lenna_0.5.png b/doc/images/brightness/lenna_0.5.png
new file mode 100644
index 0000000..a2e305f
Binary files /dev/null and b/doc/images/brightness/lenna_0.5.png differ
diff --git a/doc/images/brightness/lenna_small_-0.2.png b/doc/images/brightness/lenna_small_-0.2.png
new file mode 100644
index 0000000..5d45c63
Binary files /dev/null and b/doc/images/brightness/lenna_small_-0.2.png differ
diff --git a/doc/images/brightness/lenna_small_-0.5.png b/doc/images/brightness/lenna_small_-0.5.png
new file mode 100644
index 0000000..11e02c8
Binary files /dev/null and b/doc/images/brightness/lenna_small_-0.5.png differ
diff --git a/doc/images/brightness/lenna_small_0.2.png b/doc/images/brightness/lenna_small_0.2.png
new file mode 100644
index 0000000..dea074e
Binary files /dev/null and b/doc/images/brightness/lenna_small_0.2.png differ
diff --git a/doc/images/brightness/lenna_small_0.5.png b/doc/images/brightness/lenna_small_0.5.png
new file mode 100644
index 0000000..d63e922
Binary files /dev/null and b/doc/images/brightness/lenna_small_0.5.png differ
diff --git a/doc/images/brightness_contrast/images.txt b/doc/images/brightness_contrast/images.txt
new file mode 100644
index 0000000..85812c3
--- /dev/null
+++ b/doc/images/brightness_contrast/images.txt
@@ -0,0 +1,17 @@
+.Original Image; BrightnessContrast b=-0.2 c=0.8, b=-0.5 c=2, b=0.2 c=0.8, b=0.2 c=1.5
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/brightness_contrast/lenna_small_-0.2_0.8.png[
+ "BrightnessContrast -0.2 0.8",
+ link="images/brightness_contrast/lenna_-0.2_0.8.png"]
+image:images/brightness_contrast/lenna_small_-0.5_2.png[
+ "BrightnessContrast -0.5 2",
+ link="images/brightness_contrast/lenna_-0.5_2.png"]
+image:images/brightness_contrast/lenna_small_0.2_0.8.png[
+ "BrightnessContrast 0.2 0.8",
+ link="images/brightness_contrast/lenna_0.2_0.8.png"]
+image:images/brightness_contrast/lenna_small_0.2_1.5.png[
+ "BrightnessContrast 0.2 1.5",
+ link="images/brightness_contrast/lenna_0.2_1.5.png"]
+
diff --git a/doc/images/brightness_contrast/lenna_-0.2_0.8.png b/doc/images/brightness_contrast/lenna_-0.2_0.8.png
new file mode 100644
index 0000000..698eba9
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_-0.2_0.8.png differ
diff --git a/doc/images/brightness_contrast/lenna_-0.5_2.png b/doc/images/brightness_contrast/lenna_-0.5_2.png
new file mode 100644
index 0000000..267c873
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_-0.5_2.png differ
diff --git a/doc/images/brightness_contrast/lenna_0.2_0.5.png b/doc/images/brightness_contrast/lenna_0.2_0.5.png
new file mode 100644
index 0000000..611122d
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_0.2_0.5.png differ
diff --git a/doc/images/brightness_contrast/lenna_0.2_0.8.png b/doc/images/brightness_contrast/lenna_0.2_0.8.png
new file mode 100644
index 0000000..465a3c4
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_0.2_0.8.png differ
diff --git a/doc/images/brightness_contrast/lenna_0.2_1.5.png b/doc/images/brightness_contrast/lenna_0.2_1.5.png
new file mode 100644
index 0000000..36c6a54
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_0.2_1.5.png differ
diff --git a/doc/images/brightness_contrast/lenna_0.4_0.5.png b/doc/images/brightness_contrast/lenna_0.4_0.5.png
new file mode 100644
index 0000000..68cb7b1
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_0.4_0.5.png differ
diff --git a/doc/images/brightness_contrast/lenna_small_-0.2_0.8.png b/doc/images/brightness_contrast/lenna_small_-0.2_0.8.png
new file mode 100644
index 0000000..20ff951
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_-0.2_0.8.png differ
diff --git a/doc/images/brightness_contrast/lenna_small_-0.5_2.png b/doc/images/brightness_contrast/lenna_small_-0.5_2.png
new file mode 100644
index 0000000..7ccab22
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_-0.5_2.png differ
diff --git a/doc/images/brightness_contrast/lenna_small_0.2_0.5.png b/doc/images/brightness_contrast/lenna_small_0.2_0.5.png
new file mode 100644
index 0000000..6752bfb
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_0.2_0.5.png differ
diff --git a/doc/images/brightness_contrast/lenna_small_0.2_0.8.png b/doc/images/brightness_contrast/lenna_small_0.2_0.8.png
new file mode 100644
index 0000000..a4747b9
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_0.2_0.8.png differ
diff --git a/doc/images/brightness_contrast/lenna_small_0.2_1.5.png b/doc/images/brightness_contrast/lenna_small_0.2_1.5.png
new file mode 100644
index 0000000..d177b75
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_0.2_1.5.png differ
diff --git a/doc/images/brightness_contrast/lenna_small_0.4_0.5.png b/doc/images/brightness_contrast/lenna_small_0.4_0.5.png
new file mode 100644
index 0000000..b6af555
Binary files /dev/null and b/doc/images/brightness_contrast/lenna_small_0.4_0.5.png differ
diff --git a/doc/images/contrast/images.txt b/doc/images/contrast/images.txt
new file mode 100644
index 0000000..b4533f6
--- /dev/null
+++ b/doc/images/contrast/images.txt
@@ -0,0 +1,20 @@
+.Original Image; Contrast p=0.2, p=0.5, p=1.5, p=2, p=3
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/contrast/lenna_small_0.2.png[
+ "Contrast 0.2",
+ link="images/contrast/lenna_0.2.png"]
+image:images/contrast/lenna_small_0.5.png[
+ "Contrast 0.5",
+ link="images/contrast/lenna_0.5.png"]
+image:images/contrast/lenna_small_1.5.png[
+ "Contrast 1.5",
+ link="images/contrast/lenna_1.5.png"]
+image:images/contrast/lenna_small_2.png[
+ "Contrast 2",
+ link="images/contrast/lenna_2.png"]
+image:images/contrast/lenna_small_3.png[
+ "Contrast 3",
+ link="images/contrast/lenna_3.png"]
+
diff --git a/doc/images/contrast/lenna_0.1.png b/doc/images/contrast/lenna_0.1.png
new file mode 100644
index 0000000..9f20010
Binary files /dev/null and b/doc/images/contrast/lenna_0.1.png differ
diff --git a/doc/images/contrast/lenna_0.2.png b/doc/images/contrast/lenna_0.2.png
new file mode 100644
index 0000000..457aeed
Binary files /dev/null and b/doc/images/contrast/lenna_0.2.png differ
diff --git a/doc/images/contrast/lenna_0.5.png b/doc/images/contrast/lenna_0.5.png
new file mode 100644
index 0000000..1b9c60d
Binary files /dev/null and b/doc/images/contrast/lenna_0.5.png differ
diff --git a/doc/images/contrast/lenna_1.5.png b/doc/images/contrast/lenna_1.5.png
new file mode 100644
index 0000000..26c8300
Binary files /dev/null and b/doc/images/contrast/lenna_1.5.png differ
diff --git a/doc/images/contrast/lenna_2.png b/doc/images/contrast/lenna_2.png
new file mode 100644
index 0000000..3940472
Binary files /dev/null and b/doc/images/contrast/lenna_2.png differ
diff --git a/doc/images/contrast/lenna_3.png b/doc/images/contrast/lenna_3.png
new file mode 100644
index 0000000..56318c0
Binary files /dev/null and b/doc/images/contrast/lenna_3.png differ
diff --git a/doc/images/contrast/lenna_4.png b/doc/images/contrast/lenna_4.png
new file mode 100644
index 0000000..ca033c8
Binary files /dev/null and b/doc/images/contrast/lenna_4.png differ
diff --git a/doc/images/contrast/lenna_small_0.1.png b/doc/images/contrast/lenna_small_0.1.png
new file mode 100644
index 0000000..529a120
Binary files /dev/null and b/doc/images/contrast/lenna_small_0.1.png differ
diff --git a/doc/images/contrast/lenna_small_0.2.png b/doc/images/contrast/lenna_small_0.2.png
new file mode 100644
index 0000000..4ad19f3
Binary files /dev/null and b/doc/images/contrast/lenna_small_0.2.png differ
diff --git a/doc/images/contrast/lenna_small_0.5.png b/doc/images/contrast/lenna_small_0.5.png
new file mode 100644
index 0000000..f96b6d3
Binary files /dev/null and b/doc/images/contrast/lenna_small_0.5.png differ
diff --git a/doc/images/contrast/lenna_small_1.5.png b/doc/images/contrast/lenna_small_1.5.png
new file mode 100644
index 0000000..a4ed2c5
Binary files /dev/null and b/doc/images/contrast/lenna_small_1.5.png differ
diff --git a/doc/images/contrast/lenna_small_2.png b/doc/images/contrast/lenna_small_2.png
new file mode 100644
index 0000000..ef2a128
Binary files /dev/null and b/doc/images/contrast/lenna_small_2.png differ
diff --git a/doc/images/contrast/lenna_small_3.png b/doc/images/contrast/lenna_small_3.png
new file mode 100644
index 0000000..4fae79c
Binary files /dev/null and b/doc/images/contrast/lenna_small_3.png differ
diff --git a/doc/images/contrast/lenna_small_4.png b/doc/images/contrast/lenna_small_4.png
new file mode 100644
index 0000000..c8537e4
Binary files /dev/null and b/doc/images/contrast/lenna_small_4.png differ
diff --git a/doc/images/invert/images.txt b/doc/images/invert/images.txt
new file mode 100644
index 0000000..7a3e952
--- /dev/null
+++ b/doc/images/invert/images.txt
@@ -0,0 +1,8 @@
+.Original Image; Inverted
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/invert/lenna_small_.png[
+ "Inverted ",
+ link="images/invert/lenna_.png"]
+
diff --git a/doc/images/invert/lenna_.png b/doc/images/invert/lenna_.png
new file mode 100644
index 0000000..2909167
Binary files /dev/null and b/doc/images/invert/lenna_.png differ
diff --git a/doc/images/invert/lenna_small_.png b/doc/images/invert/lenna_small_.png
new file mode 100644
index 0000000..cd32e36
Binary files /dev/null and b/doc/images/invert/lenna_small_.png differ
diff --git a/doc/images/posterize/images.txt b/doc/images/posterize/images.txt
new file mode 100644
index 0000000..9a5ee63
--- /dev/null
+++ b/doc/images/posterize/images.txt
@@ -0,0 +1,20 @@
+.Original Image; Posterize s=2, s=3, s=4, s=5, s=6
+image:images/orig/lenna_small.png[
+ "Original Image",
+ link="images/orig/lenna.png"]
+image:images/posterize/lenna_small_2.png[
+ "Posterize 2",
+ link="images/posterize/lenna_2.png"]
+image:images/posterize/lenna_small_3.png[
+ "Posterize 3",
+ link="images/posterize/lenna_3.png"]
+image:images/posterize/lenna_small_4.png[
+ "Posterize 4",
+ link="images/posterize/lenna_4.png"]
+image:images/posterize/lenna_small_5.png[
+ "Posterize 5",
+ link="images/posterize/lenna_5.png"]
+image:images/posterize/lenna_small_6.png[
+ "Posterize 6",
+ link="images/posterize/lenna_6.png"]
+
diff --git a/doc/images/posterize/lenna_2.png b/doc/images/posterize/lenna_2.png
new file mode 100644
index 0000000..a719aa3
Binary files /dev/null and b/doc/images/posterize/lenna_2.png differ
diff --git a/doc/images/posterize/lenna_3.png b/doc/images/posterize/lenna_3.png
new file mode 100644
index 0000000..83315c2
Binary files /dev/null and b/doc/images/posterize/lenna_3.png differ
diff --git a/doc/images/posterize/lenna_4.png b/doc/images/posterize/lenna_4.png
new file mode 100644
index 0000000..352efe1
Binary files /dev/null and b/doc/images/posterize/lenna_4.png differ
diff --git a/doc/images/posterize/lenna_5.png b/doc/images/posterize/lenna_5.png
new file mode 100644
index 0000000..d395005
Binary files /dev/null and b/doc/images/posterize/lenna_5.png differ
diff --git a/doc/images/posterize/lenna_6.png b/doc/images/posterize/lenna_6.png
new file mode 100644
index 0000000..ea8295c
Binary files /dev/null and b/doc/images/posterize/lenna_6.png differ
diff --git a/doc/images/posterize/lenna_small_2.png b/doc/images/posterize/lenna_small_2.png
new file mode 100644
index 0000000..695fd16
Binary files /dev/null and b/doc/images/posterize/lenna_small_2.png differ
diff --git a/doc/images/posterize/lenna_small_3.png b/doc/images/posterize/lenna_small_3.png
new file mode 100644
index 0000000..c0b8252
Binary files /dev/null and b/doc/images/posterize/lenna_small_3.png differ
diff --git a/doc/images/posterize/lenna_small_4.png b/doc/images/posterize/lenna_small_4.png
new file mode 100644
index 0000000..f509351
Binary files /dev/null and b/doc/images/posterize/lenna_small_4.png differ
diff --git a/doc/images/posterize/lenna_small_5.png b/doc/images/posterize/lenna_small_5.png
new file mode 100644
index 0000000..ed1e80f
Binary files /dev/null and b/doc/images/posterize/lenna_small_5.png differ
diff --git a/doc/images/posterize/lenna_small_6.png b/doc/images/posterize/lenna_small_6.png
new file mode 100644
index 0000000..cb1c8cc
Binary files /dev/null and b/doc/images/posterize/lenna_small_6.png differ
diff --git a/doc/images/regen.py b/doc/images/regen.py
index 8a705f7..ace7e6a 100755
--- a/doc/images/regen.py
+++ b/doc/images/regen.py
@@ -61,6 +61,26 @@ class ImgGen:
def main():
imggen = ImgGen('images/orig/')
+ imggen.gen(filters.InvertAlloc, [],
+ [[]],
+ 'images/invert/', 'Inverted')
+
+ imggen.gen(filters.BrightnessAlloc, ['p'],
+ [[-.5], [-.2], [.2], [.5]],
+ 'images/brightness/', 'Brightness')
+
+ imggen.gen(filters.ContrastAlloc, ['p'],
+ [[.2], [.5], [1.5], [2], [3]],
+ 'images/contrast/', 'Contrast')
+
+ imggen.gen(filters.BrightnessContrastAlloc, ['b', 'c'],
+ [[-.2, .8], [-.5, 2], [.2, .8], [.2, 1.5]],
+ 'images/brightness_contrast/', 'BrightnessContrast')
+
+ imggen.gen(filters.PosterizeAlloc, ['s'],
+ [[2], [3], [4], [5], [6]],
+ 'images/posterize/', 'Posterize')
+
imggen.gen(filters.GaussianBlurAlloc, ['xsig', 'ysig'],
[[2, 2], [0, 4], [4, 0], [4, 4], [10, 10]],
'images/blur/', 'Gaussian Blur')
http://repo.or.cz/w/gfxprim.git/commit/6a0865b80f90e2397d90d13e836b0db3f8aa…
commit 6a0865b80f90e2397d90d13e836b0db3f8aaa372
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 8 22:45:49 2013 +0100
filters: Add two point filters.
Add combined Brightness Contrast filter and Posterize filter.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h
index e5c7e99..6ebf48c 100644
--- a/include/filters/GP_Point.h
+++ b/include/filters/GP_Point.h
@@ -50,9 +50,9 @@ static inline int GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
return GP_FilterBrightnessEx(&area, p, callback);
}
-static inline GP_Context *GP_FilterBrightnessAlloc(const GP_Context *src,
- float p,
- GP_ProgressCallback *callback)
+static inline GP_Context *
+GP_FilterBrightnessAlloc(const GP_Context *src, float p,
+ GP_ProgressCallback *callback)
{
GP_FILTER_AREA_DEFAULT(src, NULL);
@@ -91,6 +91,65 @@ static inline GP_Context *GP_FilterContrastAlloc(const GP_Context *src,
}
/*
+ * Brightness and Contrast combined.
+ */
+int GP_FilterBrightnessContrastEx(const GP_FilterArea *area, float b, float c,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterBrightnessContrastExAlloc(const GP_FilterArea *area,
+ float b, float c,
+ GP_ProgressCallback *callback);
+
+static inline int
+GP_FilterBrightnessContrast(const GP_Context *src, GP_Context *dst,
+ float b, float c, GP_ProgressCallback *callback)
+{
+ GP_FILTER_AREA_DEFAULT(src, dst);
+
+ return GP_FilterBrightnessContrastEx(&area, b, c, callback);
+}
+
+static inline GP_Context *
+GP_FilterBrightnessContrastAlloc(const GP_Context *src,
+ float b, float c,
+ GP_ProgressCallback *callback)
+{
+ GP_FILTER_AREA_DEFAULT(src, NULL);
+
+ return GP_FilterBrightnessContrastExAlloc(&area, b, c, callback);
+}
+
+/*
+ * Posterize
+ *
+ * Does quantization into steps regions.
+ */
+int GP_FilterPosterizeEx(const GP_FilterArea *area, unsigned int steps,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterPosterizeExAlloc(const GP_FilterArea *area,
+ unsigned int steps,
+ GP_ProgressCallback *callback);
+
+static inline int GP_FilterPosterize(const GP_Context *src, GP_Context *dst,
+ unsigned int steps,
+ GP_ProgressCallback *callback)
+{
+ GP_FILTER_AREA_DEFAULT(src, dst);
+
+ return GP_FilterPosterizeEx(&area, steps, callback);
+}
+
+static inline GP_Context *
+GP_FilterPosterizeAlloc(const GP_Context *src, unsigned int steps,
+ GP_ProgressCallback *callback)
+{
+ GP_FILTER_AREA_DEFAULT(src, NULL);
+
+ return GP_FilterPosterizeExAlloc(&area, steps, callback);
+}
+
+/*
* Inverts the pixel value, i.e. sets it to max - val.
*/
int GP_FilterInvertEx(const GP_FilterArea *area,
diff --git a/libs/filters/GP_BrightnessContrast.gen.c.t b/libs/filters/GP_BrightnessContrast.gen.c.t
new file mode 100644
index 0000000..fc620f6
--- /dev/null
+++ b/libs/filters/GP_BrightnessContrast.gen.c.t
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+%% extends "filter.point.c.t"
+
+%% block descr
+Brightness and Contrast Point filter
+%% endblock
+
+%% block body
+
+#include "core/GP_Clamp.h"
+
+%% macro filter_op_brightness_contrast(val, val_max)
+GP_CLAMP_GENERIC(c * {{ val }} + b * {{ val_max }} + 0.5, 0, {{ val_max }})
+%%- endmacro
+
+{{ filter_point('BrightnessContrast', filter_op_brightness_contrast, 'float b, float c', 'b, c') }}
+
+%% endblock body
diff --git a/libs/filters/GP_Posterize.gen.c.t b/libs/filters/GP_Posterize.gen.c.t
new file mode 100644
index 0000000..d87fa0c
--- /dev/null
+++ b/libs/filters/GP_Posterize.gen.c.t
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+%% extends "filter.point.c.t"
+
+%% block descr
+Posterize Point filter
+%% endblock
+
+%% block body
+
+%% macro filter_op_posterize(val, val_max)
+(({{ val }} + ({{ val_max }} / steps)/2) / ({{ val_max }} / steps)) * ({{ val_max }} / steps);
+%%- endmacro
+
+{{ filter_point('Posterize', filter_op_posterize, 'unsigned int steps', 'steps') }}
+
+%% endblock body
diff --git a/libs/filters/Makefile b/libs/filters/Makefile
index e39d66e..c929aa7 100644
--- a/libs/filters/Makefile
+++ b/libs/filters/Makefile
@@ -4,7 +4,8 @@ include $(TOPDIR)/pre.mk
STATS_FILTERS=GP_Histogram.gen.c
POINT_FILTERS=GP_GaussianNoise.gen.c GP_ApplyTables.gen.c GP_Invert.gen.c- GP_Brightness.gen.c GP_Contrast.gen.c
+ GP_Brightness.gen.c GP_Contrast.gen.c+ GP_BrightnessContrast.gen.c GP_Posterize.gen.c
ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c GP_Max.gen.c GP_Multiply.gen.c
diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py
index c5ef3ab..d8bdd97 100644
--- a/pylib/gfxprim/filters/__init__.py
+++ b/pylib/gfxprim/filters/__init__.py
@@ -23,6 +23,8 @@ def _init(module):
for name in ['Invert', 'InvertAlloc',
'Brightness', 'BrightnessAlloc',
'Contrast', 'ContrastAlloc',
+ 'BrightnessContrast', 'BrightnessContrastAlloc',
+ 'Posterize', 'PosterizeAlloc',
'Resize', 'ResizeAlloc',
'Rotate90', 'Rotate90Alloc',
'Rotate180', 'Rotate180Alloc',
diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i
index 59da75b..9bd6daf 100644
--- a/pylib/gfxprim/filters/filters.i
+++ b/pylib/gfxprim/filters/filters.i
@@ -31,6 +31,8 @@ ERROR_ON_NONZERO(GP_Filter ## funcname);
FILTER_FUNC(Invert);
FILTER_FUNC(Brightness);
FILTER_FUNC(Contrast);
+FILTER_FUNC(BrightnessContrast);
+FILTER_FUNC(Posterize);
%include "GP_Point.h"
/* Arithmetic filters */
http://repo.or.cz/w/gfxprim.git/commit/ddaf9058d046bbde16edfe2c4655a5690b04…
commit ddaf9058d046bbde16edfe2c4655a5690b043883
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 8 22:35:04 2013 +0100
filters: Clear free_table flag on GP_FilterTablesInit()
Fixes abort when GP_FilterTablesFree() tries to free() stack allocated
tables structure.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_ApplyTables.c b/libs/filters/GP_ApplyTables.c
index 7fcb591..bc03dda 100644
--- a/libs/filters/GP_ApplyTables.c
+++ b/libs/filters/GP_ApplyTables.c
@@ -30,6 +30,9 @@ static GP_Pixel *create_table(const GP_PixelTypeChannel *chan)
GP_Pixel *table = malloc(table_size * sizeof(GP_Pixel));
GP_Pixel i;
+ GP_DEBUG(2, "Table for channel '%s' size %zu (%p)",
+ chan->name, table_size, table);
+
if (!table) {
GP_DEBUG(1, "Malloc failed :(");
return NULL;
@@ -45,8 +48,14 @@ static void free_tables(GP_FilterTables *self)
{
unsigned int i;
- for (i = 0; i < GP_PIXELTYPE_MAX_CHANNELS; i++)
+ for (i = 0; i < GP_PIXELTYPE_MAX_CHANNELS; i++) {
+
+ if (!self->table[i])
+ break;
+
+ GP_DEBUG(2, "Freeing table (%p)", self->table[i]);
free(self->table[i]);
+ }
}
int GP_FilterTablesInit(GP_FilterTables *self, const GP_Context *ctx)
@@ -70,6 +79,8 @@ int GP_FilterTablesInit(GP_FilterTables *self, const GP_Context *ctx)
}
}
+ self->free_table = 0;
+
return 0;
}
@@ -84,13 +95,13 @@ GP_FilterTables *GP_FilterTablesAlloc(const GP_Context *ctx)
return NULL;
}
- tables->free_table = 1;
-
if (GP_FilterTablesInit(tables, ctx)) {
free(tables);
return NULL;
}
+ tables->free_table = 1;
+
return tables;
}
@@ -100,6 +111,8 @@ void GP_FilterTablesFree(GP_FilterTables *self)
free_tables(self);
- if (self->free_table)
+ if (self->free_table) {
+ GP_DEBUG(2, "Freeing table itself");
free(self);
+ }
}
-----------------------------------------------------------------------
Summary of changes:
build/syms/Filters_symbols.txt | 15 +-
doc/filters.txt | 202 ++++++--------------
doc/filters_python.txt | 207 ++++++++++++++++++++
doc/images/brightness/images.txt | 17 ++
doc/images/brightness/lenna_-0.2.png | Bin 0 -> 343625 bytes
doc/images/brightness/lenna_-0.5.png | Bin 0 -> 162417 bytes
doc/images/brightness/lenna_0.2.png | Bin 0 -> 392064 bytes
doc/images/brightness/lenna_0.5.png | Bin 0 -> 335541 bytes
doc/images/brightness/lenna_small_-0.2.png | Bin 0 -> 28475 bytes
doc/images/brightness/lenna_small_-0.5.png | Bin 0 -> 13804 bytes
doc/images/brightness/lenna_small_0.2.png | Bin 0 -> 31738 bytes
doc/images/brightness/lenna_small_0.5.png | Bin 0 -> 27244 bytes
doc/images/brightness_contrast/images.txt | 17 ++
doc/images/brightness_contrast/lenna_-0.2_0.8.png | Bin 0 -> 288118 bytes
doc/images/brightness_contrast/lenna_-0.5_2.png | Bin 0 -> 330382 bytes
doc/images/brightness_contrast/lenna_0.2_0.5.png | Bin 0 -> 313679 bytes
doc/images/brightness_contrast/lenna_0.2_0.8.png | Bin 0 -> 372199 bytes
doc/images/brightness_contrast/lenna_0.2_1.5.png | Bin 0 -> 388546 bytes
doc/images/brightness_contrast/lenna_0.4_0.5.png | Bin 0 -> 314067 bytes
.../brightness_contrast/lenna_small_-0.2_0.8.png | Bin 0 -> 24114 bytes
.../brightness_contrast/lenna_small_-0.5_2.png | Bin 0 -> 26923 bytes
.../brightness_contrast/lenna_small_0.2_0.5.png | Bin 0 -> 26101 bytes
.../brightness_contrast/lenna_small_0.2_0.8.png | Bin 0 -> 30145 bytes
.../brightness_contrast/lenna_small_0.2_1.5.png | Bin 0 -> 30713 bytes
.../brightness_contrast/lenna_small_0.4_0.5.png | Bin 0 -> 26099 bytes
doc/images/contrast/images.txt | 20 ++
doc/images/contrast/lenna_0.1.png | Bin 0 -> 161387 bytes
doc/images/contrast/lenna_0.2.png | Bin 0 -> 221759 bytes
doc/images/contrast/lenna_0.5.png | Bin 0 -> 313123 bytes
doc/images/contrast/lenna_1.5.png | Bin 0 -> 427752 bytes
doc/images/contrast/lenna_2.png | Bin 0 -> 361923 bytes
doc/images/contrast/lenna_3.png | Bin 0 -> 284365 bytes
doc/images/contrast/lenna_4.png | Bin 0 -> 222137 bytes
doc/images/contrast/lenna_small_0.1.png | Bin 0 -> 14173 bytes
doc/images/contrast/lenna_small_0.2.png | Bin 0 -> 18945 bytes
doc/images/contrast/lenna_small_0.5.png | Bin 0 -> 26109 bytes
doc/images/contrast/lenna_small_1.5.png | Bin 0 -> 33609 bytes
doc/images/contrast/lenna_small_2.png | Bin 0 -> 28741 bytes
doc/images/contrast/lenna_small_3.png | Bin 0 -> 22719 bytes
doc/images/contrast/lenna_small_4.png | Bin 0 -> 18249 bytes
doc/images/invert/images.txt | 8 +
doc/images/invert/lenna_.png | Bin 0 -> 394328 bytes
doc/images/invert/lenna_small_.png | Bin 0 -> 32009 bytes
doc/images/mirror_h/images.txt | 8 +
doc/images/mirror_h/lenna_.png | Bin 0 -> 389870 bytes
doc/images/mirror_h/lenna_small_.png | Bin 0 -> 32009 bytes
doc/images/mirror_v/images.txt | 8 +
doc/images/mirror_v/lenna_.png | Bin 0 -> 390372 bytes
doc/images/mirror_v/lenna_small_.png | Bin 0 -> 32040 bytes
doc/images/posterize/images.txt | 20 ++
doc/images/posterize/lenna_2.png | Bin 0 -> 42875 bytes
doc/images/posterize/lenna_3.png | Bin 0 -> 49708 bytes
doc/images/posterize/lenna_4.png | Bin 0 -> 62363 bytes
doc/images/posterize/lenna_5.png | Bin 0 -> 59237 bytes
doc/images/posterize/lenna_6.png | Bin 0 -> 68968 bytes
doc/images/posterize/lenna_small_2.png | Bin 0 -> 4858 bytes
doc/images/posterize/lenna_small_3.png | Bin 0 -> 5145 bytes
doc/images/posterize/lenna_small_4.png | Bin 0 -> 6113 bytes
doc/images/posterize/lenna_small_5.png | Bin 0 -> 5904 bytes
doc/images/posterize/lenna_small_6.png | Bin 0 -> 7078 bytes
doc/images/regen.py | 40 ++++
doc/images/rotate_180/images.txt | 8 +
doc/images/rotate_180/lenna_.png | Bin 0 -> 393966 bytes
doc/images/rotate_180/lenna_small_.png | Bin 0 -> 31993 bytes
doc/images/rotate_270/images.txt | 8 +
doc/images/rotate_270/lenna_.png | Bin 0 -> 383865 bytes
doc/images/rotate_270/lenna_small_.png | Bin 0 -> 31636 bytes
doc/images/rotate_90/images.txt | 8 +
doc/images/rotate_90/lenna_.png | Bin 0 -> 384169 bytes
doc/images/rotate_90/lenna_small_.png | Bin 0 -> 31661 bytes
include/filters/GP_Point.h | 65 ++++++-
include/filters/GP_Rotate.h | 37 ----
libs/filters/GP_ApplyTables.c | 21 ++-
libs/filters/GP_BrightnessContrast.gen.c.t | 39 ++++
libs/filters/GP_MirrorH.gen.c.t | 110 +++++++++++
libs/filters/GP_MirrorV.gen.c.t | 75 -------
libs/filters/GP_Noise.gen.c.t | 56 ------
libs/filters/GP_Point.gen.c.t | 57 ------
libs/filters/GP_Posterize.gen.c.t | 37 ++++
libs/filters/GP_Rotate.c | 149 +--------------
libs/filters/GP_Rotate.gen.c.t | 117 +++++++++++-
libs/filters/Makefile | 5 +-
pylib/gfxprim/filters/__init__.py | 2 +
pylib/gfxprim/filters/filters.i | 2 +
84 files changed, 820 insertions(+), 538 deletions(-)
create mode 100644 doc/images/brightness/images.txt
create mode 100644 doc/images/brightness/lenna_-0.2.png
create mode 100644 doc/images/brightness/lenna_-0.5.png
create mode 100644 doc/images/brightness/lenna_0.2.png
create mode 100644 doc/images/brightness/lenna_0.5.png
create mode 100644 doc/images/brightness/lenna_small_-0.2.png
create mode 100644 doc/images/brightness/lenna_small_-0.5.png
create mode 100644 doc/images/brightness/lenna_small_0.2.png
create mode 100644 doc/images/brightness/lenna_small_0.5.png
create mode 100644 doc/images/brightness_contrast/images.txt
create mode 100644 doc/images/brightness_contrast/lenna_-0.2_0.8.png
create mode 100644 doc/images/brightness_contrast/lenna_-0.5_2.png
create mode 100644 doc/images/brightness_contrast/lenna_0.2_0.5.png
create mode 100644 doc/images/brightness_contrast/lenna_0.2_0.8.png
create mode 100644 doc/images/brightness_contrast/lenna_0.2_1.5.png
create mode 100644 doc/images/brightness_contrast/lenna_0.4_0.5.png
create mode 100644 doc/images/brightness_contrast/lenna_small_-0.2_0.8.png
create mode 100644 doc/images/brightness_contrast/lenna_small_-0.5_2.png
create mode 100644 doc/images/brightness_contrast/lenna_small_0.2_0.5.png
create mode 100644 doc/images/brightness_contrast/lenna_small_0.2_0.8.png
create mode 100644 doc/images/brightness_contrast/lenna_small_0.2_1.5.png
create mode 100644 doc/images/brightness_contrast/lenna_small_0.4_0.5.png
create mode 100644 doc/images/contrast/images.txt
create mode 100644 doc/images/contrast/lenna_0.1.png
create mode 100644 doc/images/contrast/lenna_0.2.png
create mode 100644 doc/images/contrast/lenna_0.5.png
create mode 100644 doc/images/contrast/lenna_1.5.png
create mode 100644 doc/images/contrast/lenna_2.png
create mode 100644 doc/images/contrast/lenna_3.png
create mode 100644 doc/images/contrast/lenna_4.png
create mode 100644 doc/images/contrast/lenna_small_0.1.png
create mode 100644 doc/images/contrast/lenna_small_0.2.png
create mode 100644 doc/images/contrast/lenna_small_0.5.png
create mode 100644 doc/images/contrast/lenna_small_1.5.png
create mode 100644 doc/images/contrast/lenna_small_2.png
create mode 100644 doc/images/contrast/lenna_small_3.png
create mode 100644 doc/images/contrast/lenna_small_4.png
create mode 100644 doc/images/invert/images.txt
create mode 100644 doc/images/invert/lenna_.png
create mode 100644 doc/images/invert/lenna_small_.png
create mode 100644 doc/images/mirror_h/images.txt
create mode 100644 doc/images/mirror_h/lenna_.png
create mode 100644 doc/images/mirror_h/lenna_small_.png
create mode 100644 doc/images/mirror_v/images.txt
create mode 100644 doc/images/mirror_v/lenna_.png
create mode 100644 doc/images/mirror_v/lenna_small_.png
create mode 100644 doc/images/posterize/images.txt
create mode 100644 doc/images/posterize/lenna_2.png
create mode 100644 doc/images/posterize/lenna_3.png
create mode 100644 doc/images/posterize/lenna_4.png
create mode 100644 doc/images/posterize/lenna_5.png
create mode 100644 doc/images/posterize/lenna_6.png
create mode 100644 doc/images/posterize/lenna_small_2.png
create mode 100644 doc/images/posterize/lenna_small_3.png
create mode 100644 doc/images/posterize/lenna_small_4.png
create mode 100644 doc/images/posterize/lenna_small_5.png
create mode 100644 doc/images/posterize/lenna_small_6.png
create mode 100644 doc/images/rotate_180/images.txt
create mode 100644 doc/images/rotate_180/lenna_.png
create mode 100644 doc/images/rotate_180/lenna_small_.png
create mode 100644 doc/images/rotate_270/images.txt
create mode 100644 doc/images/rotate_270/lenna_.png
create mode 100644 doc/images/rotate_270/lenna_small_.png
create mode 100644 doc/images/rotate_90/images.txt
create mode 100644 doc/images/rotate_90/lenna_.png
create mode 100644 doc/images/rotate_90/lenna_small_.png
create mode 100644 libs/filters/GP_BrightnessContrast.gen.c.t
create mode 100644 libs/filters/GP_MirrorH.gen.c.t
delete mode 100644 libs/filters/GP_MirrorV.gen.c.t
delete mode 100644 libs/filters/GP_Noise.gen.c.t
delete mode 100644 libs/filters/GP_Point.gen.c.t
create mode 100644 libs/filters/GP_Posterize.gen.c.t
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.")
1
0
08 Nov '13
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 ed36869f7b525df87a66c7403485f8ddd8491457 (commit)
via 9c0f4f912f97ae75a2de325e2b14a3cdde3d888d (commit)
via 31309d970cc83b67dd89a2afbd985b2980624200 (commit)
from 7e200feb57b68400cca6b27a5fb6d87c9692021e (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/ed36869f7b525df87a66c7403485f8ddd849…
commit ed36869f7b525df87a66c7403485f8ddd8491457
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 8 13:23:12 2013 +0100
filters: Ditherings: Set errno and fix abort.
* Set errno to EINVAL on unsupported dst pixel type
* Return 1 and set errno to EINVAL on unsupported src pixel type
(instead of aborting in GP_Convert.gen.c on unsupproted conversion)
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_FloydSteinberg.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t
index f38cb8c..f63c8cc 100644
--- a/libs/filters/GP_FloydSteinberg.gen.c.t
+++ b/libs/filters/GP_FloydSteinberg.gen.c.t
@@ -130,6 +130,13 @@ static int floyd_steinberg_to_{{ pt.name }}_Raw(const GP_Context *src,
static int floyd_steinberg(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
+ if (GP_PixelHasFlags(src->pixel_type, GP_PIXEL_IS_PALETTE)) {
+ GP_DEBUG(1, "Unsupported source pixel type %s",
+ GP_PixelTypeName(src->pixel_type));
+ errno = EINVAL;
+ return 1;
+ }
+
switch (dst->pixel_type) {
%% for pt in pixeltypes
%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
@@ -138,6 +145,7 @@ static int floyd_steinberg(const GP_Context *src, GP_Context *dst,
%% endif
%% endfor
default:
+ errno = EINVAL;
return 1;
}
}
diff --git a/libs/filters/GP_HilbertPeano.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t
index 46a3eb9..1c11973 100644
--- a/libs/filters/GP_HilbertPeano.gen.c.t
+++ b/libs/filters/GP_HilbertPeano.gen.c.t
@@ -54,7 +54,7 @@ static unsigned int count_bits(unsigned int n)
%% for pt in pixeltypes
%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
/*
- * Hilbert Peano RGB888 to {{ pt.name }}
+ * Hilbert Peano to {{ pt.name }}
*/
static int hilbert_peano_to_{{ pt.name }}_Raw(const GP_Context *src,
GP_Context *dst,
@@ -140,6 +140,13 @@ static int hilbert_peano_to_{{ pt.name }}_Raw(const GP_Context *src,
static int hilbert_peano(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback)
{
+ if (GP_PixelHasFlags(src->pixel_type, GP_PIXEL_IS_PALETTE)) {
+ GP_DEBUG(1, "Unsupported source pixel type %s",
+ GP_PixelTypeName(src->pixel_type));
+ errno = EINVAL;
+ return 1;
+ }
+
switch (dst->pixel_type) {
%% for pt in pixeltypes
%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
@@ -148,6 +155,7 @@ static int hilbert_peano(const GP_Context *src, GP_Context *dst,
%% endif
%% endfor
default:
+ errno = EINVAL;
return 1;
}
}
http://repo.or.cz/w/gfxprim.git/commit/9c0f4f912f97ae75a2de325e2b14a3cdde3d…
commit 9c0f4f912f97ae75a2de325e2b14a3cdde3d888d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 8 13:08:12 2013 +0100
tests: Filters: Add point filters.
Add point filters to API Coverage test and FiltersCompare test.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/filters/APICoverage.gen.c.t b/tests/filters/APICoverage.gen.c.t
index b4c8281..98a9286 100644
--- a/tests/filters/APICoverage.gen.c.t
+++ b/tests/filters/APICoverage.gen.c.t
@@ -42,7 +42,22 @@ We check for correct return value correcness though.
#include "tst_test.h"
-%% set API_List = [['MirrorH', '', 'GP_Context:in', 'GP_Context:out',
+%% set API_List = [['Brightness', '', 'GP_Context:in', 'GP_Context:out',
+ 'float:p', 'GP_ProgressCallback'],
+ ['BrightnessAlloc', '', 'GP_Context:in',
+ 'float:p', 'GP_ProgressCallback'],
+
+ ['Contrast', '', 'GP_Context:in', 'GP_Context:out',
+ 'float:p', 'GP_ProgressCallback'],
+ ['ContrastAlloc', '', 'GP_Context:in',
+ 'float:p', 'GP_ProgressCallback'],
+
+ ['Invert', '', 'GP_Context:in', 'GP_Context:out',
+ 'GP_ProgressCallback'],
+ ['InvertAlloc', '', 'GP_Context:in',
+ 'GP_ProgressCallback'],
+
+ ['MirrorH', '', 'GP_Context:in', 'GP_Context:out',
'GP_ProgressCallback'],
['MirrorHAlloc', '', 'GP_Context:in', 'GP_ProgressCallback'],
diff --git a/tests/filters/FiltersCompare.gen.c.t b/tests/filters/FiltersCompare.gen.c.t
index d22890b..9acb432 100644
--- a/tests/filters/FiltersCompare.gen.c.t
+++ b/tests/filters/FiltersCompare.gen.c.t
@@ -47,7 +47,20 @@ The format is [[name1, [fn1, [params]], [fn2, [params]], ...],
All results from filters listed under one name are compared.
*/
-%% set compare_list = [['MirrorH',
+%% set compare_list = [['Brightness',
+ ['Brightness', ['dst', 'dst', '0.1', 'NULL']],
+ ['BrightnessAlloc', ['src', '0.1', 'NULL']],
+ ],
+ ['Contrast',
+ ['Contrast', ['dst', 'dst', '1.2', 'NULL']],
+ ['ContrastAlloc', ['src', '1.2', 'NULL']],
+ ],
+ ['Invert',
+ ['Invert', ['dst', 'dst', 'NULL']],
+ ['InvertAlloc', ['src', 'NULL']],
+ ],
+
+ ['MirrorH',
['MirrorH', ['dst', 'dst', 'NULL']],
['MirrorHAlloc', ['src', 'NULL']],
['Symmetry', ['dst', 'dst', 'GP_MIRROR_H', 'NULL']],
http://repo.or.cz/w/gfxprim.git/commit/31309d970cc83b67dd89a2afbd985b298062…
commit 31309d970cc83b67dd89a2afbd985b2980624200
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Nov 8 12:53:40 2013 +0100
loaders: PNM: Optimize Save()
This adds custom function to write ASCII byte into a file which is more
than five times faster than printf("%u", byte).
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index 813de81..7e28f1b 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -291,6 +291,22 @@ static int get_ascii_int(FILE *f, int *val)
}
/*
+ * Five times faster than printf("%u", byte)
+ */
+static inline int write_ascii_byte(FILE *f, uint8_t byte)
+{
+ if (byte >= 100)
+ fputc_unlocked('0' + byte/100, f);
+
+ if (byte >= 10)
+ fputc_unlocked('0' + (byte%100)/10, f);
+
+ fputc_unlocked('0' + (byte%10), f);
+
+ return fputc_unlocked(' ', f) == EOF;
+}
+
+/*
* The PBM ASCII has the values inverted
*/
static int load_ascii_g1_inv(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb)
@@ -564,7 +580,7 @@ static int save_ascii(FILE *f, const GP_Context *ctx,
if (inv)
val = !val;
- if (fprintf(f, "%i ", val) < 0) {
+ if (write_ascii_byte(f, val)) {
err = errno;
GP_DEBUG(1, "Failed to write data");
return err;
@@ -961,7 +977,7 @@ static int save_ascii_rgb888(FILE *f, const GP_Context *ctx,
GP_LineConvert Convert, GP_ProgressCallback *cb)
{
uint32_t x, y;
- int ret;
+ int ret = 0;
uint8_t buf[3 * ctx->w], *addr;
for (y = 0; y < ctx->h; y++) {
@@ -976,9 +992,11 @@ static int save_ascii_rgb888(FILE *f, const GP_Context *ctx,
for (x = 0; x < ctx->w; x++) {
addr+=3;
- ret = fprintf(f, "%u %u %u ", addr[2], addr[1], addr[0]);
+ ret |= write_ascii_byte(f, addr[2]);
+ ret |= write_ascii_byte(f, addr[1]);
+ ret |= write_ascii_byte(f, addr[0]);
- if (ret < 0)
+ if (ret)
return errno;
}
-----------------------------------------------------------------------
Summary of changes:
libs/filters/GP_FloydSteinberg.gen.c.t | 8 ++++++++
libs/filters/GP_HilbertPeano.gen.c.t | 10 +++++++++-
libs/loaders/GP_PNM.c | 26 ++++++++++++++++++++++----
tests/filters/APICoverage.gen.c.t | 17 ++++++++++++++++-
tests/filters/FiltersCompare.gen.c.t | 15 ++++++++++++++-
5 files changed, 69 insertions(+), 7 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.")
1
0
07 Nov '13
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 7e200feb57b68400cca6b27a5fb6d87c9692021e (commit)
via 2dcfaebb1f2f7560d3b36df02066907a1fca84da (commit)
via c83a0d2c773e72545e78f465ec4c2dea92272b55 (commit)
via d93da078d5d3db1e457a0225a26da0cead0085cb (commit)
via 147b4068a0ef11c88d116442680ad46894a7b12a (commit)
from 7b640614144c242d672abe372961ef1d2e64c1fd (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/7e200feb57b68400cca6b27a5fb6d87c9692…
commit 7e200feb57b68400cca6b27a5fb6d87c9692021e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Nov 7 00:51:50 2013 +0100
loaders: PNM: Fix aligment issues in save_ascii_rgb888
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index 09018fe..813de81 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -974,12 +974,9 @@ static int save_ascii_rgb888(FILE *f, const GP_Context *ctx,
}
for (x = 0; x < ctx->w; x++) {
- GP_Pixel pix = *(addr+=3);
+ addr+=3;
- ret = fprintf(f, "%u %u %u ",
- GP_Pixel_GET_R_RGB888(pix),
- GP_Pixel_GET_G_RGB888(pix),
- GP_Pixel_GET_B_RGB888(pix));
+ ret = fprintf(f, "%u %u %u ", addr[2], addr[1], addr[0]);
if (ret < 0)
return errno;
http://repo.or.cz/w/gfxprim.git/commit/2dcfaebb1f2f7560d3b36df02066907a1fca…
commit 2dcfaebb1f2f7560d3b36df02066907a1fca84da
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Nov 7 00:40:18 2013 +0100
filters: Reimplement point filters.
Point filters are now implemented using ApplyTable generic filter.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Filters_symbols.txt b/build/syms/Filters_symbols.txt
index 970c881..1e8b74b 100644
--- a/build/syms/Filters_symbols.txt
+++ b/build/syms/Filters_symbols.txt
@@ -1,15 +1,23 @@
GP_CubicTable
+GP_FilterTablesApply
+GP_FilterTablesAlloc
+GP_FilterTablesInit
+GP_FilterTablesFree
+
+GP_FilterInvertEx
+GP_FilterInvertExAlloc
+
+GP_FilterBrightnessEx
+GP_FilterBrightnessExAlloc
+
+GP_FilterContrastEx
+GP_FilterContrastExAlloc
+
GP_FilterAddition
GP_FilterAdditionAlloc
GP_FilterAddition_Raw
-GP_FilterBrightness
-GP_FilterBrightness_Raw
-
-GP_FilterContrast
-GP_FilterContrast_Raw
-
GP_FilterConvolutionEx
GP_FilterConvolutionExAlloc
GP_FilterConvolutionMP_Raw
@@ -46,9 +54,6 @@ GP_FilterHistogram
GP_FilterHistogramAlloc
GP_FilterHistogram_Raw
-GP_FilterInvert
-GP_FilterInvert_Raw
-
GP_FilterKernelPrint_Raw
GP_FilterLaplace
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c
index 7bc3071..8c798d4 100644
--- a/demos/grinder/grinder.c
+++ b/demos/grinder/grinder.c
@@ -273,41 +273,18 @@ static int mirror(GP_Context **c, const char *params)
/* brightness filter */
static struct param bright_params[] = {
- {"inc", PARAM_INT, "brightness increment", NULL, NULL},
- {"chann", PARAM_STR, "Channel name {R, G, B, A, V, ...}", NULL, NULL},
+ {"inc", PARAM_FLOAT, "brightness increment", NULL, NULL},
{NULL, 0, NULL, NULL, NULL}
};
static int bright(GP_Context **c, const char *params)
{
- int bright = 0;
- char *chann = NULL;
+ float bright = 0;
- if (param_parse(params, bright_params, "bright", param_err, &bright, &chann))
+ if (param_parse(params, bright_params, "bright", param_err, &bright))
return EINVAL;
- if (bright == 0) {
- print_error("bright: bright parameter is zero or missing");
- return EINVAL;
- }
-
- GP_FILTER_PARAMS((*c)->pixel_type, filter_params);
-
- if (chann == NULL) {
- GP_FilterParamSetIntAll(filter_params, bright);
- } else {
- GP_FilterParam *param = GP_FilterParamChannel(filter_params, chann);
-
- if (param == NULL) {
- print_error("bright: Invalid channel name");
- return EINVAL;
- }
-
- GP_FilterParamSetIntAll(filter_params, 0);
- param->val.i = bright;
- }
-
- GP_FilterBrightness(*c, *c, filter_params, progress_callback);
+ GP_FilterBrightness(*c, *c, bright, progress_callback);
return 0;
}
@@ -316,16 +293,14 @@ static int bright(GP_Context **c, const char *params)
static struct param contrast_params[] = {
{"mul", PARAM_FLOAT, "contrast (1.5 = +50%, 0.5 = -50%)", NULL, NULL},
- {"chann", PARAM_STR, "Channel name {R, G, B, A, V, ...}", NULL, NULL},
{NULL, 0, NULL, NULL, NULL}
};
static int contrast(GP_Context **c, const char *params)
{
float mul = 0;
- char *chann = NULL;
- if (param_parse(params, contrast_params, "contrast", param_err, &mul, &chann))
+ if (param_parse(params, contrast_params, "contrast", param_err, &mul))
return EINVAL;
if (mul <= 0) {
@@ -333,45 +308,7 @@ static int contrast(GP_Context **c, const char *params)
return EINVAL;
}
- GP_FILTER_PARAMS((*c)->pixel_type, filter_params);
-
- if (chann == NULL) {
- GP_FilterParamSetFloatAll(filter_params, mul);
- } else {
- GP_FilterParam *param = GP_FilterParamChannel(filter_params, chann);
-
- if (param == NULL) {
- print_error("contrast: Invalid channel name");
- return EINVAL;
- }
-
- GP_FilterParamSetFloatAll(filter_params, 1);
- param->val.f = mul;
- }
-
- GP_FilterContrast(*c, *c, filter_params, progress_callback);
-
- return 0;
-}
-
-/* noise */
-static struct param noise_params[] = {
- {"ratio", PARAM_FLOAT, "noise", NULL, NULL},
- {NULL, 0, NULL, NULL, NULL}
-};
-
-static int noise(GP_Context **c, const char *params)
-{
- float rat;
-
- if (param_parse(params, noise_params, "noise", param_err, &rat))
- return EINVAL;
-
- GP_FILTER_PARAMS((*c)->pixel_type, filter_params);
-
- GP_FilterParamSetFloatAll(filter_params, rat);
-
- GP_FilterNoise(*c, *c, filter_params, progress_callback);
+ GP_FilterContrast(*c, *c, mul, progress_callback);
return 0;
}
@@ -525,70 +462,6 @@ static int save_png(GP_Context **c, const char *params)
return 0;
}
-/* noise filter */
-
-static struct param add_noise_params[] = {
- {"percents", PARAM_FLOAT, "Percents of noise to add", NULL, NULL},
- {"chann", PARAM_STR, "Channel name {R, G, B, A, V, ...}", NULL, NULL},
- {NULL, 0, NULL, NULL, NULL}
-};
-
-static uint32_t add_noise_op(uint32_t val, uint8_t bits, GP_FilterParam *param)
-{
- float perc;
- int max = (1<<bits) - 1;
- int ret;
-
- perc = param->val.f;
-
- ret = val * (1 - perc) + (random() % max) * perc;
-
- if (ret < 0)
- ret = 0;
-
- if (ret > max)
- ret = max;
-
- return ret;
-}
-
-static uint32_t no_op(uint32_t val)
-{
- return val;
-}
-
-static int add_noise(GP_Context **c, const char *params)
-{
- float percents = 0;
- char *chann = NULL;
-
- if (param_parse(params, add_noise_params, "add_noise", param_err, &percents, &chann))
- return EINVAL;
-
- GP_FILTER_PARAMS((*c)->pixel_type, priv);
- GP_FilterParamSetFloatAll(priv, percents/100);
- GP_FILTER_PARAMS((*c)->pixel_type, op_callbacks);
-
- if (chann == NULL) {
- GP_FilterParamSetPtrAll(op_callbacks, add_noise_op);
- } else {
- GP_FilterParam *param = GP_FilterParamChannel(op_callbacks, chann);
-
- if (param == NULL) {
- print_error("add_noise: Invalid channel name");
- return EINVAL;
- }
-
-
- GP_FilterParamSetPtrAll(op_callbacks, no_op);
- param->val.ptr = add_noise_op;
- }
-
- GP_FilterPoint(*c, *c, op_callbacks, priv, progress_callback);
-
- return 0;
-}
-
/* median filter */
static struct param median_params[] = {
@@ -816,8 +689,6 @@ static struct filter filter_table[] = {
{"bright", "alter image brightness", bright_params, bright},
{"contrast", "alter image contrast", contrast_params, contrast},
{"invert", "inverts image", invert_params, invert},
- {"add_noise", "adds noise", add_noise_params, add_noise},
- {"noise", "adds noise", noise_params, noise},
{"blur", "gaussian blur", blur_params, blur},
{"dither", "dithers bitmap", dither_params, dither},
{"arithmetic", "arithmetic operation", arithmetic_params, arithmetic},
diff --git a/demos/py_simple/invert.py b/demos/py_simple/invert.py
new file mode 100755
index 0000000..84a5b6f
--- /dev/null
+++ b/demos/py_simple/invert.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+import sys
+
+import gfxprim.core as core
+import gfxprim.loaders as loaders
+import gfxprim.filters as filters
+
+def main():
+ if len(sys.argv) != 2:
+ print("usage: invert.py image")
+ sys.exit(1)
+
+ # Load Image
+ img = loaders.Load(sys.argv[1])
+ # Invert image in-place
+ img.filters.Invert(img);
+ # Save result into grayscale png
+ img.loaders.SavePNG("out.png")
+
+if __name__ == '__main__':
+ main()
diff --git a/libs/filters/GP_Contrast.gen.c.t b/include/filters/GP_ApplyTables.h
similarity index 61%
copy from libs/filters/GP_Contrast.gen.c.t
copy to include/filters/GP_ApplyTables.h
index c8dae6f..d2a6948 100644
--- a/libs/filters/GP_Contrast.gen.c.t
+++ b/include/filters/GP_ApplyTables.h
@@ -16,39 +16,50 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-%% extends "filter.point.c.t"
+/*
+
+ Applies per-channel tables on a context pixels. Used for fast point filters
+ implementation.
-%% block descr
-Contrast filters -- Multiply color channel(s) by a fixed float value.
-%% endblock
+ */
-%% block body
+#ifndef FILTERS_GP_APPLY_TABLES_H
+#define FILTERS_GP_APPLY_TABLES_H
-{{ filter_point_include() }}
+#include "GP_Filter.h"
+
+/*
+ * Per-channel lookup tables.
+ */
+typedef struct GP_FilterTables {
+ GP_Pixel *table[GP_PIXELTYPE_MAX_CHANNELS];
+ int free_table:1;
+} GP_FilterTables;
-%% macro filter_op(chan_name, chan_size)
-{{ chan_name }} = {{ chan_name }} * {{ chan_name }}_mul + 0.5;
-{{ filter_clamp_val(chan_name, chan_size) }}
-%% endmacro
+/*
+ * Generic point filter, applies corresponding table on bitmap.
+ */
+int GP_FilterTablesApply(const GP_FilterArea *const area,
+ const GP_FilterTables *const tables,
+ GP_ProgressCallback *callback);
/*
- * Generated contrast filters for pixels with several channels.
+ * Aloocates and initializes tables.
*/
-%% call(pt) filter_point_per_channel('Contrast', 'GP_FilterParam muls[]', filter_op)
-{{ filter_params(pt, 'muls', 'float ', '_mul', 'f') }}
-%% endcall
+int GP_FilterTablesInit(GP_FilterTables *self, const GP_Context *ctx);
/*
- * Generated constrast filters for pixels with one channel.
+ * Allocates and initializes table structure and tables.
*/
-%% call(ps) filter_point_per_bpp('Contrast', 'GP_FilterParam muls[]', filter_op)
-{{ filter_param(ps, 'muls', 'float ', '_mul', 'f') }}
-%% endcall
+GP_FilterTables *GP_FilterTablesAlloc(const GP_Context *ctx);
-{{ filter_functions('Contrast', 'GP_FilterParam muls[]', 'muls') }}
+/*
+ * Frees point filter tables.
+ */
+void GP_FilterTablesFree(GP_FilterTables *self);
-%% endblock body
+#endif /* FILTERS_GP_APPLY_TABLES_H */
diff --git a/include/filters/GP_Filter.h b/include/filters/GP_Filter.h
index af02bd0..69254a0 100644
--- a/include/filters/GP_Filter.h
+++ b/include/filters/GP_Filter.h
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -34,4 +34,29 @@
#include "GP_FilterParam.h"
+/*
+ * Describes filter source, destination and coordinates.
+ *
+ * For Alloc filter variants dst, dst_x and dst_y is ignored.
+ */
+typedef struct GP_FilterArea {
+ const GP_Context *src;
+ GP_Coord src_x, src_y;
+ GP_Size src_w, src_h;
+
+ GP_Context *dst;
+ GP_Coord dst_x, dst_y;
+
+ void *priv;
+} GP_FilterArea;
+
+#define GP_FILTER_AREA_DEFAULT(srcc, dstc) + GP_FilterArea area = { + .src = srcc, + .src_x = 0, .src_y = 0, + .src_w = srcc->w, .src_h = srcc->h, + .dst = dstc, + .dst_x = 0, .dst_y = 0, + };
+
#endif /* FILTERS_GP_FILTER_H */
diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h
index 42248a9..e5c7e99 100644
--- a/include/filters/GP_Point.h
+++ b/include/filters/GP_Point.h
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -34,15 +34,30 @@
/*
* Brightness filter.
*
- * Increments each pixel channel by a given value.
+ * Increments each pixel channel by a p * channel_max value.
*/
-int GP_FilterBrightness_Raw(const GP_Context *src, GP_Context *dst,
- GP_FilterParam params[],
- GP_ProgressCallback *callback);
+int GP_FilterBrightnessEx(const GP_FilterArea *area, float p,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterBrightnessExAlloc(const GP_FilterArea *area, float p,
+ GP_ProgressCallback *callback);
+
+static inline int GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
+ float p, GP_ProgressCallback *callback)
+{
+ GP_FILTER_AREA_DEFAULT(src, dst);
-GP_Context *GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
- GP_FilterParam params[],
- GP_ProgressCallback *callback);
+ return GP_FilterBrightnessEx(&area, p, callback);
+}
+
+static inline GP_Context *GP_FilterBrightnessAlloc(const GP_Context *src,
+ float p,
+ GP_ProgressCallback *callback)
+{
+ GP_FILTER_AREA_DEFAULT(src, NULL);
+
+ return GP_FilterBrightnessExAlloc(&area, p, callback);
+}
/*
* Contrast filter.
@@ -52,42 +67,52 @@ GP_Context *GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
* The parameters should have the same pixel channels as
* source pixel type and are expected to be float numbers.
*/
-int GP_FilterContrast_Raw(const GP_Context *src, GP_Context *dst,
- GP_FilterParam params[],
- GP_ProgressCallback *callback);
+int GP_FilterContrastEx(const GP_FilterArea *area, float p,
+ GP_ProgressCallback *callback);
-GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst,
- GP_FilterParam params[],
- GP_ProgressCallback *callback);
+GP_Context *GP_FilterContrastExAlloc(const GP_FilterArea *area, float p,
+ GP_ProgressCallback *callback);
-/*
- * Invert filter.
- *
- * Inverts each pixel channel (eg. val = max - val)
- */
-int GP_FilterInvert_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
+static inline int GP_FilterContrast(const GP_Context *src, GP_Context *dst,
+ float p, GP_ProgressCallback *callback)
+{
+ GP_FILTER_AREA_DEFAULT(src, dst);
-GP_Context *GP_FilterInvert(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
+ return GP_FilterContrastEx(&area, p, callback);
+}
-/*
- * Noise filter.
- */
-GP_Context *GP_FilterNoise(const GP_Context *src, GP_Context *dst,
- GP_FilterParam ratio[], GP_ProgressCallback *callback);
+static inline GP_Context *GP_FilterContrastAlloc(const GP_Context *src,
+ float p,
+ GP_ProgressCallback *callback)
+{
+ GP_FILTER_AREA_DEFAULT(src, NULL);
+
+ return GP_FilterContrastExAlloc(&area, p, callback);
+}
/*
- * Generic slow point filter.
- *
- * The filter_callback[] is expected to be filled with pointers
- * to functions of type uint32_t (*func)(uint32_t chan_val, uint8_t chan_size, GP_FilterParam *priv)
- *
- * The priv[] is free for your use and corresponding
+ * Inverts the pixel value, i.e. sets it to max - val.
*/
-GP_Context *GP_FilterPoint(const GP_Context *src, GP_Context *dst,
- GP_FilterParam filter_callback[],
- GP_FilterParam priv[],
- GP_ProgressCallback *callback);
+int GP_FilterInvertEx(const GP_FilterArea *area,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterInvertExAlloc(const GP_FilterArea *area,
+ GP_ProgressCallback *callback);
+
+static inline int GP_FilterInvert(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ GP_FILTER_AREA_DEFAULT(src, dst);
+
+ return GP_FilterInvertEx(&area, callback);
+}
+
+static inline GP_Context *GP_FilterInvertAlloc(const GP_Context *src,
+ GP_ProgressCallback *callback)
+{
+ GP_FILTER_AREA_DEFAULT(src, NULL);
+
+ return GP_FilterInvertExAlloc(&area, callback);
+}
#endif /* FILTERS_GP_POINT_H */
diff --git a/libs/filters/GP_ApplyTables.c b/libs/filters/GP_ApplyTables.c
new file mode 100644
index 0000000..7fcb591
--- /dev/null
+++ b/libs/filters/GP_ApplyTables.c
@@ -0,0 +1,105 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "core/GP_Debug.h"
+
+#include "filters/GP_ApplyTables.h"
+
+static GP_Pixel *create_table(const GP_PixelTypeChannel *chan)
+{
+ size_t table_size = (1 << chan->size);
+ GP_Pixel *table = malloc(table_size * sizeof(GP_Pixel));
+ GP_Pixel i;
+
+ if (!table) {
+ GP_DEBUG(1, "Malloc failed :(");
+ return NULL;
+ }
+
+ for (i = 0; i < table_size; i++)
+ table[i] = i;
+
+ return table;
+}
+
+static void free_tables(GP_FilterTables *self)
+{
+ unsigned int i;
+
+ for (i = 0; i < GP_PIXELTYPE_MAX_CHANNELS; i++)
+ free(self->table[i]);
+}
+
+int GP_FilterTablesInit(GP_FilterTables *self, const GP_Context *ctx)
+{
+ unsigned int i;
+ const GP_PixelTypeDescription *desc;
+
+ GP_DEBUG(2, "Allocating tables for pixel %s",
+ GP_PixelTypeName(ctx->pixel_type));
+
+ for (i = 0; i < GP_PIXELTYPE_MAX_CHANNELS; i++)
+ self->table[i] = NULL;
+
+ desc = GP_PixelTypeDesc(ctx->pixel_type);
+
+ for (i = 0; i < desc->numchannels; i++) {
+ self->table[i] = create_table(&desc->channels[i]);
+ if (!self->table[i]) {
+ free_tables(self);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+GP_FilterTables *GP_FilterTablesAlloc(const GP_Context *ctx)
+{
+ GP_FilterTables *tables = malloc(sizeof(GP_FilterTables));
+
+ GP_DEBUG(1, "Allocating point filter (%p)", tables);
+
+ if (!tables) {
+ GP_DEBUG(1, "Malloc failed :(");
+ return NULL;
+ }
+
+ tables->free_table = 1;
+
+ if (GP_FilterTablesInit(tables, ctx)) {
+ free(tables);
+ return NULL;
+ }
+
+ return tables;
+}
+
+void GP_FilterTablesFree(GP_FilterTables *self)
+{
+ GP_DEBUG(1, "Freeing point filter and tables (%p)", self);
+
+ free_tables(self);
+
+ if (self->free_table)
+ free(self);
+}
diff --git a/libs/filters/GP_ApplyTables.gen.c.t b/libs/filters/GP_ApplyTables.gen.c.t
new file mode 100644
index 0000000..566d957
--- /dev/null
+++ b/libs/filters/GP_ApplyTables.gen.c.t
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+%% extends "filter.c.t"
+
+%% block descr
+Generic Point filer
+%% endblock
+
+%% block body
+
+#include <errno.h>
+
+#include "core/GP_Context.h"
+#include "core/GP_GetPutPixel.h"
+#include "core/GP_Debug.h"
+
+#include "filters/GP_ApplyTables.h"
+
+%% for pt in pixeltypes
+%% if not pt.is_unknown() and not pt.is_palette()
+static int apply_tables_{{ pt.name }}(const GP_FilterArea *const area,
+ const GP_FilterTables *const tables,
+ GP_ProgressCallback *callback)
+{
+ GP_DEBUG(1, "Point filter %ux%u", area->src_w, area->src_h);
+
+ unsigned int x, y;
+ const GP_Context *src = area->src;
+ GP_Context *dst = area->dst;
+
+%% for c in pt.chanslist
+ GP_Pixel {{ c.name }};
+%% endfor
+
+ for (y = 0; y < area->src_h; y++) {
+ for (x = 0; x < area->src_w; x++) {
+ unsigned int src_x = area->src_x + x;
+ unsigned int src_y = area->src_y + y;
+ unsigned int dst_x = area->dst_x + x;
+ unsigned int dst_y = area->dst_y + y;
+
+ GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, src_x, src_y);
+
+%% for c in pt.chanslist
+ {{ c.name }} = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix);
+ {{ c.name }} = tables->table[{{ c.idx }}][{{ c.name }}];
+%% endfor
+
+ pix = GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "", "") }});
+ GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, dst_x, dst_y, pix);
+ }
+
+ if (GP_ProgressCallbackReport(callback, y, area->src_h, area->src_w)) {
+ errno = ECANCELED;
+ return 1;
+ }
+ }
+
+ GP_ProgressCallbackDone(callback);
+
+ return 0;
+}
+
+%% endif
+%% endfor
+
+int GP_FilterTablesApply(const GP_FilterArea *const area,
+ const GP_FilterTables *const tables,
+ GP_ProgressCallback *callback)
+{
+ GP_ASSERT(area->src->pixel_type == area->dst->pixel_type);
+ //TODO: Assert size
+
+ switch (area->src->pixel_type) {
+%% for pt in pixeltypes
+%% if not pt.is_unknown() and not pt.is_palette()
+ case GP_PIXEL_{{ pt.name }}:
+ return apply_tables_{{ pt.name }}(area, tables, callback);
+ break;
+%% endif
+%% endfor
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+}
+
+%% endblock body
diff --git a/libs/filters/GP_Brightness.gen.c.t b/libs/filters/GP_Brightness.gen.c.t
index 2a02268..374837d 100644
--- a/libs/filters/GP_Brightness.gen.c.t
+++ b/libs/filters/GP_Brightness.gen.c.t
@@ -16,39 +16,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
%% extends "filter.point.c.t"
%% block descr
-Brightness filters -- Increments color channel(s) by a fixed value.
+Brightness Point filter
%% endblock
%% block body
-{{ filter_point_include() }}
+#include "core/GP_Clamp.h"
-%% macro filter_op(chann_name, chann_size)
-{{ chann_name }} = {{ chann_name }} + {{ chann_name }}_inc;
-{{ filter_clamp_val(chann_name, chann_size) }}
-%% endmacro
+%% macro filter_op_brightness(val, val_max)
+GP_CLAMP_GENERIC({{ val }} + (p * {{ val_max }} + 0.5), 0, {{ val_max }})
+%%- endmacro
-/*
- * Generated brightness filters.
- */
-%% call(pt) filter_point_per_channel('Brightness', 'GP_FilterParam incs[]', filter_op)
-{{ filter_params(pt, 'incs', 'int32_t ', '_inc', 'i') }}
-%% endcall
-
-/*
- * Generated constrast filters for pixels with one channel.
- */
-%% call(ps) filter_point_per_bpp('Brightness', 'GP_FilterParam incs[]', filter_op)
-{{ filter_param(ps, 'incs', 'int32_t ', '_inc', 'i') }}
-%% endcall
-
-{{ filter_functions('Brightness', 'GP_FilterParam incs[]', 'incs') }}
+{{ filter_point('Brightness', filter_op_brightness, 'float p', 'p') }}
%% endblock body
diff --git a/libs/filters/GP_Contrast.gen.c.t b/libs/filters/GP_Contrast.gen.c.t
index c8dae6f..d00a6fc 100644
--- a/libs/filters/GP_Contrast.gen.c.t
+++ b/libs/filters/GP_Contrast.gen.c.t
@@ -16,39 +16,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
%% extends "filter.point.c.t"
%% block descr
-Contrast filters -- Multiply color channel(s) by a fixed float value.
+Contrast Point filter
%% endblock
%% block body
-{{ filter_point_include() }}
+#include "core/GP_Clamp.h"
-%% macro filter_op(chan_name, chan_size)
-{{ chan_name }} = {{ chan_name }} * {{ chan_name }}_mul + 0.5;
-{{ filter_clamp_val(chan_name, chan_size) }}
-%% endmacro
+%% macro filter_op_contrast(val, val_max)
+GP_CLAMP_GENERIC({{ val }} * p + 0.5, 0, {{ val_max }})
+%%- endmacro
-/*
- * Generated contrast filters for pixels with several channels.
- */
-%% call(pt) filter_point_per_channel('Contrast', 'GP_FilterParam muls[]', filter_op)
-{{ filter_params(pt, 'muls', 'float ', '_mul', 'f') }}
-%% endcall
-
-/*
- * Generated constrast filters for pixels with one channel.
- */
-%% call(ps) filter_point_per_bpp('Contrast', 'GP_FilterParam muls[]', filter_op)
-{{ filter_param(ps, 'muls', 'float ', '_mul', 'f') }}
-%% endcall
-
-{{ filter_functions('Contrast', 'GP_FilterParam muls[]', 'muls') }}
+{{ filter_point('Contrast', filter_op_contrast, 'float p', 'p') }}
%% endblock body
diff --git a/libs/filters/GP_Invert.gen.c.t b/libs/filters/GP_Invert.gen.c.t
index ef9598e..2f5a4fe 100644
--- a/libs/filters/GP_Invert.gen.c.t
+++ b/libs/filters/GP_Invert.gen.c.t
@@ -16,30 +16,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
%% extends "filter.point.c.t"
%% block descr
-Invert filters -- Invert image
+Invert Point filter -- Inverts pixel channel values
%% endblock
%% block body
-{{ filter_point_include() }}
+%% macro filter_op_invert(val, val_max)
+{{ val_max }} - {{ val }}
+%%- endmacro
-%% macro filter_op(chann_name, chann_size)
-{{ chann_name }} = {{ 2 ** chann_size - 1 }} - {{ chann_name }};
-%% endmacro
-
-%% call(pt) filter_point_per_channel('Invert', '', filter_op)
-%% endcall
-
-%% call(ps) filter_point_per_bpp('Invert', '', filter_op)
-%% endcall
-
-{{ filter_functions('Invert') }}
+{{ filter_point('Invert', filter_op_invert) }}
%% endblock body
diff --git a/libs/filters/Makefile b/libs/filters/Makefile
index 05a310e..e39d66e 100644
--- a/libs/filters/Makefile
+++ b/libs/filters/Makefile
@@ -3,8 +3,8 @@ include $(TOPDIR)/pre.mk
STATS_FILTERS=GP_Histogram.gen.c
-POINT_FILTERS=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c- GP_Point.gen.c GP_Noise.gen.c GP_GaussianNoise.gen.c
+POINT_FILTERS=GP_GaussianNoise.gen.c GP_ApplyTables.gen.c GP_Invert.gen.c+ GP_Brightness.gen.c GP_Contrast.gen.c
ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c GP_Max.gen.c GP_Multiply.gen.c
diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py
index 67022ba..c5ef3ab 100644
--- a/pylib/gfxprim/filters/__init__.py
+++ b/pylib/gfxprim/filters/__init__.py
@@ -20,7 +20,10 @@ def _init(module):
_context._submodules['filters'] = FiltersSubmodule
- for name in ['Resize', 'ResizeAlloc',
+ for name in ['Invert', 'InvertAlloc',
+ 'Brightness', 'BrightnessAlloc',
+ 'Contrast', 'ContrastAlloc',
+ 'Resize', 'ResizeAlloc',
'Rotate90', 'Rotate90Alloc',
'Rotate180', 'Rotate180Alloc',
'Rotate270', 'Rotate270Alloc',
diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i
index 7417ec4..59da75b 100644
--- a/pylib/gfxprim/filters/filters.i
+++ b/pylib/gfxprim/filters/filters.i
@@ -28,7 +28,10 @@ ERROR_ON_NONZERO(GP_Filter ## funcname);
%newobject GP_FilterParamCreate;
%include "GP_FilterParam.h"
-/* TODO: Point filters, once fixed */
+FILTER_FUNC(Invert);
+FILTER_FUNC(Brightness);
+FILTER_FUNC(Contrast);
+%include "GP_Point.h"
/* Arithmetic filters */
FILTER_FUNC(Addition);
diff --git a/pylib/templates/filter.point.c.t b/pylib/templates/filter.point.c.t
index 7789bb1..bdd0679 100644
--- a/pylib/templates/filter.point.c.t
+++ b/pylib/templates/filter.point.c.t
@@ -1,135 +1,73 @@
%% extends "filter.c.t"
%% macro filter_point_include()
-{{ filter_include() }}
-#include "GP_Point.h"
+#include <errno.h>
+
+#include "core/GP_Debug.h"
+
+#include "filters/GP_ApplyTables.h"
+#include "filters/GP_Point.h"
%% endmacro
-/*
- * Filter per pixel type, used for images with more than one channel per pixel
- */
-%% macro filter_point_per_channel(name, opts="", filter_op)
-%% for pt in pixeltypes
-%% if not pt.is_unknown() and len(pt.chanslist) > 1
-static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src, GP_Context *dst,
- {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback)
+%% macro filter_point_ex(op_name, filter_op, fopts)
+int GP_Filter{{ op_name }}Ex(const GP_FilterArea *const area{{ maybe_opts_l(fopts) }},
+ GP_ProgressCallback *callback)
{
-{{ caller(pt) }}
- uint32_t x, y;
-
- for (y = 0; y < src->h; y++) {
- for (x = 0; x < src->w; x++) {
- GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x, y);
- %% for c in pt.chanslist
- int32_t {{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix);
- %% endfor
+ const GP_PixelTypeDescription *desc;
+ GP_FilterTables tables;
+ unsigned int i;
+ GP_Pixel j;
+ int ret, err;
- %% for c in pt.chanslist
- {{ filter_op(c[0], c[2]) }}
- %% endfor
+ if (GP_FilterTablesInit(&tables, area->src))
+ return 1;
- pix = GP_Pixel_CREATE_{{ pt.name }}({{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, {{ c[0] }}{% endfor %});
+ desc = GP_PixelTypeDesc(area->src->pixel_type);
- GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, pix);
- }
+ for (i = 0; i < desc->numchannels; i++) {
+ GP_Pixel chan_max = (1 << desc->channels[i].size);
+ GP_Pixel *table = tables.table[i];
- if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
- return 1;
+ for (j = 0; j < chan_max; j++)
+ table[j] = {{ filter_op('((signed)j)', '((signed)chan_max - 1)') }};
}
- GP_ProgressCallbackDone(callback);
- return 0;
-}
-
-%% endif
-%% endfor
-%% endmacro
+ ret = GP_FilterTablesApply(area, &tables, callback);
-/*
- * Point filter per bpp (used for 1 channel pixels to save space).
- */
-%% macro filter_point_per_bpp(name, opts="", filter_op)
-%% for ps in pixelsizes
-%% if ps.size > 1
-static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src, GP_Context *dst,
- {{ maybe_opts_r(opts) }}GP_ProgressCallback *callback)
-{
-{{ caller(ps) }}
- uint32_t x, y;
-
- for (y = 0; y < src->h; y++) {
- for (x = 0; x < src->w; x++) {
- int32_t pix = GP_GetPixel_Raw_{{ ps.suffix }}(src, x, y);
- {{ filter_op('pix', ps.size) }}
- GP_PutPixel_Raw_{{ ps.suffix }}(dst, x, y, pix);
- }
-
- if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
- return 1;
- }
+ err = errno;
+ GP_FilterTablesFree(&tables);
+ errno = err;
- GP_ProgressCallbackDone(callback);
- return 0;
+ return ret;
}
-
-%% endif
-%% endfor
%% endmacro
-/*
- * Switch per pixel sizes or pixel types.
- */
-%% macro filter_functions(name, opts="", params="", fmt="")
-int GP_Filter{{ name }}_Raw(const GP_Context *src, GP_Context *dst{{ maybe_opts_l(opts) }},
- GP_ProgressCallback *callback)
+%% macro filter_point_ex_alloc(op_name, fopts, opts)
+GP_Context *GP_Filter{{ op_name }}ExAlloc(const GP_FilterArea *const area{{ maybe_opts_l(fopts) }},
+ GP_ProgressCallback *callback)
{
- GP_DEBUG(1, "Running filter {{ name }}");
-
- switch (src->pixel_type) {
- %% for pt in pixeltypes
- case GP_PIXEL_{{ pt.name }}:
- %% if pt.is_unknown() or pt.pixelsize.size < 2
- return 1;
- %% elif len(pt.chanslist) == 1:
- //TODO: BITENDIAN
- return GP_Filter{{ name }}_{{ pt.pixelsize.suffix }}(src, dst{{ maybe_opts_l(params) }}, callback);
- %% else
- return GP_Filter{{ name }}_{{ pt.name }}(src, dst{{ maybe_opts_l(params) }}, callback);
- %% endif
- %% endfor
- default:
- break;
- }
-
- return 1;
-}
-
-GP_Context *GP_Filter{{ name }}(const GP_Context *src, GP_Context *dst{{ maybe_opts_l(opts) }},
- GP_ProgressCallback *callback)
-{
- GP_Context *res = dst;
-
- if (res == NULL) {
- res = GP_ContextCopy(src, 0);
-
- if (res == NULL)
- return NULL;
- } else {
- GP_ASSERT(src->pixel_type == dst->pixel_type,
- "The src and dst pixel types must match");
- GP_ASSERT(src->w <= dst->w && src->h <= dst->h,
- "Destination is not big enough");
- }
-
- if (GP_Filter{{ name }}_Raw(src, res{{ maybe_opts_l(params) }}, callback)) {
- GP_DEBUG(1, "Operation aborted");
-
- if (dst == NULL)
- GP_ContextFree(res);
-
+ GP_FilterArea carea = *area;
+ GP_Context *new = GP_ContextAlloc(area->src_w, area->src_h,
+ area->src->pixel_type);
+
+ /* Clear these just to be sure */
+ carea.dst_x = 0;
+ carea.dst_y = 0;
+ carea.dst = new;
+
+ if (GP_Filter{{ op_name }}Ex(&carea, {{ maybe_opts_r(opts) }}callback)) {
+ int err = errno;
+ GP_ContextFree(new);
+ errno = err;
return NULL;
}
- return res;
+ return new;
}
%% endmacro
+
+%% macro filter_point(op_name, filter_op, fopts="", opts="")
+{{ filter_point_include() }}
+{{ filter_point_ex(op_name, filter_op, fopts) }}
+{{ filter_point_ex_alloc(op_name, fopts, opts) }}
+%% endmacro
http://repo.or.cz/w/gfxprim.git/commit/c83a0d2c773e72545e78f465ec4c2dea9227…
commit c83a0d2c773e72545e78f465ec4c2dea92272b55
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Nov 6 19:55:44 2013 +0100
doc: Cleanup loaders docs a bit.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/about.txt b/doc/about.txt
index fc4d176..1dc7ce5 100644
--- a/doc/about.txt
+++ b/doc/about.txt
@@ -61,6 +61,7 @@ printing text into the bitmap. There are two bitmap fonts compiled directly
into the library and we support True Type fonts through
link:http://freetype.org[FreeType] (so far ASCII printable characters only).
+[[Loaders]]
Loaders
-------
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 1702470..3b8e283 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -3,8 +3,10 @@ Context loaders
This part of GFXprim library aims to create API to load and save images
from/to common image file formats.
-Currently we support JPEG, PNG, BPM and PNM images for loading and saving and
-GIF and PSP for loading.
+Currently we support JPEG, PNG, BMP, TIFF and PNM images for loading and
+saving and GIF, JPEG2000 and PSP for loading.
+
+Have a look at the link:about.html#Loaders[supported formats].
Loaders API
~~~~~~~~~~~
@@ -48,21 +50,21 @@ Image Loader
GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads image from a file.
+Loads an image from a file.
The image format is first guessed by the file extension. If loader for the
file extension is found it's called and if it succedes the image data is
returned.
-If extension based guess fails either because the extension wasn't matched or
-if the loader for the extension failed; the signature based method is used.
-The loader loads several bytes (currently 32) from the file and calls
-signature matching functions for each format that implements signature
-matching. If image signature is found particular image loader it is called
-and the result is returned.
+If file extension based guess fails either because the extension wasn't
+matched or if the loader for the extension failed; the signature based method
+is used. The loader loads several bytes (currently 32) from the file and
+calls signature matching functions for each format that implements signature
+matching. If image signature is found image loader it is called and the result
+is returned.
-If file extension disagrees with file signature a warning is printed into the
-'stderr'.
+If file extension disagrees with file signature on the file format a warning
+is printed into the 'stderr'.
[source,c]
-------------------------------------------------------------------------------
@@ -76,11 +78,16 @@ int GP_SaveImage(GP_Context *src, const char *dst_path,
Saves a context into a file.
-The file format is matched accordingly to the file extension. If extension is
-not found non-zero is returned and 'errno' is set to 'EINVAL'. If extension
-was found but support for saving the image format is not implemented 'errno'
-is set to 'ENOSYS'.
+The file format is matched accordingly to the file extension.
+
+If extension is not found non-zero is returned and 'errno' is set to 'EINVAL'.
+
+If extension was found but support for saving the image format is not
+implemented 'errno' is set to 'ENOSYS' (this may happen in case that GFXprim
+wasn't compiled with support for this image type).
+If context pixel type is not supported by the format 'errno' is set to
+'EINVAL'.
Advanced usage
^^^^^^^^^^^^^^
http://repo.or.cz/w/gfxprim.git/commit/d93da078d5d3db1e457a0225a26da0cead00…
commit d93da078d5d3db1e457a0225a26da0cead0085cb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Nov 6 19:39:21 2013 +0100
doc: Finish logo and favicon.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/favicon.png b/doc/favicon.png
index ad24515..e35dc42 100644
Binary files a/doc/favicon.png and b/doc/favicon.png differ
diff --git a/doc/gfxprim_logo.png b/doc/gfxprim_logo.png
index 5cf4f68..6857f55 100644
Binary files a/doc/gfxprim_logo.png and b/doc/gfxprim_logo.png differ
http://repo.or.cz/w/gfxprim.git/commit/147b4068a0ef11c88d116442680ad46894a7…
commit 147b4068a0ef11c88d116442680ad46894a7b12a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Nov 3 20:16:00 2013 +0100
gp_codegen: Add idx to channel.
The channel.idx describes position of the channel in pixel (from left).
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gp_codegen/pixeltype.py b/pylib/gp_codegen/pixeltype.py
index bcad7fc..9887136 100644
--- a/pylib/gp_codegen/pixeltype.py
+++ b/pylib/gp_codegen/pixeltype.py
@@ -9,12 +9,14 @@ import re
from .pixelsize import PixelSize
class PixelChannel(list):
- def __init__(self, triplet):
+ def __init__(self, triplet, idx):
(name, offset, size) = triplet
# Create the list -> backward compatibility with triplets
self.append(name)
self.append(offset)
self.append(size)
+ # Add index (position in pixel from left)
+ self.idx = idx
# Add some convinience variables
self.name = name
self.off = offset
@@ -45,8 +47,10 @@ class PixelType(object):
self.name = name
# Create channel list with convinience variables
new_chanslist = []
+ idx = 0
for i in chanslist:
- new_chanslist.append(PixelChannel(i))
+ new_chanslist.append(PixelChannel(i, idx))
+ idx = idx + 1
self.chanslist = new_chanslist
self.chans = dict() # { chan_name: (offset, size) }
self.pixelsize = pixelsize
-----------------------------------------------------------------------
Summary of changes:
build/syms/Filters_symbols.txt | 23 ++-
demos/grinder/grinder.c | 141 +----------------
demos/py_simple/{dither.py => invert.py} | 8 +-
doc/about.txt | 1 +
doc/favicon.png | Bin 4929 -> 609 bytes
doc/gfxprim_logo.png | Bin 8112 -> 8732 bytes
doc/loaders.txt | 37 +++--
.../{GP_EdgeDetection.h => GP_ApplyTables.h} | 44 +++++-
include/filters/GP_Filter.h | 27 +++-
include/filters/GP_Point.h | 101 ++++++++-----
.../{GP_MirrorV.gen.c.t => GP_ApplyTables.c} | 102 ++++++++-----
...{GP_ResizeNN.gen.c.t => GP_ApplyTables.gen.c.t} | 89 ++++++------
libs/filters/GP_Brightness.gen.c.t | 29 +---
libs/filters/GP_Contrast.gen.c.t | 29 +---
libs/filters/GP_Invert.gen.c.t | 20 +--
libs/filters/Makefile | 4 +-
libs/loaders/GP_PNM.c | 7 +-
pylib/gfxprim/filters/__init__.py | 5 +-
pylib/gfxprim/filters/filters.i | 5 +-
pylib/gp_codegen/pixeltype.py | 8 +-
pylib/templates/filter.point.c.t | 162 ++++++--------------
21 files changed, 370 insertions(+), 472 deletions(-)
copy demos/py_simple/{dither.py => invert.py} (65%)
copy include/filters/{GP_EdgeDetection.h => GP_ApplyTables.h} (66%)
copy libs/filters/{GP_MirrorV.gen.c.t => GP_ApplyTables.c} (53%)
copy libs/filters/{GP_ResizeNN.gen.c.t => GP_ApplyTables.gen.c.t} (56%)
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.")
1
0