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
30 May '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 8ab5ac0d39286dd025fcc5df44db7d5530209899 (commit)
via aa25e20587692884c085e045ce281be07d4b1518 (commit)
via 7bab9abf175a1d8eea8e7570fdb77a24fa2b08ad (commit)
from 65ca2dca576b0de212af87daf4b8ac069bc2967d (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/8ab5ac0d39286dd025fcc5df44db7d553020…
commit 8ab5ac0d39286dd025fcc5df44db7d5530209899
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu May 30 23:32:57 2013 +0200
loaders: BMP: Add support for RGB555.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index 29ee503..ca2fe29 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -325,6 +325,10 @@ static GP_PixelType match_pixel_type(struct bitmap_info_header *header)
case 8:
case 24:
return GP_PIXEL_RGB888;
+#ifdef GP_PIXEL_RGB555
+ case 16:
+ return GP_PIXEL_RGB555;
+#endif
}
return GP_PIXEL_UNKNOWN;
@@ -446,13 +450,13 @@ static int read_palette(FILE *f, struct bitmap_info_header *header,
return 0;
}
-static int read_rgb888(FILE *f, struct bitmap_info_header *header,
- GP_Context *context, GP_ProgressCallback *callback)
+static int read_rgb(FILE *f, struct bitmap_info_header *header,
+ GP_Context *context, GP_ProgressCallback *callback)
{
- uint32_t row_size = 3 * header->w;
+ uint32_t row_size = header->w * (header->bpp / 8);
int32_t y;
int err;
-
+
if ((err = seek_pixels_offset(header, f)))
return err;
@@ -504,8 +508,11 @@ static int read_bitmap_pixels(FILE *f, struct bitmap_info_header *header,
case 4:
case 8:
return read_palette(f, header, context, callback);
+#ifdef GP_PIXEL_RGB555
+ case 16:
+#endif
case 24:
- return read_rgb888(f, header, context, callback);
+ return read_rgb(f, header, context, callback);
}
return ENOSYS;
http://repo.or.cz/w/gfxprim.git/commit/aa25e20587692884c085e045ce281be07d4b…
commit aa25e20587692884c085e045ce281be07d4b1518
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu May 30 23:31:09 2013 +0200
gfxprim_config.py: Add RGB555.
This is needed to support 16 bit RGB BMP.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/gfxprim_config.py b/gfxprim_config.py
index dad4bbe..ae32019 100644
--- a/gfxprim_config.py
+++ b/gfxprim_config.py
@@ -65,7 +65,12 @@ config = GfxPrimConfig(
('B', 16, 8),
('G', 8, 8),
('R', 0, 8)]),
-
+
+ PixelType(name='RGB555', pixelsize=PS_16BPP, chanslist=[
+ ('R', 10, 5),
+ ('G', 5, 5),
+ ('B', 0, 5)]),
+
PixelType(name='RGB565', pixelsize=PS_16BPP, chanslist=[
('R', 11, 5),
('G', 5, 6),
http://repo.or.cz/w/gfxprim.git/commit/7bab9abf175a1d8eea8e7570fdb77a24fa2b…
commit 7bab9abf175a1d8eea8e7570fdb77a24fa2b08ad
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu May 30 23:29:06 2013 +0200
core: GP_Pixel.gen.h.t: Add #define GP_PIXEL_foo
So that we can use:
#ifdef GP_PIXEL_RGBA5551
...
#endif
for less common pixel types.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Pixel.gen.h.t b/include/core/GP_Pixel.gen.h.t
index f0bddab..d6e7659 100644
--- a/include/core/GP_Pixel.gen.h.t
+++ b/include/core/GP_Pixel.gen.h.t
@@ -16,7 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * Copyright (C) 2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -40,6 +41,10 @@ typedef enum GP_PixelType {
} GP_PixelType;
%% for pt in pixeltypes
+#define GP_PIXEL_{{ pt.name }} GP_PIXEL_{{ pt.name }}
+%% endfor
+
+%% for pt in pixeltypes
%% if not pt.is_unknown()
/* Automatically generated code for pixel type {{ pt.name }}
*
-----------------------------------------------------------------------
Summary of changes:
gfxprim_config.py | 7 ++++++-
include/core/GP_Pixel.gen.h.t | 7 ++++++-
libs/loaders/GP_BMP.c | 17 ++++++++++++-----
3 files changed, 24 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
27 May '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 65ca2dca576b0de212af87daf4b8ac069bc2967d (commit)
from 4b617848e0d959af89531911192a376442bc30a1 (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/65ca2dca576b0de212af87daf4b8ac069bc2…
commit 65ca2dca576b0de212af87daf4b8ac069bc2967d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 26 22:36:57 2013 +0200
spiv: Add new zoom type.
In this mode, images are not upscaled when they are smaller than screen.
Also fix modulo by zero on small enough transparent images.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 6f48840..5f03205 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -22,7 +22,7 @@
/*
- SPIV -- Simple but Powerfull Image Viewer.
+ SPIV -- Simple yet Powerful Image Viewer.
*/
@@ -33,7 +33,6 @@
#include <pthread.h>
#include <GP.h>
-#include <backends/GP_Backends.h>
#include <input/GP_InputDriverLinux.h>
#include "image_cache.h"
@@ -68,6 +67,12 @@ enum zoom_type {
* 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 {
@@ -151,7 +156,8 @@ static GP_Context *load_image(struct loader_params *params, int elevate);
* backend (window) is resized we will get SYS_RESIZE event, see the main event
* loop.
*/
-static void resize_backend(struct loader_params *params, float ratio, int shift_flag)
+static void resize_backend(struct loader_params *params,
+ float ratio, int shift_flag)
{
GP_Context *img = load_image(params, 1);
@@ -173,6 +179,9 @@ static float calc_img_size(struct loader_params *params,
float h_rat;
switch (params->zoom_type) {
+ case ZOOM_FIT_DOWNSCALE:
+ if (img_w <= src_w && img_h <= src_h)
+ return 1.00;
case ZOOM_FIT:
w_rat = 1.00 * src_w / img_w;
h_rat = 1.00 * src_h / img_h;
@@ -184,7 +193,7 @@ static float calc_img_size(struct loader_params *params,
return params->zoom;
}
- return 1;
+ return 1.00;
}
static const char *img_name(const char *img_path)
@@ -265,14 +274,19 @@ static void pattern_fill(GP_Context *ctx, unsigned int x0, unsigned int y0, unsi
{
unsigned int x, y;
- GP_Pixel g1 = GP_RGBToContextPixel(0x44, 0x44, 0x44, ctx);
- GP_Pixel g2 = GP_RGBToContextPixel(0x33, 0x33, 0x33, ctx);
+ GP_Pixel g1 = GP_RGBToContextPixel(0x64, 0x64, 0x64, ctx);
+ GP_Pixel g2 = GP_RGBToContextPixel(0x80, 0x80, 0x80, ctx);
+
+ unsigned int wm = w/10 < 10 ? 10 : w/10;
+ unsigned int hm = h/10 < 10 ? 10 : h/10;
+ unsigned int wt = w/20 < 5 ? 5 : w/20;
+ unsigned int ht = h/20 < 5 ? 5 : h/20;
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
GP_Pixel pix;
- if ((x%(w/10) < (w/20)) ^ (y%(h/10) < (h/20)))
+ if ((x % wm < wt) ^ (y % hm < ht))
pix = g1;
else
pix = g2;
@@ -315,6 +329,7 @@ static void update_display(struct loader_params *params, GP_Context *img)
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;
@@ -733,7 +748,7 @@ int main(int argc, char *argv[])
.rotate = 0,
.resampling_method = GP_INTERP_LINEAR_LF_INT,
- .zoom_type = ZOOM_FIT,
+ .zoom_type = ZOOM_FIT_DOWNSCALE,
.zoom = 1,
.img_resized_cache = NULL,
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 31 +++++++++++++++++++++++--------
1 files changed, 23 insertions(+), 8 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
26 May '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 4b617848e0d959af89531911192a376442bc30a1 (commit)
via 9d86b8f15fced851b346d6778bf575199671fc92 (commit)
via 4d361f3de0eafe0a60d5b96a4051e58e28bf9be0 (commit)
via 84c99346779e46b0cc9b86cd0c230002b99d3b7a (commit)
via b977a0c7137a1c6725b84ceb4a1514513f6049bb (commit)
via 34f2dc55eb9de6087d495cecf94669be47451ead (commit)
via 752688c98757d2c59dac433cfdfebc645d9a360c (commit)
via 8a5b220d6f33c0d69f32b1d9566c32909667278b (commit)
from a75d7240e0224f992b9cb7895af24aeae8409728 (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/4b617848e0d959af89531911192a376442bc…
commit 4b617848e0d959af89531911192a376442bc30a1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 26 18:35:31 2013 +0200
spiv: Add scrolling to help.
The help page can be scrolled both horizontally and vertically now.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
index 38ae582..701b5ae 100644
--- a/demos/spiv/spiv_help.c
+++ b/demos/spiv/spiv_help.c
@@ -117,7 +117,7 @@ void print_help(void)
}
-void draw_help(GP_Backend *backend)
+static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff)
{
GP_Context *c = backend->context;
GP_Pixel black = GP_ColorToContextPixel(GP_COL_BLACK, c);
@@ -126,12 +126,31 @@ void draw_help(GP_Backend *backend)
GP_Fill(c, black);
- for (i = 0; i < keys_help_len; i++) {
- GP_Print(c, NULL, 20, 2 + i * 15, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ for (i = loff; i < keys_help_len; i++) {
+ GP_Coord h = 2 + (i - loff) * 15;
+
+ if (h + 2 >= (GP_Coord)c->h)
+ goto out;
+
+ GP_Print(c, NULL, 20 + 10 * xoff, h, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white, black, "%s", keys_help[i]);
}
+out:
GP_BackendFlip(backend);
+ return i;
+}
+
+static int max_lines(GP_Backend *backend)
+{
+ return (backend->context->h - 4) / 15;
+}
+
+void draw_help(GP_Backend *backend)
+{
+ int loff = 0, last, xoff = 0;
+
+ last = redraw_help(backend, loff, xoff);
for (;;) {
GP_Event ev;
@@ -143,10 +162,52 @@ void draw_help(GP_Backend *backend)
continue;
switch (ev.val.key.key) {
+ case GP_KEY_DOWN:
+ if (last < keys_help_len)
+ last = redraw_help(backend, ++loff, xoff);
+ break;
+ case GP_KEY_UP:
+ if (loff > 0)
+ last = redraw_help(backend, --loff, xoff);
+ break;
+ case GP_KEY_LEFT:
+ last = redraw_help(backend, loff, --xoff);
+ break;
+ case GP_KEY_RIGHT:
+ last = redraw_help(backend, loff, ++xoff);
+ break;
+ case GP_KEY_PAGE_DOWN:
+ if (last < keys_help_len) {
+ if (loff + max_lines(backend) >= keys_help_len)
+ break;
+
+ loff += max_lines(backend);
+
+ last = redraw_help(backend, loff, xoff);
+ }
+ break;
+ case GP_KEY_PAGE_UP:
+ if (loff > 0) {
+ loff -= max_lines(backend);
+ if (loff < 0)
+ loff = 0;
+ last = redraw_help(backend, loff, xoff);
+ }
+ break;
default:
return;
}
break;
+ case GP_EV_SYS:
+ switch (ev.code) {
+ case GP_EV_SYS_RESIZE:
+ GP_BackendResizeAck(backend);
+ last = redraw_help(backend, loff, xoff);
+ break;
+ case GP_EV_SYS_QUIT:
+ GP_BackendPutEventBack(backend, &ev);
+ return;
+ }
}
}
}
http://repo.or.cz/w/gfxprim.git/commit/9d86b8f15fced851b346d6778bf575199671…
commit 9d86b8f15fced851b346d6778bf575199671fc92
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 26 19:14:06 2013 +0200
pywrap: backends: Add PeekEvent and PutEventBack.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/backends/_extend_backend.py b/pylib/gfxprim/backends/_extend_backend.py
index 7ab8d07..efd010f 100644
--- a/pylib/gfxprim/backends/_extend_backend.py
+++ b/pylib/gfxprim/backends/_extend_backend.py
@@ -59,11 +59,26 @@ def extend_backend(_backend):
ev = c_input.GP_Event()
if c_backends.GP_BackendGetEvent(self, ev) != 0:
- return ev
+ return ev
return None
@extend(_backend)
+ def PeekEvent(self):
+ "Returns, but not removes, the top of the backend event queue."
+ ev = c_input.GP_Event()
+
+ if c_backends.GP_BackendPeekEvent(self, ev) != 0:
+ return ev
+
+ return None
+
+ @extend(_backend)
+ def PutEventBack(self, ev):
+ "Puts back event removed from the top of the backend event queue."
+ c_backends.GP_BackendPutEventBack(self, ev)
+
+ @extend(_backend)
def EventsQueued(self):
"Returns the number of events queued in the backend event queue."
return c_backends.GP_BackendEventsQueued(self)
http://repo.or.cz/w/gfxprim.git/commit/4d361f3de0eafe0a60d5b96a4051e58e28bf…
commit 4d361f3de0eafe0a60d5b96a4051e58e28bf9be0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 26 19:07:58 2013 +0200
doc: Update backends docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/backends.txt b/doc/backends.txt
index 481a425..ff8cffb 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -452,6 +452,36 @@ TIP: For more information on events see link:input.html[input events]
documentation.
+GP_BackendPeekEvent
+^^^^^^^^^^^^^^^^^^^
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <backends/GP_Backend.h>
+/* or */
+#include <GP.h>
+
+int GP_BackendPeekEvent(GP_Backend *self, GP_Event *ev);
+-------------------------------------------------------------------------------
+
+Same as +GP_BackendPeekEvent()+ but the top event is not removed from the
+queue.
+
+GP_BackendPutEventBack
+^^^^^^^^^^^^^^^^^^^^^^
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <backends/GP_Backend.h>
+/* or */
+#include <GP.h>
+
+void GP_BackendPutEventBack(GP_Backend *self, GP_Event *ev);
+-------------------------------------------------------------------------------
+
+Puts event to the top of the queue. May be useful for putting back events that
+were removed from the queue.
+
GP_BackendSetCaption
^^^^^^^^^^^^^^^^^^^^
http://repo.or.cz/w/gfxprim.git/commit/84c99346779e46b0cc9b86cd0c230002b99d…
commit 84c99346779e46b0cc9b86cd0c230002b99d3b7a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 26 19:02:53 2013 +0200
doc: Update and fix GP_EventQueue docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/event_queue.txt b/doc/event_queue.txt
index 7f786bc..5b476bd 100644
--- a/doc/event_queue.txt
+++ b/doc/event_queue.txt
@@ -54,7 +54,7 @@ failed 'NULL' is returned.
/* or */
#include <input/GP_EventQueue.h>
-unsigned int GP_EventsQueueEventsQueued(void);
+unsigned int GP_EventsQueueEventsQueued(GP_EventQueue *self);
-------------------------------------------------------------------------------
This function returns number of queued events.
@@ -65,7 +65,7 @@ This function returns number of queued events.
/* or */
#include <input/GP_EventQueue.h>
-int GP_EventQueueGet(struct GP_Event *ev);
+int GP_EventQueueGet(GP_EventQueue *self, GP_Event *ev);
-------------------------------------------------------------------------------
In case there are any events queued, the top event is removed from the
@@ -80,6 +80,29 @@ If there are no events queued the call returns immediately with zero.
/* or */
#include <input/GP_EventQueue.h>
+int GP_EventQueuePeek(GP_EventQueue *self, GP_Event *ev);
+-------------------------------------------------------------------------------
+
+Same as +GP_EventQueueGet()+ but the top event is not removed from the queue.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <input/GP_EventQueue.h>
+
+void GP_EventQueuePutBack(GP_EventQueue *self, GP_Event *ev);
+-------------------------------------------------------------------------------
+
+Puts event to the top of the queue. Useful for putting back event that has
+been removed from the queue.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <input/GP_EventQueue.h>
+
/*
* Inject event that moves cursor by rx and ry.
*
http://repo.or.cz/w/gfxprim.git/commit/b977a0c7137a1c6725b84ceb4a1514513f60…
commit b977a0c7137a1c6725b84ceb4a1514513f6049bb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 26 18:56:09 2013 +0200
input, backends: Add EventPeek and EventPushBack.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h
index 712f156..792d603 100644
--- a/include/backends/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -256,4 +256,14 @@ static inline int GP_BackendGetEvent(GP_Backend *self, GP_Event *ev)
return GP_EventQueueGet(&self->event_queue, ev);
}
+static inline int GP_BackendPeekEvent(GP_Backend *self, GP_Event *ev)
+{
+ return GP_EventQueuePeek(&self->event_queue, ev);
+}
+
+static inline void GP_BackendPutEventBack(GP_Backend *self, GP_Event *ev)
+{
+ GP_EventQueuePutBack(&self->event_queue, ev);
+}
+
#endif /* BACKENDS_GP_BACKEND_H */
diff --git a/include/input/GP_EventQueue.h b/include/input/GP_EventQueue.h
index 030742a..df25159 100644
--- a/include/input/GP_EventQueue.h
+++ b/include/input/GP_EventQueue.h
@@ -107,6 +107,11 @@ unsigned int GP_EventQueueEventsQueued(struct GP_EventQueue *self);
int GP_EventQueueGet(struct GP_EventQueue *self, struct GP_Event *ev);
/*
+ * Same as GP_EventQueueGet but the event is not removed from the queue.
+ */
+int GP_EventQueuePeek(struct GP_EventQueue *self, struct GP_Event *ev);
+
+/*
* Puts the event in the queue.
*
* This is bare call that just copies the event into the queue. Use the calls
@@ -114,6 +119,11 @@ int GP_EventQueueGet(struct GP_EventQueue *self, struct GP_Event *ev);
*/
void GP_EventQueuePut(struct GP_EventQueue *self, struct GP_Event *ev);
+/*
+ * Puts event to the top of the queue.
+ */
+void GP_EventQueuePutBack(struct GP_EventQueue *self, struct GP_Event *ev);
+
struct timeval;
/*
diff --git a/libs/input/GP_EventQueue.c b/libs/input/GP_EventQueue.c
index 5cf38c8..a3732f1 100644
--- a/libs/input/GP_EventQueue.c
+++ b/libs/input/GP_EventQueue.c
@@ -116,6 +116,16 @@ int GP_EventQueueGet(struct GP_EventQueue *self, struct GP_Event *ev)
return 1;
}
+int GP_EventQueuePeek(struct GP_EventQueue *self, struct GP_Event *ev)
+{
+ if (self->queue_first == self->queue_last)
+ return 0;
+
+ *ev = self->events[self->queue_first];
+
+ return 1;
+}
+
static void event_put(struct GP_EventQueue *self, struct GP_Event *ev)
{
unsigned int next = (self->queue_last + 1) % self->queue_size;
@@ -129,11 +139,34 @@ static void event_put(struct GP_EventQueue *self, struct GP_Event *ev)
self->queue_last = next;
}
+static void event_put_back(struct GP_EventQueue *self, struct GP_Event *ev)
+{
+ unsigned int prev;
+
+ if (self->queue_first == 0)
+ prev = self->queue_last - 1;
+ else
+ prev = self->queue_first - 1;
+
+ if (prev == self->queue_last) {
+ GP_WARN("Event queue full, dropping event.");
+ return;
+ }
+
+ self->events[prev] = *ev;
+ self->queue_first = prev;
+}
+
void GP_EventQueuePut(struct GP_EventQueue *self, struct GP_Event *ev)
{
event_put(self, ev);
}
+void GP_EventQueuePutBack(struct GP_EventQueue *self, struct GP_Event *ev)
+{
+ event_put_back(self, ev);
+}
+
static void set_time(struct GP_EventQueue *self, struct timeval *time)
{
if (time == NULL)
http://repo.or.cz/w/gfxprim.git/commit/34f2dc55eb9de6087d495cecf94669be4745…
commit 34f2dc55eb9de6087d495cecf94669be47451ead
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 26 16:59:23 2013 +0200
spiv: Move help to separate source file.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/Makefile b/demos/spiv/Makefile
index 52ba4ec..10bac03 100644
--- a/demos/spiv/Makefile
+++ b/demos/spiv/Makefile
@@ -10,7 +10,7 @@ LDLIBS+=$(LDLIBS_LOADERS) $(LDLIBS_BACKENDS)
APPS=spiv
-spiv: cpu_timer.o image_cache.o image_list.o image_actions.o
+spiv: cpu_timer.o image_cache.o image_list.o image_actions.o spiv_help.o
include $(TOPDIR)/pre.mk
include $(TOPDIR)/app.mk
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 8c77fff..6f48840 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -39,6 +39,7 @@
#include "image_cache.h"
#include "image_list.h"
#include "image_actions.h"
+#include "spiv_help.h"
#include "cpu_timer.h"
static GP_Pixel black_pixel;
@@ -712,121 +713,13 @@ static void init_caches(struct loader_params *params)
// params->img_orig_cache = NULL;
}
-static const char *keys_help[] = {
- "Keyboard control:",
- "",
- "Esc, Enter, Q - quit spiv",
- "",
- "< or KP Minus - zoom out by 1.5",
- "> or KP Plus - zoom in by 1.5",
- "R - rotate by 90 degrees clockwise",
- "Up, Down, Left, Right - move image by 1px",
- " (by 10 with Shift)",
- "",
- "Space - move to the next image",
- "BackSpace - move to the prev image",
- "PgDown - move to the start of directory",
- "PgUp - move to the end of directory",
- "Home - move to the first image",
- "End - move to the last image",
- "",
- "I - toggle show info box",
- "P - toggle show progress",
- "",
- "] - change to next resampling method",
- "[ - change to prev resampling method",
- " (current method is shown in info box)",
- "L - toggle low pass filter",
- "D - drop image cache",
- "H - toggle help",
- "",
- "F1-F10 - execute action 0 - 9",
- "",
- "1 - resize spiv window to the image size",
- "1 - resize spiv window to the image size",
- "2 - resize spiv window to the half of the image size",
- "3 - resize spiv window to the third of the image size",
- "...",
- "9 - resize spiv window to the ninth 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",
- "...",
-};
-
-static const int keys_help_len = sizeof(keys_help) / sizeof(char*);
-
-static void print_help(void)
-{
- int i;
-
- printf("Usage: spiv [opts] images or dirs with imagesnn");
- printf(" -I show image info boxn");
- printf(" -P show loading progressn");
- printf(" -f use floyd-steinberg ditheringn");
- printf(" -s sec sleep interval in secondsn");
- printf(" -c turns on bicubic resampling (experimental)n");
- printf(" -e pixel_type turns on backend type emulationn");
- printf(" for example -e G1 sets 1-bit grayscalen");
- printf(" -r angle rotate display 90,180 or 270 degreesn");
- printf(" -z moden");
- printf(" -zf zoom is set and modified by usern");
- printf(" -zw zoom is fixed to window size (currently default)n");
- printf(" -b pass backend init string to backend initn");
- printf(" pass -b help for more infon");
- puts("n");
- printf("Actions:nn");
- printf(" -0 'cmd' sets first actionn");
- printf(" -1 'cmd' sets second actionn");
- printf(" ...n");
- printf(" -9 'cmd' sets tenth actionn");
- puts("");
- printf(" actions are shell commands with following modifiers:n");
- printf(" %%f path to current imagen");
- printf(" %%F shell escaped path to current imagen");
- printf(" %%n current image filename without extensionn");
- printf(" %%N shell escaped image filename without extensionn");
- printf(" %%e current image file extensionn");
- puts("n");
-
- for (i = 0; i < keys_help_len; i++)
- puts(keys_help[i]);
-
- puts("");
-
- printf("Some cool options to try:nn");
- printf("spiv -0 'cp %%F sorted' [images]n");
- printf("tcopies current image into directory 'sorted/' on F1n");
- printf("spiv -e G1 -f [images]n");
- printf("truns spiv in 1-bit bitmap mode and turns on ditheringnn");
- printf("spiv -b 'X11:ROOT_WIN' [images]n");
- printf("truns spiv using X root window as backend windownn");
- printf("spiv -b 'X11:CREATE_ROOT' [images]n");
- printf("tSame as abowe but works in KDEn");
-}
-
-static void show_help(void)
-{
- GP_Context *c = backend->context;
- int i;
-
- GP_Fill(c, black_pixel);
-
- for (i = 0; i < keys_help_len; i++) {
- GP_Print(c, NULL, 20, 2 + i * 15, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- white_pixel, black_pixel, "%s", keys_help[i]);
- }
-
- GP_BackendFlip(backend);
-}
-
int main(int argc, char *argv[])
{
GP_Context *context = NULL;
const char *backend_opts = "X11";
int sleep_sec = -1;
int opt;
- int shift_flag, help_flag = 0;
+ int shift_flag;
GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
struct loader_params params = {
@@ -980,13 +873,8 @@ int main(int argc, char *argv[])
switch (ev.val.key.key) {
case GP_KEY_H:
- if (help_flag)
- show_image(¶ms, NULL);
- else
- show_help();
-
- //TODO: remove help_flag on any other action done
- help_flag = !help_flag;
+ draw_help(backend);
+ show_image(¶ms, NULL);
break;
case GP_KEY_F:
if (GP_BackendIsX11(backend))
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
new file mode 100644
index 0000000..38ae582
--- /dev/null
+++ b/demos/spiv/spiv_help.c
@@ -0,0 +1,153 @@
+/*****************************************************************************
+ * 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 <stdio.h>
+#include <GP.h>
+
+static const char *keys_help[] = {
+ "Keyboard control:",
+ "",
+ "Esc, Enter, Q - quit spiv",
+ "",
+ "< or KP Minus - zoom out by 1.5",
+ "> or KP Plus - zoom in by 1.5",
+ "R - rotate by 90 degrees clockwise",
+ "Up, Down, Left, Right - move image by 1px",
+ " (by 10 with Shift)",
+ "",
+ "Space - move to the next image",
+ "BackSpace - move to the prev image",
+ "PgDown - move to the start of directory",
+ "PgUp - move to the end of directory",
+ "Home - move to the first image",
+ "End - move to the last image",
+ "",
+ "I - toggle show info box",
+ "P - toggle show progress",
+ "",
+ "] - change to next resampling method",
+ "[ - change to prev resampling method",
+ " (current method is shown in info box)",
+ "L - toggle low pass filter",
+ "D - drop image cache",
+ "H - toggle help",
+ "",
+ "F1-F10 - execute action 0 - 9",
+ "",
+ "1 - resize spiv window to the image size",
+ "1 - resize spiv window to the image size",
+ "2 - resize spiv window to the half of the image size",
+ "3 - resize spiv window to the third of the image size",
+ "...",
+ "9 - resize spiv window to the ninth 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",
+ "...",
+};
+
+static const int keys_help_len = sizeof(keys_help) / sizeof(char*);
+
+void print_help(void)
+{
+ int i;
+
+ printf("Usage: spiv [opts] images or dirs with imagesnn");
+ printf(" -I show image info boxn");
+ printf(" -P show loading progressn");
+ printf(" -f use floyd-steinberg ditheringn");
+ printf(" -s sec sleep interval in secondsn");
+ printf(" -c turns on bicubic resampling (experimental)n");
+ printf(" -e pixel_type turns on backend type emulationn");
+ printf(" for example -e G1 sets 1-bit grayscalen");
+ printf(" -r angle rotate display 90,180 or 270 degreesn");
+ printf(" -z moden");
+ printf(" -zf zoom is set and modified by usern");
+ printf(" -zw zoom is fixed to window size (currently default)n");
+ printf(" -b pass backend init string to backend initn");
+ printf(" pass -b help for more infon");
+ puts("n");
+ printf("Actions:nn");
+ printf(" -0 'cmd' sets first actionn");
+ printf(" -1 'cmd' sets second actionn");
+ printf(" ...n");
+ printf(" -9 'cmd' sets tenth actionn");
+ puts("");
+ printf(" actions are shell commands with following modifiers:n");
+ printf(" %%f path to current imagen");
+ printf(" %%F shell escaped path to current imagen");
+ printf(" %%n current image filename without extensionn");
+ printf(" %%N shell escaped image filename without extensionn");
+ printf(" %%e current image file extensionn");
+ puts("n");
+
+ for (i = 0; i < keys_help_len; i++)
+ puts(keys_help[i]);
+
+ puts("");
+
+ printf("Some cool options to try:nn");
+ printf("spiv -0 'cp %%F sorted' [images]n");
+ printf("tcopies current image into directory 'sorted/' on F1n");
+ printf("spiv -e G1 -f [images]n");
+ printf("truns spiv in 1-bit bitmap mode and turns on ditheringnn");
+ printf("spiv -b 'X11:ROOT_WIN' [images]n");
+ printf("truns spiv using X root window as backend windownn");
+ printf("spiv -b 'X11:CREATE_ROOT' [images]n");
+ printf("tSame as abowe but works in KDEn");
+
+}
+
+void draw_help(GP_Backend *backend)
+{
+ GP_Context *c = backend->context;
+ GP_Pixel black = GP_ColorToContextPixel(GP_COL_BLACK, c);
+ GP_Pixel white = GP_ColorToContextPixel(GP_COL_WHITE, c);
+ int i;
+
+ GP_Fill(c, black);
+
+ for (i = 0; i < keys_help_len; i++) {
+ GP_Print(c, NULL, 20, 2 + i * 15, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ white, black, "%s", keys_help[i]);
+ }
+
+ GP_BackendFlip(backend);
+
+ for (;;) {
+ GP_Event ev;
+
+ while (GP_BackendWaitEvent(backend, &ev)) {
+ switch (ev.type) {
+ case GP_EV_KEY:
+ if (ev.code != GP_EV_KEY_DOWN)
+ continue;
+
+ switch (ev.val.key.key) {
+ default:
+ return;
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/demos/spiv/spiv_help.h b/demos/spiv/spiv_help.h
new file mode 100644
index 0000000..ed8c6b6
--- /dev/null
+++ b/demos/spiv/spiv_help.h
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * 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 __SPIV_HELP_H__
+#define __SPIV_HELP_H__
+
+/*
+ * Prints help into stderr
+ */
+void print_help(void);
+
+/*
+ * Draws help, waits for keypress.
+ */
+void draw_help(GP_Backend *backend);
+
+#endif /* __SPIV_HELP_H__ */
http://repo.or.cz/w/gfxprim.git/commit/752688c98757d2c59dac433cfdfebc645d9a…
commit 752688c98757d2c59dac433cfdfebc645d9a360c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 26 16:15:59 2013 +0200
tests: core: Convert: Remove the gray code.
It's not working and parts of the code causes python errors with
floating point vs. int params to hex().
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t
index cc58162..3c418b0 100644
--- a/tests/core/Convert.gen.c.t
+++ b/tests/core/Convert.gen.c.t
@@ -102,58 +102,6 @@ static GP_Pixel get_white(GP_PixelType pixel_type)
}
/*
- * Returns 50% gray color for particular pixel type.
- */
-GP_Pixel get_gray(GP_PixelType pixel_type)
-{
- switch (pixel_type) {
-%% for pt in pixeltypes
- case {{ pt.C_enum }}:
-%% if pt.is_cmyk()
-%% set K = pt.chans['K']
- /* Gray in CMYK modifies K */
- return {{ hex(round(K.max / 2.00)) }}{{ K.C_shift }};
-%% elif pt.is_rgb()
-%% set R = pt.chans['R']
-%% set G = pt.chans['G']
-%% set B = pt.chans['B']
-%% if pt.is_alpha()
-%% set A = pt.chans['A']
- /* Gray in RGBA */
- return {{ A.C_mask }} |
- ({{ hex(round(R.max / 2.00)) }}{{ R.C_shift }}) |
- ({{ hex(round(G.max / 2.00)) }}{{ G.C_shift }}) |
- ({{ hex(round(B.max / 2.00)) }}{{ B.C_shift }});
-%% else
- /* Gray Plain old RGB */
- return ({{ hex(round(R.max / 2.00)) }}{{ R.C_shift }}) |
- ({{ hex(round(G.max / 2.00)) }}{{ G.C_shift }}) |
- ({{ hex(round(B.max / 2.00)) }}{{ B.C_shift }});
-%% endif
-%% elif pt.is_gray()
-%% set V = pt.chans['V']
-%% if pt.is_alpha()
-%% set A = pt.chans['A']
- /* Gray in Grayscale with Alpha */
- return {{ A.C_mask }} |
- ({{ hex(round(V.max / 2.00)) }}{{ V.C_shift }});
-%% else
- /* Grayscale */
- return {{ hex(round(V.max / 2.00)) }}{{ V.C_shift }};
-%% endif
-%% else
- tst_msg("FIXME: Unsupported conversion to %s",
- GP_PixelTypeName(pixel_type));
- exit(TST_INTERR);
-%% endif
-%% endfor
- default:
- tst_msg("Invalid pixel type %i", pixel_type);
- exit(TST_INTERR);
- }
-}
-
-/*
* Returns red color for particular pixel type.
*/
static GP_Pixel get_red(GP_PixelType pixel_type)
@@ -233,15 +181,6 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi
{{ gen_convert_and_check('black', pt1.name, 'RGBA8888') }}
{{ gen_convert_and_check('black', 'RGB888', pt1.name) }}
{{ gen_convert_and_check('black', 'RGBA8888', pt1.name) }}
-{#- Grayscale -#}
-{#
-%% if pt1.name not in ['G1']
-{{ gen_convert_and_check('gray', pt1.name, 'RGB888') }}
-{{ gen_convert_and_check('gray', pt1.name, 'RGBA8888') }}
-%% endif
-{{ gen_convert_and_check('gray', 'RGB888', pt1.name) }}
-{{ gen_convert_and_check('gray', 'RGBA8888', pt1.name) }}
-#}
{#- Red -#}
%% if not pt1.is_gray()
{{ gen_convert_and_check('red', pt1.name, 'RGB888') }}
@@ -277,15 +216,6 @@ const struct tst_suite tst_suite = {
{{ gen_suite_entry('black', pt1.name, 'RGBA8888') }}
{{ gen_suite_entry('black', 'RGB888', pt1.name) }}
{{ gen_suite_entry('black', 'RGBA8888', pt1.name) }}
-{#- Gray -#}
-{#
-%% if pt1.name not in ['G1']
-{{ gen_suite_entry('gray', pt1.name, 'RGB888') }}
-{{ gen_suite_entry('gray', pt1.name, 'RGBA8888') }}
-%% endif
-{{ gen_suite_entry('gray', 'RGB888', pt1.name) }}
-{{ gen_suite_entry('gray', 'RGBA8888', pt1.name) }}
-#}
{#- Red -#}
%% if not pt1.is_gray()
{{ gen_suite_entry('red', pt1.name, 'RGB888') }}
http://repo.or.cz/w/gfxprim.git/commit/8a5b220d6f33c0d69f32b1d9566c32909667…
commit 8a5b220d6f33c0d69f32b1d9566c32909667278b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 26 16:12:05 2013 +0200
core: Convert: Fix swig syntax error.
Rewrite the code not to include the "/" string which breaks some swig
versions with syntax error on input (although the code is correct).
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t
index 6f1c123..22a3795 100644
--- a/include/core/GP_Convert.gen.h.t
+++ b/include/core/GP_Convert.gen.h.t
@@ -90,8 +90,7 @@
%% endif
GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, (({{ c2.C_max }} * ({{ K.C_max }} - GP_GET_BITS({{ K.off }}+o1, {{ K.size }}, p1)) * - ({{ V.C_max }} - GP_GET_BITS({{ V.off }}+o1, {{ V.size }}, p1)))) /- ({{ K.C_max }} * {{ V.C_max }})); + ({{ V.C_max }} - GP_GET_BITS({{ V.off }}+o1, {{ V.size }}, p1)))) / ({{ K.C_max }} * {{ V.C_max }})); {# case 7: invalid mapping -#}
%% else
{{ error('Channel conversion ' + pt1.name + ' to ' + pt2.name + ' not supported.') }}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/Makefile | 2 +-
demos/spiv/spiv.c | 120 +-------------
demos/spiv/spiv_help.c | 214 ++++++++++++++++++++++++
demos/{c_simple/version.c => spiv/spiv_help.h} | 21 +--
doc/backends.txt | 30 ++++
doc/event_queue.txt | 27 +++-
include/backends/GP_Backend.h | 10 +
include/core/GP_Convert.gen.h.t | 3 +-
include/input/GP_EventQueue.h | 10 +
libs/input/GP_EventQueue.c | 33 ++++
pylib/gfxprim/backends/_extend_backend.py | 17 ++-
tests/core/Convert.gen.c.t | 70 --------
12 files changed, 354 insertions(+), 203 deletions(-)
create mode 100644 demos/spiv/spiv_help.c
copy demos/{c_simple/version.c => spiv/spiv_help.h} (89%)
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
24 May '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 a75d7240e0224f992b9cb7895af24aeae8409728 (commit)
via 7d6d8b84a65ca1f2ef24ae1ffc4695618557b075 (commit)
via cb64272eaa3935181c791dac700ae656bd57c4dd (commit)
from 065f3db1028b2a0fecbfba71927b30198b332472 (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/a75d7240e0224f992b9cb7895af24aeae840…
commit a75d7240e0224f992b9cb7895af24aeae8409728
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 24 13:59:16 2013 +0200
core: Convert: Fix rounding error on CMYK to RGB.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t
index 72c974b..6f1c123 100644
--- a/include/core/GP_Convert.gen.h.t
+++ b/include/core/GP_Convert.gen.h.t
@@ -89,9 +89,9 @@
%% set V = pt1.chans['Y']
%% endif
GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2,- GP_SCALE_VAL_{{ K.size + V.size }}_{{ c2.size }}(- (({{ K.C_max }} - GP_GET_BITS({{ K.off }}+o1, {{ K.size }}, p1)) * - ({{ V.C_max }} - GP_GET_BITS({{ V.off }}+o1, {{ V.size }}, p1))))); + (({{ c2.C_max }} * ({{ K.C_max }} - GP_GET_BITS({{ K.off }}+o1, {{ K.size }}, p1)) * + ({{ V.C_max }} - GP_GET_BITS({{ V.off }}+o1, {{ V.size }}, p1)))) /+ ({{ K.C_max }} * {{ V.C_max }})); {# case 7: invalid mapping -#}
%% else
{{ error('Channel conversion ' + pt1.name + ' to ' + pt2.name + ' not supported.') }}
http://repo.or.cz/w/gfxprim.git/commit/7d6d8b84a65ca1f2ef24ae1ffc4695618557…
commit 7d6d8b84a65ca1f2ef24ae1ffc4695618557b075
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 24 12:40:14 2013 +0200
tests: core: Convert: Comment out gray in tests.
The upscaling is not precise by definition.
I will have to change the code to compute acceptable
delta given the value and input and output size in
order to make it work.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t
index 57bc4d2..cc58162 100644
--- a/tests/core/Convert.gen.c.t
+++ b/tests/core/Convert.gen.c.t
@@ -104,7 +104,7 @@ static GP_Pixel get_white(GP_PixelType pixel_type)
/*
* Returns 50% gray color for particular pixel type.
*/
-static GP_Pixel get_gray(GP_PixelType pixel_type)
+GP_Pixel get_gray(GP_PixelType pixel_type)
{
switch (pixel_type) {
%% for pt in pixeltypes
@@ -234,12 +234,14 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi
{{ gen_convert_and_check('black', 'RGB888', pt1.name) }}
{{ gen_convert_and_check('black', 'RGBA8888', pt1.name) }}
{#- Grayscale -#}
+{#
%% if pt1.name not in ['G1']
{{ gen_convert_and_check('gray', pt1.name, 'RGB888') }}
{{ gen_convert_and_check('gray', pt1.name, 'RGBA8888') }}
%% endif
{{ gen_convert_and_check('gray', 'RGB888', pt1.name) }}
{{ gen_convert_and_check('gray', 'RGBA8888', pt1.name) }}
+#}
{#- Red -#}
%% if not pt1.is_gray()
{{ gen_convert_and_check('red', pt1.name, 'RGB888') }}
@@ -276,12 +278,14 @@ const struct tst_suite tst_suite = {
{{ gen_suite_entry('black', 'RGB888', pt1.name) }}
{{ gen_suite_entry('black', 'RGBA8888', pt1.name) }}
{#- Gray -#}
+{#
%% if pt1.name not in ['G1']
{{ gen_suite_entry('gray', pt1.name, 'RGB888') }}
{{ gen_suite_entry('gray', pt1.name, 'RGBA8888') }}
%% endif
{{ gen_suite_entry('gray', 'RGB888', pt1.name) }}
{{ gen_suite_entry('gray', 'RGBA8888', pt1.name) }}
+#}
{#- Red -#}
%% if not pt1.is_gray()
{{ gen_suite_entry('red', pt1.name, 'RGB888') }}
http://repo.or.cz/w/gfxprim.git/commit/cb64272eaa3935181c791dac700ae656bd57…
commit cb64272eaa3935181c791dac700ae656bd57c4dd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 24 11:51:38 2013 +0200
core: Convert_Scale: Limit conversions to 16 bits.
This limits the conversions on output to 16 bits in order not to cause
overflows.
The code is also cleaned up a little.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Convert_Scale.gen.h.t b/include/core/GP_Convert_Scale.gen.h.t
index 9261a90..497fea7 100644
--- a/include/core/GP_Convert_Scale.gen.h.t
+++ b/include/core/GP_Convert_Scale.gen.h.t
@@ -26,7 +26,7 @@
{% block descr %}Fast value scaling macros{% endblock %}
{% macro multcoef(s1, s2) -%}
-(0{% for i in range((s2 + s1 - 1) // s1) %}+{{ 2 ** (i * s1) }}{% endfor %})
+(0{% for i in range((s2 + s1 - 1) // s1) %}+{{ hex(2 ** (i * s1)) }}{% endfor %})
{%- endmacro %}
%% block body
@@ -35,17 +35,16 @@
* Efficient and accurate for both up- and downscaling.
* WARNING: GP_SCALE_VAL requires constants numbers as first two parameters
*/
-
#define GP_SCALE_VAL(s1, s2, val) ( GP_SCALE_VAL_##s1##_##s2(val) )
%% for s1 in range(1,33)
-%% for s2 in range(1,33)
-%% if s2>s1
+%% for s2 in range(1,17)
+%% if s2 > s1
#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) (((val) * {{ multcoef(s1, s2) }}) >> {{ (-s2) % s1 }})
-%% else
+%% else
#define GP_SCALE_VAL_{{s1}}_{{s2}}(val) ((val) >> {{ s1 - s2 }})
-%% endif
-%% endfor
+%% endif
+%% endfor
%% endfor
%% endblock body
diff --git a/tests/core/Convert_Scale.gen.c.t b/tests/core/Convert_Scale.gen.c.t
index a3ce1b5..8e67da4 100644
--- a/tests/core/Convert_Scale.gen.c.t
+++ b/tests/core/Convert_Scale.gen.c.t
@@ -26,18 +26,21 @@
#include <stdio.h>
#include <math.h>
+#include <stdint.h>
#include <core/GP_Convert_Scale.gen.h>
#include "tst_test.h"
-%% set max = 16
+%% set max_in = 24
+%% set max_out = 16
-%% for i in range(1, max)
-%% for j in range(1, max)
+%% for i in range(1, max_in)
+%% for j in range(1, max_out)
static int check_convert_{{ i }}_{{ j }}(void)
{
- unsigned int v, res, exp_res, fail = 0;
+ unsigned int v, fail = 0;
+ uint32_t res, exp_res;
float fres;
for (v = 0; v < {{ 2 ** i - 1 }}; v++) {
@@ -90,8 +93,8 @@ static int check_convert_{{ i }}_{{ j }}(void)
const struct tst_suite tst_suite = {
.suite_name = "Pixel Conversions Testsuite",
.tests = {
-%% for i in range(1, max)
-%% for j in range(1, max)
+%% for i in range(1, max_in)
+%% for j in range(1, max_out)
{.name = "SCALE_{{ i }}_{{ j }}()",
.tst_fn = check_convert_{{ i }}_{{ j }}},
%% endfor
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Convert.gen.h.t | 6 +++---
include/core/GP_Convert_Scale.gen.h.t | 13 ++++++-------
tests/core/Convert.gen.c.t | 6 +++++-
tests/core/Convert_Scale.gen.c.t | 15 +++++++++------
4 files changed, 23 insertions(+), 17 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
22 May '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 065f3db1028b2a0fecbfba71927b30198b332472 (commit)
from a9676bd9397ba4a939a11341c66f7fba6a8293a5 (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/065f3db1028b2a0fecbfba71927b30198b33…
commit 065f3db1028b2a0fecbfba71927b30198b332472
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 21 23:48:54 2013 +0200
spiv: Cleanup and update help.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 5e0352e..8c77fff 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -717,8 +717,8 @@ static const char *keys_help[] = {
"",
"Esc, Enter, Q - quit spiv",
"",
- "< KP Minus - zoom out by 1.5",
- ">, KP Plus - zoom in by 1.5",
+ "< or KP Minus - zoom out by 1.5",
+ "> or KP Plus - zoom in by 1.5",
"R - rotate by 90 degrees clockwise",
"Up, Down, Left, Right - move image by 1px",
" (by 10 with Shift)",
@@ -760,26 +760,26 @@ static void print_help(void)
{
int i;
- printf("Usage: spiv [opts] imagesnn");
- printf("-Intshow image info (filename and size)nn");
- printf("-Pntshow loading progressnn");
- printf("-fntuse floyd-steinberg ditheringnn");
- printf("-s secntsleep interval in secondsnn");
- printf("-cntturns on bicubic resampling (experimental)nn");
- printf("-d levelntsets GFXprim debug levelnn");
- printf("-e pixel_typentturns on backend type emulationn");
- printf("tfor example -e G1 sets 1-bit grayscalenn");
- printf("-r anglentrotate display 90,180 or 270 degreesnn");
- printf("-z sets zoom modent-zf zoom is set and modified by usern");
- printf("t-zw zoom is fixed to window size (currently default)nn");
- printf("-bntpass backend init string to backend initn");
- printf("tpass -b help for more infonn");
- puts("");
- printf("Actionsn");
- printf("-0 'cmd' sets first actionn");
- printf("-1 'cmd' sets second actionn");
- printf("...n");
- printf("-9 'cmd' sets tenth actionn");
+ printf("Usage: spiv [opts] images or dirs with imagesnn");
+ printf(" -I show image info boxn");
+ printf(" -P show loading progressn");
+ printf(" -f use floyd-steinberg ditheringn");
+ printf(" -s sec sleep interval in secondsn");
+ printf(" -c turns on bicubic resampling (experimental)n");
+ printf(" -e pixel_type turns on backend type emulationn");
+ printf(" for example -e G1 sets 1-bit grayscalen");
+ printf(" -r angle rotate display 90,180 or 270 degreesn");
+ printf(" -z moden");
+ printf(" -zf zoom is set and modified by usern");
+ printf(" -zw zoom is fixed to window size (currently default)n");
+ printf(" -b pass backend init string to backend initn");
+ printf(" pass -b help for more infon");
+ puts("n");
+ printf("Actions:nn");
+ printf(" -0 'cmd' sets first actionn");
+ printf(" -1 'cmd' sets second actionn");
+ printf(" ...n");
+ printf(" -9 'cmd' sets tenth actionn");
puts("");
printf(" actions are shell commands with following modifiers:n");
printf(" %%f path to current imagen");
@@ -787,7 +787,7 @@ static void print_help(void)
printf(" %%n current image filename without extensionn");
printf(" %%N shell escaped image filename without extensionn");
printf(" %%e current image file extensionn");
- puts("");
+ puts("n");
for (i = 0; i < keys_help_len; i++)
puts(keys_help[i]);
@@ -795,13 +795,13 @@ static void print_help(void)
puts("");
printf("Some cool options to try:nn");
- printf("spiv -0 'cp %%F sorted/");
+ printf("spiv -0 'cp %%F sorted' [images]n");
printf("tcopies current image into directory 'sorted/' on F1n");
- printf("spiv -e G1 -f imagesn");
+ printf("spiv -e G1 -f [images]n");
printf("truns spiv in 1-bit bitmap mode and turns on ditheringnn");
- printf("spiv -b 'X11:ROOT_WIN' imagesn");
+ printf("spiv -b 'X11:ROOT_WIN' [images]n");
printf("truns spiv using X root window as backend windownn");
- printf("spiv -b 'X11:CREATE_ROOT' imagesn");
+ printf("spiv -b 'X11:CREATE_ROOT' [images]n");
printf("tSame as abowe but works in KDEn");
}
@@ -825,7 +825,7 @@ int main(int argc, char *argv[])
GP_Context *context = NULL;
const char *backend_opts = "X11";
int sleep_sec = -1;
- int opt, debug_level = 0;
+ int opt;
int shift_flag, help_flag = 0;
GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
@@ -847,7 +847,7 @@ int main(int argc, char *argv[])
.img_orig_cache = NULL,
};
- while ((opt = getopt(argc, argv, "b:cd:e:fhIPs:r:z:0:1:2:3:4:5:6:7:8:9:")) != -1) {
+ while ((opt = getopt(argc, argv, "b:ce:fhIPs:r:z:0:1:2:3:4:5:6:7:8:9:")) != -1) {
switch (opt) {
case 'I':
params.show_info = 1;
@@ -868,9 +868,6 @@ int main(int argc, char *argv[])
/* Cubic resampling is slow, show nn first */
params.show_nn_first = 1;
break;
- case 'd':
- debug_level = atoi(optarg);
- break;
case 'e':
emul_type = GP_PixelTypeByName(optarg);
@@ -919,8 +916,6 @@ int main(int argc, char *argv[])
return 1;
}
- GP_SetDebugLevel(debug_level);
-
signal(SIGINT, sighandler);
signal(SIGSEGV, sighandler);
signal(SIGBUS, sighandler);
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 63 ++++++++++++++++++++++++----------------------------
1 files changed, 29 insertions(+), 34 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
21 May '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 a9676bd9397ba4a939a11341c66f7fba6a8293a5 (commit)
from 144f51ced0bc1c933d15917578e99f6615afc6f9 (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/a9676bd9397ba4a939a11341c66f7fba6a82…
commit a9676bd9397ba4a939a11341c66f7fba6a8293a5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 21 23:30:28 2013 +0200
spiv: Cleanup the progress callback.
Cleanup the code a little, draw better progress.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 87f2e26..5e0352e 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -43,6 +43,7 @@
static GP_Pixel black_pixel;
static GP_Pixel white_pixel;
+static GP_Pixel gray_pixel;
static GP_Backend *backend = NULL;
@@ -123,17 +124,21 @@ static int image_loader_callback(GP_ProgressCallback *self)
(const char*)self->priv, self->percentage);
int align = GP_ALIGN_CENTER|GP_VALIGN_ABOVE;
+
+ size = GP_TextWidth(NULL, buf);
- GP_TextClear(c, NULL, c->w/2, c->h - 4, align,
- black_pixel, GP_MAX(size, GP_TextWidth(NULL, buf)));
+ int start = c->w/2 - size/2 - 10;
+ int end = c->w/2 + size/2 + 10;
+ int middle = start + (end - start) * self->percentage / 100;
+ int top = c->h - GP_TextHeight(NULL) - 11;
- GP_Text(c, NULL, c->w/2, c->h - 4, align,
- white_pixel, black_pixel, buf);
+ GP_FillRectXYXY(c, start, c->h - 1, middle, top, gray_pixel);
+ GP_FillRectXYXY(c, middle, c->h - 1, end, top, black_pixel);
- size = GP_TextWidth(NULL, buf);
+ GP_Text(c, NULL, c->w/2, c->h - 5, align,
+ white_pixel, black_pixel, buf);
- GP_BackendUpdateRect(backend, c->w/2 - size/2 - 1, c->h - 4,
- c->w/2 + size/2 + 1, c->h - 4 - GP_TextHeight(NULL));
+ GP_BackendUpdateRect(backend, start, c->h - 1, end, top);
return 0;
}
@@ -932,6 +937,7 @@ int main(int argc, char *argv[])
black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context);
white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context);
+ gray_pixel = GP_RGBToContextPixel(0x33, 0x33, 0x33, context);
GP_Fill(context, black_pixel);
GP_BackendFlip(backend);
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 20 +++++++++++++-------
1 files changed, 13 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
21 May '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 144f51ced0bc1c933d15917578e99f6615afc6f9 (commit)
from f7cb41744ef49b26625e2c6c9e7deb64a6ba0018 (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/144f51ced0bc1c933d15917578e99f6615af…
commit 144f51ced0bc1c933d15917578e99f6615afc6f9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 21 22:33:39 2013 +0200
spiv: Add image actions.
Image actions are shell snippets with printf-like formating
characters (for image path, name, etc...) to be executed when
key is pressed in spiv (currently mapped on F1-F10).
BEWARE: it seems to work, but I haven't tested all corner cases.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/Makefile b/demos/spiv/Makefile
index c6747d2..52ba4ec 100644
--- a/demos/spiv/Makefile
+++ b/demos/spiv/Makefile
@@ -10,7 +10,7 @@ LDLIBS+=$(LDLIBS_LOADERS) $(LDLIBS_BACKENDS)
APPS=spiv
-spiv: cpu_timer.o image_cache.o image_list.o
+spiv: cpu_timer.o image_cache.o image_list.o image_actions.o
include $(TOPDIR)/pre.mk
include $(TOPDIR)/app.mk
diff --git a/demos/spiv/image_actions.c b/demos/spiv/image_actions.c
new file mode 100644
index 0000000..de35255
--- /dev/null
+++ b/demos/spiv/image_actions.c
@@ -0,0 +1,331 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+ /*
+
+ Image Actions.
+
+ Image action is an arbitrary command with printf-like syntax for image name,
+ format and path.
+
+ %f - image path
+ %F - shell escaped path
+
+ %e - file extension
+
+ %n - image name (without extension)
+ %N - escaped image name (without extension)
+
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#define ACTION_MAX 10u
+
+struct action_param {
+ char type;
+ int pos;
+};
+
+struct action {
+ char *cmd;
+ unsigned int param_cnt;
+ struct action_param params[];
+};
+
+static struct action *actions[ACTION_MAX];
+
+static int find_modifiers(const char *cmd, struct action_param *params)
+{
+ int i, flag = 0, mod_cnt = 0;
+
+ /* validate action command and count modifiers */
+ for (i = 0; cmd[i]; i++) {
+ if (flag) {
+ switch (cmd[i]) {
+ case 'f':
+ case 'F':
+ case 'n':
+ case 'N':
+ case 'e':
+ if (params) {
+ params[mod_cnt].type = cmd[i];
+ params[mod_cnt].pos = i;
+ }
+ mod_cnt++;
+ break;
+ case '%':
+ break;
+ default:
+ fprintf(stderr, "Invalid action modifier %%%c",
+ cmd[i]);
+ return -1;
+ }
+ flag = 0;
+ } else {
+ if (cmd[i] == '%')
+ flag = 1;
+ }
+ }
+
+ return mod_cnt;
+}
+
+int image_action_set(unsigned int action, const char *cmd)
+{
+ char *cmd_dup;
+ int mod_cnt;
+
+ if (action > ACTION_MAX) {
+ fprintf(stderr, "Invalid action slot %u, ACTION_MAX = %un",
+ action, ACTION_MAX);
+ return 1;
+ }
+
+ mod_cnt = find_modifiers(cmd, NULL);
+
+ if (mod_cnt < 0)
+ return 1;
+
+ if (actions[action]) {
+ free(actions[action]->cmd);
+ free(actions[action]);
+ }
+
+ action[actions] = malloc(sizeof(struct action) +
+ sizeof(struct action_param) * mod_cnt);
+ cmd_dup = strdup(cmd);
+
+ if (!actions[action] || !cmd_dup) {
+ free(actions[action]);
+ free(cmd_dup);
+ actions[action] = 0;
+ fprintf(stderr, "Failed to strdup() commandn");
+ return 1;
+ }
+
+ action[actions]->cmd = cmd_dup;
+ action[actions]->param_cnt = mod_cnt;
+ find_modifiers(cmd_dup, action[actions]->params);
+
+ return 0;
+}
+
+static size_t get_name_ext(const char *path,
+ const char **name, const char **extension)
+{
+ int i, len = strlen(path);
+ size_t name_len = 0;
+
+ *name = NULL;
+ *extension = NULL;
+
+ for (i = len; i > 0; i--) {
+
+ if (*extension)
+ name_len++;
+
+ switch (path[i]) {
+ case '.':
+ if (!*extension)
+ *extension = &path[i+1];
+ break;
+ case '/':
+ if (!*name) {
+ *name = &path[i+1];
+ return name_len - 1;
+ }
+ break;
+ }
+ }
+
+ *name = path;
+
+ if (*extension)
+ return name_len - 1;
+
+ return name_len;
+}
+
+static int escape(const char *name, size_t name_len,
+ char *buf, size_t buf_len)
+{
+ unsigned int i, j = 0;
+
+ buf[0] = ''';
+
+ for (i = 1; j < name_len && i + 2 < buf_len; j++) {
+ switch (name[j]) {
+ case ''':
+ if (i + 5 < buf_len)
+ return -1;
+
+ buf[i++] = ''';
+ buf[i++] = '"';
+ buf[i++] = ''';
+ buf[i++] = '"';
+ buf[i++] = ''';
+ break;
+ default:
+ buf[i++] = name[j];
+ }
+ }
+
+ buf[i] = ''';
+ buf[++i] = '0';
+
+ return i;
+}
+
+/* Global cmd buffer */
+static char *cmd = NULL;
+static size_t cmd_size;
+static size_t cmd_pos;
+
+static int cmd_append(const char *str, size_t len)
+{
+ if (len == 0)
+ len = strlen(str);
+
+ /* Initial allocation size */
+ if (!cmd) {
+ cmd = malloc(1024);
+ cmd_size = 1024;
+ }
+
+ if (!cmd) {
+ fprintf(stderr, "Failed to allocated command buffern");
+ return 1;
+ }
+
+ if (cmd_size - cmd_pos <= len) {
+ char *new_cmd = realloc(cmd, cmd_size + 1024);
+
+ if (new_cmd == NULL) {
+ fprintf(stderr, "Failed to allocated command buffern");
+ return 1;
+ }
+ }
+
+ memcpy(cmd + cmd_pos, str, len);
+ cmd_pos += len;
+ cmd[cmd_pos] = '0';
+
+ return 0;
+}
+
+static int cmd_append_escape(const char *str, size_t len)
+{
+ int ret;
+
+ if (len == 0)
+ len = strlen(str);
+
+ while ((ret = escape(str, len, cmd + cmd_pos, cmd_size - cmd_pos)) < 0) {
+ char *new_cmd = realloc(cmd, cmd_size + 1024);
+
+ if (new_cmd == NULL) {
+ fprintf(stderr, "Failed to allocated command buffern");
+ return 1;
+ }
+ }
+
+ cmd_pos += ret;
+
+ return 0;
+}
+
+static void cmd_reset(void)
+{
+ cmd_pos = 0;
+}
+
+static int prepare_cmd(unsigned int action, const char *img_path)
+{
+ const char *img_name;
+ const char *img_extension;
+ unsigned int i, name_len;
+
+ name_len = get_name_ext(img_path, &img_name, &img_extension);
+
+ cmd_reset();
+
+ char *prev = actions[action]->cmd;
+ size_t len;
+
+ for (i = 0; i < actions[action]->param_cnt; i++) {
+ len = actions[action]->params[i].pos;
+
+ if (i > 0)
+ len -= actions[action]->params[i - 1].pos + 1;
+
+ if (cmd_append(prev, len - 1))
+ return 1;
+
+ switch (actions[action]->params[i].type) {
+ case 'f':
+ cmd_append(img_path, 0);
+ break;
+ case 'F':
+ cmd_append_escape(img_path, 0);
+ break;
+ case 'e':
+ cmd_append(img_extension, 0);
+ break;
+ case 'n':
+ cmd_append(img_name, name_len);
+ break;
+ case 'N':
+ cmd_append_escape(img_name, name_len);
+ break;
+ }
+
+ prev += len + 1;
+ }
+
+ cmd_append(prev, 0);
+
+ return 0;
+}
+
+int image_action_run(unsigned int action, const char *img_path)
+{
+ if (!actions[action]) {
+ fprintf(stderr, "Undefined action %un", action);
+ return 1;
+ }
+
+ if (prepare_cmd(action, img_path))
+ return 1;
+
+ printf("Executing cmd "%s"n", cmd);
+
+ if (system(cmd)) {
+ fprintf(stderr, "Failed to execute cmd '%s': %s", cmd, strerror(errno));
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/demos/spiv/image_actions.h b/demos/spiv/image_actions.h
new file mode 100644
index 0000000..b03fbb1
--- /dev/null
+++ b/demos/spiv/image_actions.h
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+ /*
+
+ Image Actions.
+
+ Image action is an arbitrary command with printf-like syntax for image name,
+ format and path.
+
+ %f - image path
+ %F - shell escaped path
+
+ %n - image name
+ %N - escaped image name
+
+ */
+
+#ifndef __IMAGE_ACTIONS_H__
+#define __IMAGE_ACTIONS_H__
+
+void image_action_set(unsigned int action, const char *cmd);
+
+int image_action_run(unsigned int action, const char *img_path);
+
+#endif /* __IMAGE_ACTIONS_H__ */
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 93dd301..87f2e26 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -38,6 +38,7 @@
#include "image_cache.h"
#include "image_list.h"
+#include "image_actions.h"
#include "cpu_timer.h"
static GP_Pixel black_pixel;
@@ -734,6 +735,9 @@ static const char *keys_help[] = {
"D - drop image cache",
"H - toggle help",
"",
+ "F1-F10 - execute action 0 - 9",
+ "",
+ "1 - resize spiv window to the image size",
"1 - resize spiv window to the image size",
"2 - resize spiv window to the half of the image size",
"3 - resize spiv window to the third of the image size",
@@ -765,20 +769,35 @@ static void print_help(void)
printf("t-zw zoom is fixed to window size (currently default)nn");
printf("-bntpass backend init string to backend initn");
printf("tpass -b help for more infonn");
-
+ puts("");
+ printf("Actionsn");
+ printf("-0 'cmd' sets first actionn");
+ printf("-1 'cmd' sets second actionn");
+ printf("...n");
+ printf("-9 'cmd' sets tenth actionn");
+ puts("");
+ printf(" actions are shell commands with following modifiers:n");
+ printf(" %%f path to current imagen");
+ printf(" %%F shell escaped path to current imagen");
+ printf(" %%n current image filename without extensionn");
+ printf(" %%N shell escaped image filename without extensionn");
+ printf(" %%e current image file extensionn");
+ puts("");
+
for (i = 0; i < keys_help_len; i++)
puts(keys_help[i]);
puts("");
printf("Some cool options to try:nn");
+ printf("spiv -0 'cp %%F sorted/");
+ printf("tcopies current image into directory 'sorted/' on F1n");
printf("spiv -e G1 -f imagesn");
printf("truns spiv in 1-bit bitmap mode and turns on ditheringnn");
printf("spiv -b 'X11:ROOT_WIN' imagesn");
printf("truns spiv using X root window as backend windownn");
printf("spiv -b 'X11:CREATE_ROOT' imagesn");
printf("tSame as abowe but works in KDEn");
-
}
static void show_help(void)
@@ -823,7 +842,7 @@ int main(int argc, char *argv[])
.img_orig_cache = NULL,
};
- while ((opt = getopt(argc, argv, "b:cd:e:fhIPs:r:z:")) != -1) {
+ while ((opt = getopt(argc, argv, "b:cd:e:fhIPs:r:z:0:1:2:3:4:5:6:7:8:9:")) != -1) {
switch (opt) {
case 'I':
params.show_info = 1;
@@ -879,6 +898,9 @@ int main(int argc, char *argv[])
break;
}
break;
+ case '0' ... '9':
+ image_action_set(opt - '0', optarg);
+ break;
default:
fprintf(stderr, "Invalid paramter '%c'n", opt);
print_help();
@@ -1132,6 +1154,10 @@ int main(int argc, char *argv[])
params.show_progress_once = 1;
zoom_mul(¶ms, 1/1.5);
break;
+ case GP_KEY_F1 ... GP_KEY_F10:
+ image_action_run(ev.val.key.key - GP_KEY_F1,
+ image_list_img_path(list));
+ break;
}
break;
case GP_EV_SYS:
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/Makefile | 2 +-
demos/spiv/image_actions.c | 331 ++++++++++++++++++++
.../GP_Version.h => demos/spiv/image_actions.h | 28 +-
demos/spiv/spiv.c | 32 ++-
4 files changed, 376 insertions(+), 17 deletions(-)
create mode 100644 demos/spiv/image_actions.c
copy include/core/GP_Version.h => demos/spiv/image_actions.h (79%)
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
19 May '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 f7cb41744ef49b26625e2c6c9e7deb64a6ba0018 (commit)
via 9962b69ac47d514051afb83b0942655ff9e76991 (commit)
from e596ea9912cfde653e3048e64d3a821328975f14 (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/f7cb41744ef49b26625e2c6c9e7deb64a6ba…
commit f7cb41744ef49b26625e2c6c9e7deb64a6ba0018
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 19 16:23:13 2013 +0200
tests: core: Add test for Convert_Scale operations
There are few failures that are caused by slightly
incorrect rounding on upsampling but these are not fatal.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/Convert_Scale.gen.c.t b/tests/core/Convert_Scale.gen.c.t
new file mode 100644
index 0000000..a3ce1b5
--- /dev/null
+++ b/tests/core/Convert_Scale.gen.c.t
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * 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 "base.test.c.t"
+
+%% block body
+
+#include <stdio.h>
+#include <math.h>
+
+#include <core/GP_Convert_Scale.gen.h>
+
+#include "tst_test.h"
+
+%% set max = 16
+
+%% for i in range(1, max)
+%% for j in range(1, max)
+static int check_convert_{{ i }}_{{ j }}(void)
+{
+ unsigned int v, res, exp_res, fail = 0;
+ float fres;
+
+ for (v = 0; v < {{ 2 ** i - 1 }}; v++) {
+ res = GP_SCALE_VAL_{{ i }}_{{ j }}(v);
+%% if j > i
+ /*
+ * We have {{ 2**i }} values and we need to map them to
+ * subset of {{ 2**j }} values while making sure 0 -> 0
+ * and {{ 2**i - 1 }} -> {{ 2**j - 1 }} and that the
+ * mapping is as evenly distributed as possible.
+ *
+ * So we map the input to 0-1 interval by dividing it by
+ * maximal input value {{ 2**i - 1 }} and then multiply
+ * it by output maximal value {{ 2**j - 1}}.
+ */
+ fres = (v / {{ (2.00 ** i - 1) }}) * {{ (2.00 ** j - 1) }};
+ exp_res = round(fres);
+%% else
+ /*
+ * We have {{ 2**i }} values that must be mapped to {{ 2**j }}
+ * so we do simple division and floor() which maps the values
+ * evenly, 0 -> 0 and {{ 2**i - 1 }} -> {{ 2**j - 1 }}.
+ *
+ * In terms for implementation this is just bitshift.
+ */
+ fres = v * {{ (2.00 ** j) / (2.00 ** i) }};
+ exp_res = floor(fres);
+%% endif
+
+ if (res != exp_res) {
+ if (fail < 5)
+ tst_msg("GP_SCALE_{{ i }}_{{ j }}(%i) = %i, "
+ "expected %i %f", v, res, exp_res, fres);
+ fail++;
+ }
+ }
+
+ if (fail) {
+ if (fail > 5)
+ tst_msg("+ next %u failures", fail - 5);
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+%% endfor
+%% endfor
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Pixel Conversions Testsuite",
+ .tests = {
+%% for i in range(1, max)
+%% for j in range(1, max)
+ {.name = "SCALE_{{ i }}_{{ j }}()",
+ .tst_fn = check_convert_{{ i }}_{{ j }}},
+%% endfor
+%% endfor
+ {.name = NULL}
+ }
+};
+
+%% endblock body
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 2c0d363..c770fc5 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -4,9 +4,11 @@ include $(TOPDIR)/pre.mk
CSOURCES=Context.c Pixel.c
-GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c Convert.gen.c BlitConv.gen.c
+GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c Convert.gen.c BlitConv.gen.c + Convert_Scale.gen.c
-APPS=WritePixel.gen Pixel Context GetPutPixel.gen Convert.gen BlitConv.gen
+APPS=WritePixel.gen Pixel Context GetPutPixel.gen Convert.gen BlitConv.gen + Convert_Scale.gen
include ../tests.mk
diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt
index 45702bb..3edab32 100644
--- a/tests/core/test_list.txt
+++ b/tests/core/test_list.txt
@@ -4,4 +4,5 @@ Context
Pixel
GetPutPixel.gen
Convert.gen
+Convert_Scale.gen
BlitConv.gen
http://repo.or.cz/w/gfxprim.git/commit/9962b69ac47d514051afb83b0942655ff9e7…
commit 9962b69ac47d514051afb83b0942655ff9e76991
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 18 12:50:15 2013 +0200
tests: core: Convert.gen.c: Add more cases.
Some of them fail, I'm not yet sure if these
are wrong tests of rounding errors in the
implementation.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t
index 84159f1..57bc4d2 100644
--- a/tests/core/Convert.gen.c.t
+++ b/tests/core/Convert.gen.c.t
@@ -102,6 +102,58 @@ static GP_Pixel get_white(GP_PixelType pixel_type)
}
/*
+ * Returns 50% gray color for particular pixel type.
+ */
+static GP_Pixel get_gray(GP_PixelType pixel_type)
+{
+ switch (pixel_type) {
+%% for pt in pixeltypes
+ case {{ pt.C_enum }}:
+%% if pt.is_cmyk()
+%% set K = pt.chans['K']
+ /* Gray in CMYK modifies K */
+ return {{ hex(round(K.max / 2.00)) }}{{ K.C_shift }};
+%% elif pt.is_rgb()
+%% set R = pt.chans['R']
+%% set G = pt.chans['G']
+%% set B = pt.chans['B']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Gray in RGBA */
+ return {{ A.C_mask }} |
+ ({{ hex(round(R.max / 2.00)) }}{{ R.C_shift }}) |
+ ({{ hex(round(G.max / 2.00)) }}{{ G.C_shift }}) |
+ ({{ hex(round(B.max / 2.00)) }}{{ B.C_shift }});
+%% else
+ /* Gray Plain old RGB */
+ return ({{ hex(round(R.max / 2.00)) }}{{ R.C_shift }}) |
+ ({{ hex(round(G.max / 2.00)) }}{{ G.C_shift }}) |
+ ({{ hex(round(B.max / 2.00)) }}{{ B.C_shift }});
+%% endif
+%% elif pt.is_gray()
+%% set V = pt.chans['V']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Gray in Grayscale with Alpha */
+ return {{ A.C_mask }} |
+ ({{ hex(round(V.max / 2.00)) }}{{ V.C_shift }});
+%% else
+ /* Grayscale */
+ return {{ hex(round(V.max / 2.00)) }}{{ V.C_shift }};
+%% endif
+%% else
+ tst_msg("FIXME: Unsupported conversion to %s",
+ GP_PixelTypeName(pixel_type));
+ exit(TST_INTERR);
+%% endif
+%% endfor
+ default:
+ tst_msg("Invalid pixel type %i", pixel_type);
+ exit(TST_INTERR);
+ }
+}
+
+/*
* Returns red color for particular pixel type.
*/
static GP_Pixel get_red(GP_PixelType pixel_type)
@@ -171,14 +223,24 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi
%% for pt1 in pixeltypes
%% if not pt1.is_unknown() and not pt1.is_palette()
%% if pt1.name not in ['RGB888', 'RGBA8888']
+{#- White -#}
{{ gen_convert_and_check('white', pt1.name, 'RGB888') }}
{{ gen_convert_and_check('white', pt1.name, 'RGBA8888') }}
{{ gen_convert_and_check('white', 'RGB888', pt1.name) }}
{{ gen_convert_and_check('white', 'RGBA8888', pt1.name) }}
+{#- Black -#}
{{ gen_convert_and_check('black', pt1.name, 'RGB888') }}
{{ gen_convert_and_check('black', pt1.name, 'RGBA8888') }}
{{ gen_convert_and_check('black', 'RGB888', pt1.name) }}
{{ gen_convert_and_check('black', 'RGBA8888', pt1.name) }}
+{#- Grayscale -#}
+%% if pt1.name not in ['G1']
+{{ gen_convert_and_check('gray', pt1.name, 'RGB888') }}
+{{ gen_convert_and_check('gray', pt1.name, 'RGBA8888') }}
+%% endif
+{{ gen_convert_and_check('gray', 'RGB888', pt1.name) }}
+{{ gen_convert_and_check('gray', 'RGBA8888', pt1.name) }}
+{#- Red -#}
%% if not pt1.is_gray()
{{ gen_convert_and_check('red', pt1.name, 'RGB888') }}
{{ gen_convert_and_check('red', pt1.name, 'RGBA8888') }}
@@ -203,14 +265,24 @@ const struct tst_suite tst_suite = {
%% for pt1 in pixeltypes
%% if not pt1.is_unknown() and not pt1.is_palette()
%% if pt1.name not in ['RGB888', 'RGBA8888']
+{#- White -#}
{{ gen_suite_entry('white', pt1.name, 'RGB888') }}
{{ gen_suite_entry('white', pt1.name, 'RGBA8888') }}
{{ gen_suite_entry('white', 'RGB888', pt1.name) }}
{{ gen_suite_entry('white', 'RGBA8888', pt1.name) }}
+{#- Black -#}
{{ gen_suite_entry('black', pt1.name, 'RGB888') }}
{{ gen_suite_entry('black', pt1.name, 'RGBA8888') }}
{{ gen_suite_entry('black', 'RGB888', pt1.name) }}
{{ gen_suite_entry('black', 'RGBA8888', pt1.name) }}
+{#- Gray -#}
+%% if pt1.name not in ['G1']
+{{ gen_suite_entry('gray', pt1.name, 'RGB888') }}
+{{ gen_suite_entry('gray', pt1.name, 'RGBA8888') }}
+%% endif
+{{ gen_suite_entry('gray', 'RGB888', pt1.name) }}
+{{ gen_suite_entry('gray', 'RGBA8888', pt1.name) }}
+{#- Red -#}
%% if not pt1.is_gray()
{{ gen_suite_entry('red', pt1.name, 'RGB888') }}
{{ gen_suite_entry('red', pt1.name, 'RGBA8888') }}
-----------------------------------------------------------------------
Summary of changes:
tests/core/Convert.gen.c.t | 72 +++++++++++++++++++
tests/core/{Pixel.c => Convert_Scale.gen.c.t} | 93 ++++++++++++++++--------
tests/core/Makefile | 6 +-
tests/core/test_list.txt | 1 +
4 files changed, 139 insertions(+), 33 deletions(-)
copy tests/core/{Pixel.c => Convert_Scale.gen.c.t} (51%)
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
18 May '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 e596ea9912cfde653e3048e64d3a821328975f14 (commit)
via c21eede58f5a634eb89685bfe3b4cc689a21cbcc (commit)
via 86959990865d791b8c411c58db7a0aec37b7425d (commit)
from ea54d1823b32741eebb6465568654e8d1bcd4354 (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/e596ea9912cfde653e3048e64d3a82132897…
commit e596ea9912cfde653e3048e64d3a821328975f14
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 17 23:11:26 2013 +0200
core: GP_Convert: Make it more readable.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t
index 7a7397e..72c974b 100644
--- a/include/core/GP_Convert.gen.h.t
+++ b/include/core/GP_Convert.gen.h.t
@@ -34,16 +34,16 @@
%% set M = out.chans['M']
%% set Y = out.chans['Y']
%% set K = out.chans['K']
-%% set max_bits = max(R[2], G[2], B[2])
-%% set max_val = 2 ** max_bits - 1
- GP_Pixel _R = GP_SCALE_VAL_{{ R[2] }}_{{ max_bits }}(GP_GET_BITS({{ R[1] }}+o1, {{ R[2] }}, p1)); - GP_Pixel _G = GP_SCALE_VAL_{{ G[2] }}_{{ max_bits }}(GP_GET_BITS({{ G[1] }}+o1, {{ G[2] }}, p1)); - GP_Pixel _B = GP_SCALE_VAL_{{ B[2] }}_{{ max_bits }}(GP_GET_BITS({{ B[1] }}+o1, {{ B[2] }}, p1)); +%% set max_size = max(R.size, G.size, B.size)
+%% set max_val = 2 ** max_size - 1
+ GP_Pixel _R = GP_SCALE_VAL_{{ R.size }}_{{ max_size }}(GP_GET_BITS({{ R.off }}+o1, {{ R.size }}, p1)); + GP_Pixel _G = GP_SCALE_VAL_{{ G.size }}_{{ max_size }}(GP_GET_BITS({{ G.off }}+o1, {{ G.size }}, p1)); + GP_Pixel _B = GP_SCALE_VAL_{{ B.size }}_{{ max_size }}(GP_GET_BITS({{ B.off }}+o1, {{ B.size }}, p1)); GP_Pixel _K = GP_MAX3(_R, _G, _B); - GP_SET_BITS({{ C[1] }}+o2, {{ C[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ C[2] }}((_K - _R))); - GP_SET_BITS({{ M[1] }}+o2, {{ M[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ M[2] }}((_K - _G))); - GP_SET_BITS({{ Y[1] }}+o2, {{ Y[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ Y[2] }}((_K - _B))); - GP_SET_BITS({{ K[1] }}+o2, {{ K[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ K[2] }}({{ max_val }} - _K)); + GP_SET_BITS({{ C.off }}+o2, {{ C.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ C.size }}((_K - _R))); + GP_SET_BITS({{ M.off }}+o2, {{ M.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ M.size }}((_K - _G))); + GP_SET_BITS({{ Y.off }}+o2, {{ Y.si
ze }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ Y.size }}((_K - _B))); + GP_SET_BITS({{ K.off }}+o2, {{ K.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ K.size }}({{ max_val }} - _K)); %% endmacro
%% macro GP_Pixel_TYPE_TO_TYPE(pt1, pt2)
@@ -60,23 +60,23 @@
{# case 1: just copy a channel -#}
%% if c2[0] in pt1.chans.keys()
%% set c1 = pt1.chans[c2[0]]
- /* {{ c2[0] }}:={{ c1[0] }} */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2,- GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1))); + /* {{ c2[0] }}:={{ c1[0] }} */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2,+ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1))); {# case 2: set A to full opacity (not present in source) -#}
%% elif c2[0]=='A'
- /* A:={{ hex(c2[2]) }} */GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2, {{ hex(2 ** c2[2] - 1) }}); + /* A:={{ c2.C_max }} */GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, {{ c2.C_max }}); {# case 3: calculate V as average of RGB -#}
%% elif c2[0]=='V' and pt1.is_rgb()
- /* V:=RGB_avg */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2, ( + /* V:=RGB_avg */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, ( %% for c1 in [pt1.chans['R'], pt1.chans['G'], pt1.chans['B']]
- /* {{c1[0]}} */ GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1)) + + /* {{ c1.name }} */ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1)) + %% endfor
0)/3); {# case 4: set each RGB to V -#}
%% elif c2[0] in 'RGB' and pt1.is_gray()
%% set c1 = pt1.chans['V']
- /* {{ c2[0] }}:=V */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2,- GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1))); + /* {{ c2[0] }}:=V */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2,+ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1))); {# case 5: CMYK to RGB -#}
%% elif c2[0] in 'RGB' and pt1.is_cmyk()
%% set K = pt1.chans['K']
@@ -88,10 +88,10 @@
%% else
%% set V = pt1.chans['Y']
%% endif
- GP_SET_BITS({{ c2[1] }}+o2, {{ c2[2] }}, p2,- GP_SCALE_VAL_{{ K[2] + V[2] }}_{{ c2[2] }}(- (({{ 2 ** K[2] - 1 }} - GP_GET_BITS({{ K[1] }}+o1, {{ K[2] }}, p1)) * - ({{ 2 ** V[2] - 1 }} - GP_GET_BITS({{ V[1] }}+o1, {{ V[2] }}, p1))))); + GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2,+ GP_SCALE_VAL_{{ K.size + V.size }}_{{ c2.size }}(+ (({{ K.C_max }} - GP_GET_BITS({{ K.off }}+o1, {{ K.size }}, p1)) * + ({{ V.C_max }} - GP_GET_BITS({{ V.off }}+o1, {{ V.size }}, p1))))); {# case 7: invalid mapping -#}
%% else
{{ error('Channel conversion ' + pt1.name + ' to ' + pt2.name + ' not supported.') }}
http://repo.or.cz/w/gfxprim.git/commit/c21eede58f5a634eb89685bfe3b4cc689a21…
commit c21eede58f5a634eb89685bfe3b4cc689a21cbcc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 17 20:18:43 2013 +0200
tests: core: New test for pixel conversions.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t
index 6f445e2..84159f1 100644
--- a/tests/core/Convert.gen.c.t
+++ b/tests/core/Convert.gen.c.t
@@ -37,15 +37,15 @@ static GP_Pixel get_black(GP_PixelType pixel_type)
{
switch (pixel_type) {
%% for pt in pixeltypes
- case GP_PIXEL_{{ pt.name }}:
+ case {{ pt.C_enum }}:
%% if pt.is_cmyk()
%% set K = pt.chans['K']
/* Black in CMYK is full K rest zero */
- return {{ hex((2 ** K[2] - 1) * (2 ** K[1]))}};
+ return {{ K.C_mask }};
%% elif pt.is_alpha()
%% set A = pt.chans['A']
/* Black with Alpha channel is full A rest zero */
- return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}};
+ return {{ A.C_mask }};
%% else
return 0;
%% endif
@@ -57,43 +57,86 @@ static GP_Pixel get_black(GP_PixelType pixel_type)
}
/*
+ * Returns white color for particular pixel type.
+ */
+static GP_Pixel get_white(GP_PixelType pixel_type)
+{
+ switch (pixel_type) {
+%% for pt in pixeltypes
+ case {{ pt.C_enum }}:
+%% if pt.is_cmyk()
+ /* White in CMYK is zero */
+ return 0x0;
+%% elif pt.is_rgb()
+%% set R = pt.chans['R']
+%% set G = pt.chans['G']
+%% set B = pt.chans['B']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* White in RGBA */
+ return {{ A.C_mask }} | {{ R.C_mask }} | {{ G.C_mask }} | {{ B.C_mask }};
+%% else
+ /* Plain old RGB */
+ return {{ R.C_mask }} | {{ G.C_mask }} | {{ B.C_mask }};
+%% endif
+%% elif pt.is_gray()
+%% set V = pt.chans['V']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Grayscale with Alpha */
+ return {{ V.C_mask }} | {{ A.C_mask }};
+%% else
+ /* Grayscale */
+ return {{ V.C_mask }};
+%% endif
+%% else
+ tst_msg("FIXME: Unsupported conversion to %s",
+ GP_PixelTypeName(pixel_type));
+ exit(TST_INTERR);
+%% endif
+%% endfor
+ default:
+ tst_msg("Invalid pixel type %i", pixel_type);
+ exit(TST_INTERR);
+ }
+}
+
+/*
* Returns red color for particular pixel type.
*/
static GP_Pixel get_red(GP_PixelType pixel_type)
{
switch (pixel_type) {
%% for pt in pixeltypes
- case GP_PIXEL_{{ pt.name }}:
+ case {{ pt.C_enum }}:
%% if pt.is_cmyk()
%% set M = pt.chans['M']
%% set Y = pt.chans['Y']
/* Red in CMYK is full M and Y rest zero */
- return {{ hex((2 ** M[2] - 1) * (2 ** M[1]))}}
- | {{ hex((2 ** Y[2] - 1) * (2 ** Y[1]))}};
+ return {{ M.C_mask }} | {{ Y.C_mask }};
%% elif pt.is_rgb()
%% set R = pt.chans['R']
%% if pt.is_alpha()
%% set A = pt.chans['A']
/* Red with Alpha channel is full Alpha and R rest zero */
- return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}}
- | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+ return {{ A.C_mask }} | {{ R.C_mask }};
%% else
/* Plain old RGB */
- return {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+ return {{ R.C_mask }};
%% endif
%% elif pt.is_gray()
%% set V = pt.chans['V']
%% if pt.is_alpha()
%% set A = pt.chans['A']
/* Grayscale with Alpha channel is full Alpha + 1/3 Gray */
- return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}};
- | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+ return ({{ hex(V.max // 3)}}{{ V.C_shift }}) | {{ A.C_mask }};
%% else
/* Grayscale is 1/3 Gray */
- return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}};
+ return {{ hex(V.max // 3) }}{{ V.C_shift }};
%% endif
%% else
- tst_msg("Unsupported conversion to %s", GP_PixelTypeName(pixel_type));
+ tst_msg("FIXME: Unsupported conversion to %s",
+ GP_PixelTypeName(pixel_type));
exit(TST_INTERR);
%% endif
%% endfor
@@ -110,6 +153,8 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi
GP_Pixel in = get_{{ test_name }}(GP_PIXEL_{{ in_name }});
GP_Pixel out_exp = get_{{ test_name }}(GP_PIXEL_{{ out_name }});
+ tst_msg("{{ in_name }} %08x -> {{ out_name }} %08x", in, out_exp);
+
GP_Pixel_{{ in_name }}_TO_{{ out_name }}(in, out);
if (out_exp != out) {
@@ -125,12 +170,22 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi
%% macro gen_converts()
%% for pt1 in pixeltypes
%% if not pt1.is_unknown() and not pt1.is_palette()
-%% for pt2 in pixeltypes
-%% if pt2.name in ['RGB888', 'RGBA8888']
-{{ gen_convert_and_check('black', pt2.name, pt1.name) }}
-{{ gen_convert_and_check('red', pt2.name, pt1.name) }}
-%% endif
-%% endfor
+%% if pt1.name not in ['RGB888', 'RGBA8888']
+{{ gen_convert_and_check('white', pt1.name, 'RGB888') }}
+{{ gen_convert_and_check('white', pt1.name, 'RGBA8888') }}
+{{ gen_convert_and_check('white', 'RGB888', pt1.name) }}
+{{ gen_convert_and_check('white', 'RGBA8888', pt1.name) }}
+{{ gen_convert_and_check('black', pt1.name, 'RGB888') }}
+{{ gen_convert_and_check('black', pt1.name, 'RGBA8888') }}
+{{ gen_convert_and_check('black', 'RGB888', pt1.name) }}
+{{ gen_convert_and_check('black', 'RGBA8888', pt1.name) }}
+%% if not pt1.is_gray()
+{{ gen_convert_and_check('red', pt1.name, 'RGB888') }}
+{{ gen_convert_and_check('red', pt1.name, 'RGBA8888') }}
+%% endif
+{{ gen_convert_and_check('red', 'RGB888', pt1.name) }}
+{{ gen_convert_and_check('red', 'RGBA8888', pt1.name) }}
+%% endif
%% endif
%% endfor
%% endmacro
@@ -147,17 +202,24 @@ const struct tst_suite tst_suite = {
.tests = {
%% for pt1 in pixeltypes
%% if not pt1.is_unknown() and not pt1.is_palette()
-%% for pt2 in pixeltypes
-%% if pt2.name in ['RGB888', 'RGBA8888']
-{{ gen_suite_entry('black', pt2.name, pt1.name) }}
-{{ gen_suite_entry('red', pt2.name, pt1.name) }}
+%% if pt1.name not in ['RGB888', 'RGBA8888']
+{{ gen_suite_entry('white', pt1.name, 'RGB888') }}
+{{ gen_suite_entry('white', pt1.name, 'RGBA8888') }}
+{{ gen_suite_entry('white', 'RGB888', pt1.name) }}
+{{ gen_suite_entry('white', 'RGBA8888', pt1.name) }}
+{{ gen_suite_entry('black', pt1.name, 'RGB888') }}
+{{ gen_suite_entry('black', pt1.name, 'RGBA8888') }}
+{{ gen_suite_entry('black', 'RGB888', pt1.name) }}
+{{ gen_suite_entry('black', 'RGBA8888', pt1.name) }}
+%% if not pt1.is_gray()
+{{ gen_suite_entry('red', pt1.name, 'RGB888') }}
+{{ gen_suite_entry('red', pt1.name, 'RGBA8888') }}
%% endif
-%% endfor
+{{ gen_suite_entry('red', 'RGB888', pt1.name) }}
+{{ gen_suite_entry('red', 'RGBA8888', pt1.name) }}
+%% endif
%% endif
%% endfor
-
-{{ gen_suite_entry('red', 'RGB888', 'CMYK8888') }}
-
{.name = NULL}
}
};
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 2fb3c86..2c0d363 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -4,9 +4,9 @@ include $(TOPDIR)/pre.mk
CSOURCES=Context.c Pixel.c
-GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c BlitConv.gen.c
+GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c Convert.gen.c BlitConv.gen.c
-APPS=WritePixel.gen Pixel Context GetPutPixel.gen BlitConv.gen
+APPS=WritePixel.gen Pixel Context GetPutPixel.gen Convert.gen BlitConv.gen
include ../tests.mk
diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt
index 432bef9..45702bb 100644
--- a/tests/core/test_list.txt
+++ b/tests/core/test_list.txt
@@ -3,4 +3,5 @@ WritePixel.gen
Context
Pixel
GetPutPixel.gen
+Convert.gen
BlitConv.gen
http://repo.or.cz/w/gfxprim.git/commit/86959990865d791b8c411c58db7a0aec37b7…
commit 86959990865d791b8c411c58db7a0aec37b7425d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 17 19:50:35 2013 +0200
gp_codegen: pixeltype.py: Edhance channel list members.
Previously the channel list (and dict) members were simple triplets.
This commit creates ChannelList object derived from list and adds
a few convinience member values.
* c.name returns channel name (same as c[0])
* c.off returns channel offset (same as c[1])
* c.size returns channel size in bits (same as c[2])
* c.C_shift returns string with C shift (i.e. " << 8" if off=8)
* c.max returns maximal channel value as int (i.e. 2 ^ len - 1)
* c.C_max returns maximal channel value as hex string
* c.mask returns channel mask as as int
* c.C_mask returns C mask as a string (i.e. "0xff00 for len=8 and off=8)
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gp_codegen/pixeltype.py b/pylib/gp_codegen/pixeltype.py
index eaac404..9e89ddc 100644
--- a/pylib/gp_codegen/pixeltype.py
+++ b/pylib/gp_codegen/pixeltype.py
@@ -2,11 +2,34 @@
# gfxprim.pixeltype - Module with PixelType descrition class
#
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+# 2013 Cyril Hrubis <metan(a)ucw.cz>
#
import re
from .pixelsize import PixelSize
+class PixelChannel(list):
+ def __init__(self, triplet):
+ (name, offset, size) = triplet
+ # Create the list -> backward compatibility with triplets
+ self.append(name)
+ self.append(offset)
+ self.append(size)
+ # Add some convinience variables
+ self.name = name
+ self.off = offset
+ self.size = size
+ # Shift ready to used in C
+ self.C_shift = " << " + hex(offset)
+ # Maximal channel value as an integer
+ self.max = 2 ** size - 1
+ # Maximal value as a C string
+ self.C_max = hex(self.max)
+ # Chanel bitmask as int
+ self.mask = self.max * (2 ** offset)
+ # Channel bitmas as hex string
+ self.C_mask = hex(self.mask)
+
class PixelType(object):
"""Representation of one GP_PixelType"""
@@ -20,14 +43,21 @@ class PixelType(object):
"""
assert re.match('A[A-Za-z][A-Za-z0-9_]*Z', name)
self.name = name
- self.chanslist = chanslist
+ # Create channel list with convinience variables
+ new_chanslist = []
+ for i in chanslist:
+ new_chanslist.append(PixelChannel(i))
+ self.chanslist = new_chanslist
self.chans = dict() # { chan_name: (offset, size) }
self.pixelsize = pixelsize
+ # C enum as defined in GP_Pixel.gen.h
+ self.C_enum = "GP_PIXEL_" + self.name
+
# Verify channel bits for overlaps
# also builds a bit-map of the PixelType
self.bits = ['x'] * pixelsize.size
- for c in chanslist:
+ for c in new_chanslist:
assert c[0] not in self.chans.keys()
self.chans[c[0]] = c
for i in range(c[1], c[1] + c[2]):
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t
new file mode 100644
index 0000000..6f445e2
--- /dev/null
+++ b/tests/core/Convert.gen.c.t
@@ -0,0 +1,165 @@
+/*****************************************************************************
+ * 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 "base.test.c.t"
+
+%% block body
+
+#include <stdio.h>
+
+#include <core/GP_Convert.h>
+
+#include "tst_test.h"
+
+/*
+ * Returns black color for particular pixel type.
+ */
+static GP_Pixel get_black(GP_PixelType pixel_type)
+{
+ switch (pixel_type) {
+%% for pt in pixeltypes
+ case GP_PIXEL_{{ pt.name }}:
+%% if pt.is_cmyk()
+%% set K = pt.chans['K']
+ /* Black in CMYK is full K rest zero */
+ return {{ hex((2 ** K[2] - 1) * (2 ** K[1]))}};
+%% elif pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Black with Alpha channel is full A rest zero */
+ return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}};
+%% else
+ return 0;
+%% endif
+%% endfor
+ default:
+ tst_msg("Invalid pixel type %i", pixel_type);
+ exit(TST_INTERR);
+ }
+}
+
+/*
+ * Returns red color for particular pixel type.
+ */
+static GP_Pixel get_red(GP_PixelType pixel_type)
+{
+ switch (pixel_type) {
+%% for pt in pixeltypes
+ case GP_PIXEL_{{ pt.name }}:
+%% if pt.is_cmyk()
+%% set M = pt.chans['M']
+%% set Y = pt.chans['Y']
+ /* Red in CMYK is full M and Y rest zero */
+ return {{ hex((2 ** M[2] - 1) * (2 ** M[1]))}}
+ | {{ hex((2 ** Y[2] - 1) * (2 ** Y[1]))}};
+%% elif pt.is_rgb()
+%% set R = pt.chans['R']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Red with Alpha channel is full Alpha and R rest zero */
+ return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}}
+ | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+%% else
+ /* Plain old RGB */
+ return {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+%% endif
+%% elif pt.is_gray()
+%% set V = pt.chans['V']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Grayscale with Alpha channel is full Alpha + 1/3 Gray */
+ return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}};
+ | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+%% else
+ /* Grayscale is 1/3 Gray */
+ return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}};
+%% endif
+%% else
+ tst_msg("Unsupported conversion to %s", GP_PixelTypeName(pixel_type));
+ exit(TST_INTERR);
+%% endif
+%% endfor
+ default:
+ tst_msg("Invalid pixel type %i", pixel_type);
+ exit(TST_INTERR);
+ }
+}
+
+%% macro gen_convert_and_check(test_name, in_name, out_name)
+static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(void)
+{
+ GP_Pixel out = 0;
+ GP_Pixel in = get_{{ test_name }}(GP_PIXEL_{{ in_name }});
+ GP_Pixel out_exp = get_{{ test_name }}(GP_PIXEL_{{ out_name }});
+
+ GP_Pixel_{{ in_name }}_TO_{{ out_name }}(in, out);
+
+ if (out_exp != out) {
+ tst_msg("Pixels are different have %08x, expected %08x",
+ out, out_exp);
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+%% endmacro
+
+%% macro gen_converts()
+%% for pt1 in pixeltypes
+%% if not pt1.is_unknown() and not pt1.is_palette()
+%% for pt2 in pixeltypes
+%% if pt2.name in ['RGB888', 'RGBA8888']
+{{ gen_convert_and_check('black', pt2.name, pt1.name) }}
+{{ gen_convert_and_check('red', pt2.name, pt1.name) }}
+%% endif
+%% endfor
+%% endif
+%% endfor
+%% endmacro
+
+{{ gen_converts() }}
+
+%% macro gen_suite_entry(name, from, to)
+ {.name = "Convert {{ name }} {{ from }} -> {{ to }}",
+ .tst_fn = convert_and_check_{{ name }}_{{ from }}_to_{{ to }}},
+%% endmacro
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Pixel Conversions Testsuite",
+ .tests = {
+%% for pt1 in pixeltypes
+%% if not pt1.is_unknown() and not pt1.is_palette()
+%% for pt2 in pixeltypes
+%% if pt2.name in ['RGB888', 'RGBA8888']
+{{ gen_suite_entry('black', pt2.name, pt1.name) }}
+{{ gen_suite_entry('red', pt2.name, pt1.name) }}
+%% endif
+%% endfor
+%% endif
+%% endfor
+
+{{ gen_suite_entry('red', 'RGB888', 'CMYK8888') }}
+
+ {.name = NULL}
+ }
+};
+
+%% endblock body
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Convert.gen.h.t | 40 ++++----
pylib/gp_codegen/pixeltype.py | 34 ++++++-
tests/core/Convert.gen.c.t | 227 +++++++++++++++++++++++++++++++++++++++
tests/core/Makefile | 4 +-
tests/core/test_list.txt | 1 +
5 files changed, 282 insertions(+), 24 deletions(-)
create mode 100644 tests/core/Convert.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
14 May '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 ea54d1823b32741eebb6465568654e8d1bcd4354 (commit)
from 1db276a11bc1bca52f361c7e9f7e4cf2933353d6 (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/ea54d1823b32741eebb6465568654e8d1bcd…
commit ea54d1823b32741eebb6465568654e8d1bcd4354
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 14 23:31:21 2013 +0200
spiv: Update help and keys help.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index f16be8c..93dd301 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -709,9 +709,24 @@ static void init_caches(struct loader_params *params)
static const char *keys_help[] = {
"Keyboard control:",
"",
+ "Esc, Enter, Q - quit spiv",
+ "",
+ "< KP Minus - zoom out by 1.5",
+ ">, KP Plus - zoom in by 1.5",
+ "R - rotate by 90 degrees clockwise",
+ "Up, Down, Left, Right - move image by 1px",
+ " (by 10 with Shift)",
+ "",
+ "Space - move to the next image",
+ "BackSpace - move to the prev image",
+ "PgDown - move to the start of directory",
+ "PgUp - move to the end of directory",
+ "Home - move to the first image",
+ "End - move to the last image",
+ "",
"I - toggle show info box",
"P - toggle show progress",
- "R - rotate by 90 degrees",
+ "",
"] - change to next resampling method",
"[ - change to prev resampling method",
" (current method is shown in info box)",
@@ -719,17 +734,6 @@ static const char *keys_help[] = {
"D - drop image cache",
"H - toggle help",
"",
- "Esc",
- "Enter",
- "Q - quit spiv",
- "",
- "PgDown - move 10 images forward",
- "PgUp - move 10 images backward",
- "",
- "Space - move to the next image",
- "",
- "BckSpc - move to the prev image",
- "",
"1 - resize spiv window to the image size",
"2 - resize spiv window to the half of the image size",
"3 - resize spiv window to the third of the image size",
@@ -757,6 +761,8 @@ static void print_help(void)
printf("-e pixel_typentturns on backend type emulationn");
printf("tfor example -e G1 sets 1-bit grayscalenn");
printf("-r anglentrotate display 90,180 or 270 degreesnn");
+ printf("-z sets zoom modent-zf zoom is set and modified by usern");
+ printf("t-zw zoom is fixed to window size (currently default)nn");
printf("-bntpass backend init string to backend initn");
printf("tpass -b help for more infonn");
@@ -783,7 +789,7 @@ static void show_help(void)
GP_Fill(c, black_pixel);
for (i = 0; i < keys_help_len; i++) {
- GP_Print(c, NULL, 20, i * 15, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ GP_Print(c, NULL, 20, 2 + i * 15, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white_pixel, black_pixel, "%s", keys_help[i]);
}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 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