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
October 2013
- 1 participants
- 8 discussions
19 Oct '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
discards 54d4ce312d1bff5105486a429ab4dc326408908b (commit)
via 7b640614144c242d672abe372961ef1d2e64c1fd (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (54d4ce312d1bff5105486a429ab4dc326408908b)
N -- N -- N (7b640614144c242d672abe372961ef1d2e64c1fd)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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/7b640614144c242d672abe372961ef1d2e64…
commit 7b640614144c242d672abe372961ef1d2e64c1fd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 18 23:48:07 2013 +0200
build: Add --mandir to configure and install.mk
Now spiv is installed by make target rather than by the ugly install.sh
script, also prepare for man page installation.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/Makefile b/Makefile
index 33cc33c..2747b51 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ TOP_MAKE=1
ifneq ($(MAKECMDGOALS),install)
SUBDIRS=include libs tests pylib demos build
else
-SUBDIRS=pylib
+SUBDIRS=pylib demos
endif
libs: include
diff --git a/configure b/configure
index 5af836e..2e8164b 100755
--- a/configure
+++ b/configure
@@ -312,7 +312,8 @@ if __name__ == '__main__':
'prefix' : ['', 'Installation prefix'],
'bindir' : ['/usr/bin', 'Where to install binaries'],
'libdir' : ['', 'Where to install libraries'],
- 'includedir' : ['/usr/include', 'Where to install headers']}
+ 'includedir' : ['/usr/include', 'Where to install headers'],
+ 'mandir' : ['/usr/share/man', 'Where to install man pages']}
#
# Library detection/enable disable
diff --git a/demos/spiv/Makefile b/demos/spiv/Makefile
index 80cfa29..4fc57aa 100644
--- a/demos/spiv/Makefile
+++ b/demos/spiv/Makefile
@@ -11,8 +11,12 @@ LDLIBS+=$(LDLIBS_LOADERS) $(LDLIBS_BACKENDS)
APPS=spiv
+INSTALL_BIN=spiv
+#INSTALL_MAN=spiv.1
+
spiv: cpu_timer.o image_cache.o image_list.o image_actions.o spiv_help.o image_loader.o cfg.o spiv_config.o
include $(TOPDIR)/app.mk
+include $(TOPDIR)/install.mk
include $(TOPDIR)/post.mk
diff --git a/install.mk b/install.mk
new file mode 100644
index 0000000..689acda
--- /dev/null
+++ b/install.mk
@@ -0,0 +1,34 @@
+ifdef DESTDIR
+BIN_DIR=$(DESTDIR)$(bindir)
+else
+BIN_DIR=$(bindir)
+endif
+
+ifdef DESTDIR
+MAN_DIR=$(DESTDIR)$(mandir)/man1
+else
+MAN_DIR=$(mandir)/man1
+endif
+
+install:
+ifdef INSTALL_BIN
+ifdef VERBOSE
+ install -d "$(BIN_DIR)"
+ for i in $(INSTALL_BIN); do install "$$i" "$(BIN_DIR)"; done
+else
+ @install -d "$(BIN_DIR)"
+ @echo "MKDIR $(BIN_DIR)"
+ @for i in $(INSTALL_BIN); do echo "CP $$i $(MAN_DIR)"; install "$$i" "$(BIN_DIR)"; done
+endif
+endif
+
+ifdef INSTALL_MAN
+ifdef VERBOSE
+ install -d "$(MAN_DIR)"
+ for i in $(INSTALL_MAN); do install "$$i" "$(MAN_DIR)"; done
+else
+ @install -d "$(MAN_DIR)"
+ @echo "MKDIR $(MAN_DIR)"
+ @for i in $(INSTALL_MAN); do echo "CP $$i $(MAN_DIR)"; install "$$i" "$(MAN_DIR)"; done
+endif
+endif
diff --git a/install.sh b/install.sh
index 0b3020a..14c9835 100755
--- a/install.sh
+++ b/install.sh
@@ -40,4 +40,3 @@ done
echo "INSTALL binaries"
install -m 775 -d "$BIN_LOC"
install -m 755 gfxprim-config "$BIN_LOC"
-install -m 755 demos/spiv/spiv "$BIN_LOC"
-----------------------------------------------------------------------
Summary of changes:
install.mk | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
create mode 100644 install.mk
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 Oct '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 54d4ce312d1bff5105486a429ab4dc326408908b (commit)
via bb4d5c588bb10bfc481e1f767406054f11c47f44 (commit)
via a6f2101f0ee7bec3d15f1a03fa40cf712f375218 (commit)
via d0214b0c148d1489af0fe551953665f6c840cd26 (commit)
from af3ab64dd671ec59cc44f58490401b96f48c66bc (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/54d4ce312d1bff5105486a429ab4dc326408…
commit 54d4ce312d1bff5105486a429ab4dc326408908b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 18 23:48:07 2013 +0200
build: Add --mandir to configure and install.mk
Now spiv is installed by make target rather than by the ugly install.sh
script, also prepare for man page installation.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/Makefile b/Makefile
index 33cc33c..2747b51 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ TOP_MAKE=1
ifneq ($(MAKECMDGOALS),install)
SUBDIRS=include libs tests pylib demos build
else
-SUBDIRS=pylib
+SUBDIRS=pylib demos
endif
libs: include
diff --git a/configure b/configure
index 5af836e..2e8164b 100755
--- a/configure
+++ b/configure
@@ -312,7 +312,8 @@ if __name__ == '__main__':
'prefix' : ['', 'Installation prefix'],
'bindir' : ['/usr/bin', 'Where to install binaries'],
'libdir' : ['', 'Where to install libraries'],
- 'includedir' : ['/usr/include', 'Where to install headers']}
+ 'includedir' : ['/usr/include', 'Where to install headers'],
+ 'mandir' : ['/usr/share/man', 'Where to install man pages']}
#
# Library detection/enable disable
diff --git a/demos/spiv/Makefile b/demos/spiv/Makefile
index 80cfa29..4fc57aa 100644
--- a/demos/spiv/Makefile
+++ b/demos/spiv/Makefile
@@ -11,8 +11,12 @@ LDLIBS+=$(LDLIBS_LOADERS) $(LDLIBS_BACKENDS)
APPS=spiv
+INSTALL_BIN=spiv
+#INSTALL_MAN=spiv.1
+
spiv: cpu_timer.o image_cache.o image_list.o image_actions.o spiv_help.o image_loader.o cfg.o spiv_config.o
include $(TOPDIR)/app.mk
+include $(TOPDIR)/install.mk
include $(TOPDIR)/post.mk
diff --git a/install.sh b/install.sh
index 0b3020a..14c9835 100755
--- a/install.sh
+++ b/install.sh
@@ -40,4 +40,3 @@ done
echo "INSTALL binaries"
install -m 775 -d "$BIN_LOC"
install -m 755 gfxprim-config "$BIN_LOC"
-install -m 755 demos/spiv/spiv "$BIN_LOC"
http://repo.or.cz/w/gfxprim.git/commit/bb4d5c588bb10bfc481e1f767406054f11c4…
commit bb4d5c588bb10bfc481e1f767406054f11c47f44
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 18 23:20:24 2013 +0200
pywrap: text: Do not wrap GP_Print and GP_VPrint
Python has it's own way of producing formatted strings, moreover trying
to wrap these produces build errors.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/text/text.i b/pylib/gfxprim/text/text.i
index 485c31c..7134eec 100644
--- a/pylib/gfxprim/text/text.i
+++ b/pylib/gfxprim/text/text.i
@@ -11,6 +11,8 @@
%ignore GP_GlyphBitmap::bitmap;
%ignore GP_FontFace::glyph_offsets;
+%ignore GP_Print;
+%ignore GP_VPrint;
%include "GP_Text.h"
%include "GP_Font.h"
%include "GP_DefaultFont.h"
http://repo.or.cz/w/gfxprim.git/commit/a6f2101f0ee7bec3d15f1a03fa40cf712f37…
commit a6f2101f0ee7bec3d15f1a03fa40cf712f375218
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 18 23:14:14 2013 +0200
tests: Makefile: Fix parallel build.
Add missing framework dependency.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/Makefile b/tests/Makefile
index 56d5c28..799b033 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -7,5 +7,6 @@ loaders: framework
gfx: framework
core: framework
filters: framework
+input: framework
include $(TOPDIR)/post.mk
http://repo.or.cz/w/gfxprim.git/commit/d0214b0c148d1489af0fe551953665f6c840…
commit d0214b0c148d1489af0fe551953665f6c840cd26
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 18 00:15:23 2013 +0200
doc: Redo the pages style, new logo, etc.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/Makefile b/doc/Makefile
index c07d94a..a9121f7 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,10 +1,10 @@
-SOURCES=general.txt context.txt loaders.txt filters.txt basic_types.txt - drawing_api.txt backends.txt gamma.txt grabbers.txt - environment_variables.txt debug.txt core.txt api.txt input.txt +SOURCES=index.html about.txt context.txt loaders.txt filters.txt + basic_types.txt gfx.txt backends.txt gamma.txt grabbers.txt + environment_variables.txt debug.txt core.txt input.txt gen.txt pixels.txt coordinate_system.txt coding_style.txt - get_put_pixel.txt blits.txt progress_callback.txt text_api.txt + get_put_pixel.txt blits.txt progress_callback.txt text.txt event_queue.txt compilation.txt filters_resize.txt - filters_dithering.txt filters_python.txt
+ filters_dithering.txt filters_python.txt spiv.txt
SOURCES+=core_python.txt gfx_python.txt loaders_python.txt backends_python.txt
@@ -24,7 +24,7 @@ PAGES+=$(subst .txt,.html,$(EXAMPLE_SOURCES))
.PHONY: toolcheck clean
-all: toolcheck examples.html $(PAGES) api.html
+all: toolcheck examples.html $(PAGES)
$(PAGES): asciidoc.conf
@@ -74,5 +74,3 @@ CLEAN+=$(PAGES)
clean:
rm -f $(CLEAN)
- rm -f api_links.html api.html examples.html
- rm -f api.xml api.fo api.pdf
diff --git a/doc/general.txt b/doc/about.txt
similarity index 90%
rename from doc/general.txt
rename to doc/about.txt
index a2a9167..fc4d176 100644
--- a/doc/general.txt
+++ b/doc/about.txt
@@ -1,15 +1,15 @@
General information
-===================
+-------------------
Gfxprim is simple modular 2D bitmap graphics library with emphasis on speed
and correctness.
-One of the key points of the library is meta-programming. Most of the
-operations and filters are written in http://jinja.pocoo.org/[Jinja]
-templating language that is used to generate specialized code in C
-programmming language. Creating code that works with less usuall pixel types
-should be as easy as adding pixel definition into the configuration and
-rebuilding the library. Read more link:gen.html[here].
+One of the key points of the library are code generators. Most of the
+graphics operations are written using http://jinja.pocoo.org/[Jinja]
+templating engine which is used to create specialized C code. So,
+for an example, once you add pixel definition into configuration file,
+creating specialized filters, loaders and conversions to other pixel
+formats is just a matter of typing +make rebuild+.
Core
----
@@ -21,9 +21,9 @@ The most important part of the core is link:context.html[CP_Context] structure
that represents in-memory pixmap.
The Core also contains generated code for basic operations such as
-link:get_put_pixel.html[GetPixel] and link:get_put_pixel.html[PutPixel] and
-optimized functions for writing continous line of pixels 'GP_WritePixels' that
-are base for the more complex drawing primitives in GFX or for graphics
+link:get_put_pixel.html[GP_GetPixel] and link:get_put_pixel.html[GP_PutPixel]
+and optimized functions for writing continous line of pixels 'GP_WritePixels'
+that are base for the more complex drawing primitives in GFX or for graphics
operations in Filters.
link:blits.html[Blits] are functions used to copy part of one bitmap into
@@ -48,7 +48,7 @@ that are used from different parts of the library.
Gfx
---
-link:drawing_api.html[Gfx] is part of the library that implements basic
+link:gfx.html[Gfx] is part of the library that implements basic
graphics primitives such as lines, circles, polygons, etc. Clasicall
primitives are nearly finished. Work on anti aliased primitives has been
started.
@@ -56,7 +56,7 @@ started.
Text
----
-link:text_api.html[Text] part of the library implements basic support for
+link:text.html[Text] part of the library implements basic support for
printing text into the bitmap. There are two bitmap fonts compiled directly
into the library and we support True Type fonts through
link:http://freetype.org[FreeType] (so far ASCII printable characters only).
diff --git a/doc/api.txt b/doc/api.txt
deleted file mode 100644
index 709bb92..0000000
--- a/doc/api.txt
+++ /dev/null
@@ -1,86 +0,0 @@
-GFXprim API
------------
-
-. link:basic_types.html[Basic library types]
- +
- Describes how colors and pixels are handled also describes progress callback
- in great detail.
- +
-. link:coordinate_system.html[Coordinate system]
- +
- Describes briefly coordinate system and relation to pixels.
- +
-. link:core.html[Library Core overview]
- +
- Describes functions and macros in library core.
- +
-. link:pixels.html[Pixel Types]
- +
- Describes pixel types.
- +
-. link:debug.html[Debug Messages]
- +
- Interface to debug layer.
- +
-. link:context.html[Context]
- +
- The Context is description of in-memory bitmap including some meta-data
- (size, pixel format, etc...).
- +
-. link:environment_variables.html[Environment Variables]
- +
- Description of environment variables that affects GFXprim behavior.
- +
-. link:gamma.html[Gamma correction]
- +
- The gama correction description and handling in GFXprim.
- +
-. link:drawing_api.html[Drawing primitives]
- +
- Drawing API for primitives such as lines, polygons and circles as well as
- text drawing.
- +
-. link:filters.html[Context filters]
- +
- Context filters, basically all algorithms that takes an Context as an input
- and returns Context as output.
- +
- Includes resampling, convolutions, low pass (blur) filters, dithering and
- more.
- +
-. link:loaders.html[Context loaders]
- +
- Handles loading and saving images in standard formats.
- +
-. link:backends.html[Backends]
- +
- Backends API for drawing on the screen or into a window.
- +
-. link:input.html[Input Events]
- +
- Input event handling such as key presses, mouse coordinates, touchscreens
- and window manager events such as window close or window resize.
- +
-. link:grabbers.html[Grabbers]
- +
- Video grabbers interface such as V4L2.
- +
-
-TIP: There is also a nice page with code link:examples.html[examples].
-
-GFXprim Internals
------------------
-
-. link:gen.html[Templating engine]
- +
- Describes structure and basic usage of the templating engine (C code
- generator).
- +
-
-Development
------------
-
-. link:coding_style.html[Coding Style]
- +
- C and Python coding style.
- +
diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf
index 4f58bfc..4cc241a 100644
--- a/doc/asciidoc.conf
+++ b/doc/asciidoc.conf
@@ -22,101 +22,63 @@ endif::quirks[]
ifdef::pygments[<link rel="stylesheet" href="{stylesdir=.}/pygments.css" type="text/css" />]
ifdef::toc2[<link rel="stylesheet" href="{stylesdir=.}/toc2.css" type="text/css" />]
<link rel="stylesheet" href="{stylesdir=.}/{stylesheet}" type="text/css" />
-ifndef::disable-javascript[]
-<script type="text/javascript" src="{scriptsdir=.}/asciidoc.js"></script>
-<script type="text/javascript">
-# Escape as CDATA to pass validators.
-/*<![CDATA[*/
-asciidoc.install({toc,toc2?{toclevels}});
-/*]]>*/
-</script>
-endif::disable-javascript[]
{docinfo1,docinfo2#}{include:{docdir}/docinfo.html}
{docinfo,docinfo2#}{include:{docdir}/{docname}-docinfo.html}
</head>
-<body class="{doctype}" style="max-width:55em; margin-left: auto; margin-right: auto;">
-
-# Article, book header.
-# Left menu
-<div class="left-menu">
- <h4>Navigation</h4>
- <ul>
- <li><a href="general.html">Home</a></li>
- <li><a href="compilation.html">Compilation</a></li>
- </ul>
- <h4>API Pages</h4>
- <ul>
- <li><a href="drawing_api.html">Gfx</a></li>
- <li><a href="text_api.html">Text</a></li>
- <li><a href="filters.html">Filters</a></li>
- <li><a href="loaders.html">Loaders</a></li>
- <li><a href="backends.html">Backends</a></li>
- <li><a href="input.html">Input</a></li>
- </ul>
- <h4>Python bindings</h4>
- <ul>
- <li><a href="core_python.html">Core</a></li>
- <li><a href="loaders_python.html">Loaders</a></li>
- <li><a href="filters_python.html">Filters</a></li>
- <li><a href="gfx_python.html">Gfx</a></li>
- <li><a href="backends_python.html">Backends</a></li>
- </ul>
-</div>
-
-# Rest of the content
- <div class="logo">
- <h1>GFXprim documentation</h1>
- </div>
-
- <div id="header">
-
-ifndef::notitle[<h1>{doctitle}</h1>]
-ifdef::doctitle[]
- <span id="author">{author}</span><br />
- <span id="email"><tt><<a href="mailto:{email}">{email}</a>></tt></span><br />
- <span id="revnumber">version {revnumber}{revdate?,}</span>
- <span id="revdate">{revdate}</span>
- <br /><span id="revremark">{revremark}</span>
-endif::doctitle[]
-
-ifdef::toc,toc2[{template:toc}]
-
- </div>
-
- <div class="content">
-
+<body>
+ <div class="page-container">
+ <div class="logo">
+ <div class="logo_picture">
+ <img src="gfxprim_logo.png" alt="GFXprim">
+ </div>
+ <div class="upper-menu">
+ <a href="http://repo.or.cz/w/gfxprim.git">repo.or.cz</a> /
+ <a href="https://github.com/gfxprim/gfxprim">GitHub</a> /
+ <a href="about.html">C API</a> /
+ <a href="core_python.html">Pyton API</a> /
+ <a href="http://www.ucw.cz/mailman/listinfo/gfxprim">Mailing List</a>
+ </div>
+ </div>
+ <div class="left-menu">
+ Navigation
+ <ul>
+ <li><a href="index.html">Home</a></li>
+ <li><a href="about.html">About</a></li>
+ <li><a href="compilation.html">Compilation</a></li>
+ </ul>
+ C API Pages
+ <ul>
+ <li><a href="gfx.html">Gfx</a></li>
+ <li><a href="text.html">Text</a></li>
+ <li><a href="filters.html">Filters</a></li>
+ <li><a href="loaders.html">Loaders</a></li>
+ <li><a href="backends.html">Backends</a></li>
+ <li><a href="input.html">Input</a></li>
+ <li><a href="grabbers.html">Grabbers</a></li>
+ </ul>
+ Python bindings
+ <ul>
+ <li><a href="core_python.html">Core</a></li>
+ <li><a href="loaders_python.html">Loaders</a></li>
+ <li><a href="filters_python.html">Filters</a></li>
+ <li><a href="gfx_python.html">Gfx</a></li>
+ <li><a href="backends_python.html">Backends</a></li>
+ </ul>
+ Applications
+ <ul>
+ <li><a href="spiv.html">spiv</a></li>
+ </ul>
+ </div>
+ <div id="page-content">
+ <h1>{doctitle}</h1>
[footer]
- <div id="footer">
- <div id="footer-text">
-template::[footer-text]
-</div>
-ifdef::badges[]
-<div id="footer-badges">
-ifndef::icons[]
-Valid <a href="http://validator.w3.org/check?uri=referer">XHTML</a>
-and <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>.
-endif::icons[]
-ifdef::icons[]
-<a href="http://validator.w3.org/check?uri=referer">
- <img style="border:0;width:88px;height:31px"
- src="http://www.w3.org/Icons/valid-xhtml11-blue"
- alt="Valid XHTML 1.1" height="31" width="88" />
-</a>
-<a href="http://jigsaw.w3.org/css-validator/">
- <img style="border:0;width:88px;height:31px"
- src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
- alt="Valid CSS!" />
-</a>
-<a href="http://www.mozilla.org/products/firefox/">
- <img style="border:none; width:110px; height:32px;"
- src="http://www.spreadfirefox.com/community/images/affiliates/Buttons/110x32/saf…"
- alt="Get Firefox!" />
-</a>
-endif::icons[]
-</div>
-endif::badges[]
-</div>
-</div>
+ </div>
+ <div> </div>
+ <div id="footer">
+ Current release is <em>1.0.0-rc0</em>.
+ </div>
+ </div>
+ </div>
</body>
</html>
diff --git a/doc/asciidoc.css b/doc/asciidoc.css
index 37a9d07..11089de 100644
--- a/doc/asciidoc.css
+++ b/doc/asciidoc.css
@@ -1,9 +1,7 @@
-/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
-
/* Default font. */
body {
font-family: Georgia,serif;
- background: white;
+ background: #bbb;
}
/* Title font. */
@@ -11,42 +9,47 @@ h1, h2, h3, h4, h5, h6,
div.title, caption.title,
thead, p.table.header,
#toctitle,
-#author, #revnumber, #revdate, #revremark,
-#footer {
+#author, #revnumber, #revdate, #revremark {
font-family: Arial,Helvetica,sans-serif;
+ clear: both;
}
body {
- margin: 1em 5% 1em 5%;
+ margin: 1em 10% 1em 10%;
}
-a {
- color: blue;
- text-decoration: underline;
+a, a:visited {
+ color: #333;
+ font-weight: bolder;
+ text-decoration: none;
}
-a:visited {
- color: fuchsia;
+
+a:hover {
+ font-weight: bolder;
+ text-decoration: none;
+ color: OrangeRed ! important;
}
em {
- font-style: italic;
- color: navy;
+ font-style: normal;
+ font-weight: 600;
+ color: #444;
}
strong {
font-weight: bold;
- color: #083194;
+ color: #223;
}
h1, h2, h3, h4, h5, h6 {
- color: #527bbd;
+ color: #334;
margin-top: 1.2em;
margin-bottom: 0.5em;
line-height: 1.3;
}
h1, h2, h3 {
- border-bottom: 2px solid silver;
+ border-bottom: 2px solid #aaa;
}
h2 {
padding-top: 0.5em;
@@ -66,7 +69,7 @@ div.sectionbody {
}
hr {
- border: 1px solid silver;
+ border: 1px solid #aaa;
}
p {
@@ -96,18 +99,11 @@ pre {
}
#footer {
- font-size: small;
- border-top: 2px solid silver;
- padding-top: 0.5em;
- margin-top: 4.0em;
-}
-#footer-text {
- float: left;
- padding-bottom: 0.5em;
-}
-#footer-badges {
- float: right;
- padding-bottom: 0.5em;
+ background-color: #fa0;
+ text-align: center;
+ border-top: 1px solid Black;
+ border-bottom: 1px solid Black;
+ clear: both;
}
#preamble {
@@ -115,19 +111,69 @@ pre {
margin-bottom: 1.5em;
}
-div.left-menu {
+div.page-container {
+ background-color: White;
position: relative;
- top: 90pt;
- left: -110pt;
- height: 0;
- width: 110pt;
}
-div.logo h1 {
+div.left-menu {
+ position: absolute;
+ left: 1.5em;
+ top: 190px;
+ border: 1px solid Black;
+ background-color: #ddd;
+ padding-left: 0.5em;
+ padding-right: 0.5em;
+ padding-top: 0.5em;
+}
+
+div.left-menu a,a:visited,a:hover {
+ text-decoration: none;
+}
+
+div.left-menu a,a:visited {
+ color: #111;
+}
+
+div.left-menu a:hover {
+ color: OrangeRed;
+}
+
+div.left-menu ul {
+ padding: 0 0 0 0.4em;
+}
+
+div.left-menu li {
+ list-style-type: none;
+}
+
+#page-content {
+ border: 0;
+ padding-left: 13em;
+ padding-right: 2em;
+}
+
+div.logo {
border-bottom: 0px;
margin-top: 1em;
- margin-bottom: 0em;
- color: gray;
+ padding-left: 1em;
+ color: #444;
+ background-color: #fa0;
+ border-top: 1px solid Black;
+ border-bottom: 1px solid Black;
+ position: relative;
+}
+
+div.logo_picture {
+ display: inline;
+}
+
+div.upper-menu {
+ display: inline;
+ float: right;
+ position: absolute;
+ bottom: 0;
+ right: 1em;
}
div.imageblock, div.exampleblock, div.verseblock,
@@ -144,12 +190,12 @@ div.admonitionblock {
}
div.content { /* Block element content. */
- padding: 0em;
+ padding: 1em;
}
/* Block element titles. */
div.title, caption.title {
- color: #527bbd;
+ color: #444;
font-weight: bold;
text-align: left;
margin-top: 1.0em;
@@ -178,7 +224,7 @@ div.sidebarblock > div.content {
div.listingblock > div.content {
border: 1px solid #dddddd;
- border-left: 5px solid #f0f0f0;
+ border-left: 5px solid #99a;
background: #f8f8f8;
padding: 0.5em;
}
@@ -204,10 +250,6 @@ div.verseblock > div.attribution {
padding-top: 0.75em;
text-align: left;
}
-/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
-div.verseblock + div.attribution {
- text-align: left;
-}
div.admonitionblock .icon {
vertical-align: top;
@@ -219,7 +261,7 @@ div.admonitionblock .icon {
}
div.admonitionblock td.content {
padding-left: 0.5em;
- border-left: 3px solid #dddddd;
+ border-left: 3px solid #bbc;
}
div.exampleblock > div.content {
@@ -342,10 +384,6 @@ div.colist td img {
margin-top: 0.3em;
}
-@media print {
- #footer-badges { display: none; }
-}
-
#toc {
margin-bottom: 2.5em;
}
@@ -425,7 +463,7 @@ span.line-through { text-decoration: line-through; }
tt {
font-family: monospace;
font-size: inherit;
- color: navy;
+ color: #333;
}
div.tableblock {
@@ -433,11 +471,11 @@ div.tableblock {
margin-bottom: 1.5em;
}
div.tableblock > table {
- border: 3px solid #527bbd;
+ border: 3px solid #336;
}
thead, p.table.header {
font-weight: bold;
- color: #527bbd;
+ color: #334;
}
p.table {
margin-top: 0;
@@ -454,72 +492,3 @@ div.tableblock > table[frame="vsides"] {
border-top-style: none;
border-bottom-style: none;
}
-
-
-/*
- * html5 specific
- *
- * */
-
-.monospaced {
- font-family: monospace;
- font-size: inherit;
- color: navy;
-}
-
-table.tableblock {
- margin-top: 1.0em;
- margin-bottom: 1.5em;
-}
-thead, p.tableblock.header {
- font-weight: bold;
- color: #527bbd;
-}
-p.tableblock {
- margin-top: 0;
-}
-table.tableblock {
- border-width: 3px;
- border-spacing: 0px;
- border-style: solid;
- border-color: #527bbd;
- border-collapse: collapse;
-}
-th.tableblock, td.tableblock {
- border-width: 1px;
- padding: 4px;
- border-style: solid;
- border-color: #527bbd;
-}
-
-table.tableblock.frame-topbot {
- border-left-style: hidden;
- border-right-style: hidden;
-}
-table.tableblock.frame-sides {
- border-top-style: hidden;
- border-bottom-style: hidden;
-}
-table.tableblock.frame-none {
- border-style: hidden;
-}
-
-th.tableblock.halign-left, td.tableblock.halign-left {
- text-align: left;
-}
-th.tableblock.halign-center, td.tableblock.halign-center {
- text-align: center;
-}
-th.tableblock.halign-right, td.tableblock.halign-right {
- text-align: right;
-}
-
-th.tableblock.valign-top, td.tableblock.valign-top {
- vertical-align: top;
-}
-th.tableblock.valign-middle, td.tableblock.valign-middle {
- vertical-align: middle;
-}
-th.tableblock.valign-bottom, td.tableblock.valign-bottom {
- vertical-align: bottom;
-}
diff --git a/doc/backends.txt b/doc/backends.txt
index 197c71e..e124cca 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -1,5 +1,5 @@
Drawing Backends
-================
+----------------
Drawing backends provide means to draw on computer screen or into a window.
Instead of having one unified initialization interface each backend has it's
diff --git a/doc/compilation.txt b/doc/compilation.txt
index bd8a1b3..b5eb7fc 100644
--- a/doc/compilation.txt
+++ b/doc/compilation.txt
@@ -1,43 +1,39 @@
-Compilation
------------
+Dependencies
+------------
-GFXprim needs following tools to compile:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+*Base dependencies*
* C compiler (tested with 'gcc' or 'clang')
* GNU make
* Python (2.6 or newer)
* Jinja2
-Additional dependencies:
-~~~~~~~~~~~~~~~~~~~~~~~~
-
-Image loaders
-^^^^^^^^^^^^^
+*Optional Image loaders*
* libjpeg
* libpng
* giflib
* libtiff
+* openjpeg >= 2.0.0
+* zlib (usually installed as libpng dependency)
-Text rendering
-^^^^^^^^^^^^^^
+*Optinal Text rendering*
* FreeType
-Backends
-^^^^^^^^
+*Optional Backends*
* X11
-* SDL (not recomended, SDL is known to be slow and buggy)
+* AA-lib
+* SDL-1.2 (not recomended, known to be slow and buggy)
-Python Bindings
-^^^^^^^^^^^^^^^
+*Python Bindings*
* Swig
+* Python (devel library)
Compilation
-~~~~~~~~~~~
+-----------
Once devel packages are installed the compilation is as simple as running
+configure+ and +make+.
@@ -65,7 +61,7 @@ The +make install+ command will install GFXprim libraries and devel headers
into your system.
OpenSUSE & Fedora
-~~~~~~~~~~~~~~~~~
+-----------------
Instruction to install required packages on
link:http://www.opensuse.org/[OpenSUSE].
@@ -78,7 +74,7 @@ Works for link:http://www.fedoraproject.org/[Fedora] too if you substitute
zypper in gcc make python-jinja2
-------------------------------------------------------------------------------
-.Install jpeg and png devel libraries
+.Install image devel libraries
-------------------------------------------------------------------------------
zypper in libjpeg-devel libpng-devel giflib-devel libtiff-devel
-------------------------------------------------------------------------------
@@ -106,7 +102,7 @@ zypper in gcc make python-Jinja2 libjpeg-devel libpng-devel giflib-devel
-------------------------------------------------------------------------------
Debian
-~~~~~~
+------
Instruction to install required packages on link:http://www.debian.org[Debian]
and other Debian based distributions.
@@ -116,7 +112,7 @@ and other Debian based distributions.
apt-get install gcc make python-jinja2
-------------------------------------------------------------------------------
-.Install jpeg and png devel libraries
+.Install image devel libraries
-------------------------------------------------------------------------------
apt-get install libjpeg-dev libpng-dev libgif-dev libtiff-dev
-------------------------------------------------------------------------------
diff --git a/doc/favicon.png b/doc/favicon.png
index 3ceab57..ad24515 100644
Binary files a/doc/favicon.png and b/doc/favicon.png differ
diff --git a/doc/get_put_pixel.txt b/doc/get_put_pixel.txt
index f96354f..3c5e716 100644
--- a/doc/get_put_pixel.txt
+++ b/doc/get_put_pixel.txt
@@ -12,4 +12,38 @@ GP_Pixel GP_GetPixel(const GP_Context *context, GP_Coord x, GP_Coord y);
void GP_PutPixel(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p);
--------------------------------------------------------------------------------
-TODO: This is stub.
+Gets, puts a pixel value. GP_Pixel is a number which holds a pixel value.
+
+This functions are clipped, GetPixel outside of the context returns zero,
+PutPixel outside the context is no-op.
+
+This functions honour link:context.html[context rotation flags].
+
+Generally these function are safe to use but rather slow in innner cycles.
+
+[source,c]
+--------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <core/GP_GetPutPixel.h>
+
+GP_Pixel GP_GetPixel_Raw(const GP_Context *context, GP_Coord x, GP_Coord y);
+
+void GP_PutPixel_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p);
+
+/*
+ * Substitute {{ bpp }} for specific bits per pixel (1BPP_LE, 24BPP, ...)
+ *
+ * These macros are generated to core/GP_GetPutPixel.gen.h
+ */
+GP_Pixel GP_GetPixel_Raw_{{ bpp }}(const GP_Context *c, int x, int y);
+
+void GP_PutPixel_Raw_{{ bpp }}(GP_Context *c, GP_Coord x, GP_Coord y,
+ GP_Pixel p);
+--------------------------------------------------------------------------------
+
+These functions are generally fast, but does not honour context rotation flags
+and do not check coordinates.
+
+They are intended as basic building blocks for other GFX primitives, filters,
+etc.
diff --git a/doc/drawing_api.txt b/doc/gfx.txt
similarity index 84%
rename from doc/drawing_api.txt
rename to doc/gfx.txt
index 948dea0..c311dbf 100644
--- a/doc/drawing_api.txt
+++ b/doc/gfx.txt
@@ -1,7 +1,25 @@
Drawing primitives
------------------
-NOTE: You may want to see the link:coordinate_system.html[coordinate system] first.
+Drawing primitives implements algorithms to draw basic geometric shapes such
+as lines, circles, etc.
+
+You may want to see the link:coordinate_system.html[coordinate system] first.
+
+Rotation Flags
+~~~~~~~~~~~~~~
+
+Drawing orientation is affected by the link:context.html[context rotation
+flags]. The parameters passed to the functions are transformed accordingly to
+the flags before the drawing, which allows for fast and transparent rotated or
+mirrored rendering.
+
+
+GetPixel and PutPixel
+~~~~~~~~~~~~~~~~~~~~~
+
+link:get_put_pixel.html[GetPixel and PutPixel] are implemented in the library
+Core.
Fill
~~~~
@@ -11,8 +29,10 @@ Fill
void GP_Fill(GP_Context *context, GP_Pixel pixel);
--------------------------------------------------------------------------------
-Fills the whole context bitmap with the specified pixel value. This has the
-same effect as calling 'GP_FillRect(context, 0, 0, context->w, context->h, pixel)'.
+Fills the whole context bitmap with the specified pixel value.
+
+NOTE: GP_Fill is implemented in the library Core rather than in GFX so that
+ it's available to all library parts.
Lines
~~~~~
@@ -227,3 +247,25 @@ void GP_FillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
--------------------------------------------------------------------------------
Draws a filled tetragon.
+
+Polygons
+~~~~~~~~
+
+[source,c]
+--------------------------------------------------------------------------------
+void GP_Polygon(GP_Context *context, unsigned int vertex_count,
+ const GP_Coord *xy, GP_Pixel pixel);
+--------------------------------------------------------------------------------
+
+Draws a polygon.
+
+[source,c]
+--------------------------------------------------------------------------------
+void GP_FillPolygon(GP_Context *context, unsigned int vertex_count,
+ const GP_Coord *xy, GP_Pixel pixel);
+--------------------------------------------------------------------------------
+
+Draws a filled polygon.
+
+The coordinages are passed in [x0, y0, x1, y1, ...] order, the vertex count
+describes a number of nodes, i.e. half of the size of the array.
diff --git a/doc/gfxprim_logo.png b/doc/gfxprim_logo.png
index bee1c8b..5cf4f68 100644
Binary files a/doc/gfxprim_logo.png and b/doc/gfxprim_logo.png differ
diff --git a/doc/gfxprim_logo_prim.png b/doc/gfxprim_logo_prim.png
deleted file mode 100644
index 677ee0c..0000000
Binary files a/doc/gfxprim_logo_prim.png and /dev/null differ
diff --git a/doc/grabbers.txt b/doc/grabbers.txt
index 65dd71d..86bf056 100644
--- a/doc/grabbers.txt
+++ b/doc/grabbers.txt
@@ -5,8 +5,7 @@ Grabber is an abstraction for a device whose output is a stream of images.
There is currently V4L2 driver that implements a grabber.
-To link against grabbers use +-lGP_grabbers+ or better
-+`gfxprim-config --libs-grabbers`+ in your linker flags.
+Link with +-lGP_grabbers+ or better +`gfxprim-config --libs-grabbers`+.
TIP: For example usage see grabber link:example_v4l2.html[examples].
diff --git a/doc/index.html b/doc/index.html
deleted file mode 100644
index 905c1b7..0000000
--- a/doc/index.html
+++ /dev/null
@@ -1,92 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
- <link rel="icon" type="image/png" href="favicon.png">
- <title>GFXprim</title>
- <style type="text/css" title="currentStyle" media="screen">
- @import "style.css";
- </style>
- </head>
- <body>
- <div id="body">
- <div id="logo">
- <h1>
- <div id="logo_picture">
- <img src="gfxprim_logo.png" alt="GFXprim">
- </div>
- <div id="logo_picture_prim">
- <img src="gfxprim_logo_prim.png" alt="">
- </div>
- <div id="clever_line">
- <div style="display: block; text-align: right;">
- <img src="asteroids-corner.png" alt="asteroids" style="position: relative; right: 1em;">
- </div>
- What would you like to draw today...
- </div>
- </h1>
- </div>
- <div id="menu">
- <ul class="menu-tree">
- <li class="menu-tree-item"><a href="general.html">C API</a></li>
- <li class="menu-tree-item"><a href="core_python.html">Pyton API</a></li>
- <li class="menu-tree-item"><a href="http://www.ucw.cz/mailman/listinfo/gfxprim">Mailing List</a></li>
- <li class="menu-tree-item"><a href="https://github.com/gfxprim/gfxprim">GIT (GitHub)</a></li>
- <li class="menu-tree-item"><a href="http://repo.or.cz/w/gfxprim.git">GIT (repo.or.cz)</a></li>
- <li class="menu-tree-item"><a href="releases/gfxprim_1.0.0-rc0.tar.bz2">Download 1.0.0-rc0</a></li>
- </ul>
- </div>
- <div id="content">
- <h2>GFXprim</h2>
- <p>
- <i>GFXprim</i> is Open-source modular 2D bitmap graphics library
- with emphasis on speed and correctness.
- </p>
- <h3>License</h3>
- <p>
- The code is licensed under LGPL 2.1 or (at your opinion) any later.
- </p>
- <h3>About</h3>
- <p>
- Once upon the time <i>GFXprim</i> has started as a simple attempt to
- replace SDL_gfx which was unusable then. Soon it outgrew the initial
- purpose and yielded into a library that could be used as a replacement
- for the family of SDL libraries. In contrast with SDL <i>GFXprim</i> is
- not aiming for abstracting the operating system interface. Instead of
- that <i>GFXprim</i> provides means for keeping the system dependent parts
- in well defined and isolated parts.
- </p>
- <p>
- One of the key points of the library are code generators. Most of the
- graphics operations are written using <a href="http://jinja.pocoo.org/">jinja</a>
- templating engine which is used to create specialized C code. So,
- for an example, once you add pixel definition into configuration file,
- creating specialized filters, loaders and conversions to other pixel
- formats is just a matter of typing "make rebuild".
- </p>
- <h3>Documentation</h3>
- <p>
- For more information about features and API look at the
- <a href="general.html">documentation</a>.
- </p>
- <h3>News</h3>
- <p>
- <h4>The GFXprim version 1.0.0-rc0 has been released!</h4>
- Download <a href="http://gfxprim.ucw.cz/releases/gfxprim_1.0.0-rc0.tar.bz2">GFXprim 1.0.0-rc0</a> tarball (without docs).
- Or get the code from directly from <a href="http://github.com/gfxprim/gfxprim/">github</a>.
- </p>
- <h3>Contact</h3>
- <p>
- We do have a <a href="http://www.ucw.cz/mailman/listinfo/gfxprim">mailing list</a>
- and although there is not much of discussion now, we are there and listening.
- </p>
- </div>
- <div id="cleaner"> </div>
- <div id="footer">
- <a href="http://repo.or.cz/w/gfxprim.git">repo.or.cz</a> |
- <a href="https://github.com/gfxprim/gfxprim">GitHub</a> |
- <a href="http://www.ucw.cz/mailman/listinfo/gfxprim">Mailing List</a>
- </div>
- </div>
- </body>
-</html>
diff --git a/doc/index.txt b/doc/index.txt
new file mode 100644
index 0000000..4c3dff5
--- /dev/null
+++ b/doc/index.txt
@@ -0,0 +1,55 @@
+GFXprim
+-------
+
+'GFXprim' is Open-source modular 2D bitmap graphics library with emphasis on
+speed and correctness.
+
+The goal of the library is to provide simple but powerful API for applications
+that needs to work with bitmap graphics. The library itself started as a
+simple replacement for 'SDL_gfx' which was unusable at the time and soon it
+outgrew the initial purpose and became main topic of the development.
+
+GFXprim is not tied to a specific graphic system (such as X11) but on the
+other hand provides means to interact with them.
+
+GFXprim can load and save images in variety of formats, operate on the data on
+a pixel level, run image filters, render basic shapes or text, open and manage
+X11 windows, draw on Linux framebuffer and more.
+
+GFXprim also comes with link:core_python.html[Python bindings].
+
+There are a few example applications included, the most advanced is a
+link:spiv.html[spiv] image viewer which is already a full featured
+application.
+
+See the link:about.html[about page] for more detailed information.
+
+License
+-------
+
+The code is licensed under LGPL 2.1 or (at your opinion) any later.
+
+Bugs
+----
+
+Report bugs on the GFXprim
+http://www.ucw.cz/mailman/listinfo/gfxprim[mailing list].
+Eventually you can use GitHub
+https://github.com/gfxprim/gfxprim/issues[issue tracker].
+
+News
+----
+
+The GFXprim version 1.0.0-rc0 has been released!
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Download
+http://gfxprim.ucw.cz/releases/gfxprim_1.0.0-rc0.tar.bz2[1.0.0-rc0] tarball (without docs).
+
+Or get the code from directly from http://github.com/gfxprim/gfxprim/[github].
+
+Contact
+-------
+
+We do have a http://www.ucw.cz/mailman/listinfo/gfxprim[mailing list] and
+although there is not much of discussion now, we are there and listening.
diff --git a/doc/spiv.txt b/doc/spiv.txt
new file mode 100644
index 0000000..0b36e17
--- /dev/null
+++ b/doc/spiv.txt
@@ -0,0 +1,31 @@
+spiv
+----
+
+'spiv' - Simple yet Powerful Image Viewer.
+
+Spiv is a fast, lightweight and minimalistic image viewer build on the top of
+the GFXprim library.
+
+Spiv is optimized for keyboard control and although you can use your mouse for
+some of the actions, everything could be done from the keyboard as well.
+
+Spiv supports wide range of image formats, currently supported are JPEG, PNG,
+GIF, BMP, TIFF, PSP, PPM, JP2 and CBZ (as well general ZIP archives with
+images), and more will come in the near future.
+
+Spiv implements image caches with LRU (last recently used) algorithm which
+speeds up subsequent image operations (rotations, going back and forth).
+
+Spiv can also crawl a directory, there is no need to pass thousand of images
+file names via command line arguments.
+
+Spiv supports variety of video backends (via GFXprim backends) currently these
+are X11, Linux Framebuffer, SDL and AAlib. Spiv also supports wide range of
+backend pixel types from 1bit Grayscale to 32bit RGB with optional
+Floyd-Steinberg dithering (even, for example, from RGB888 to RGB565).
+
+Spiv implements feh-like image actions, which are short shell scripts with
+printf-like modifiers. The modifiers are substituted to current image path,
+name, etc. and executed by pressing function keys).
+
+See 'spiv(1)' man page for more information.
diff --git a/doc/style.css b/doc/style.css
deleted file mode 100644
index 27fa6f6..0000000
--- a/doc/style.css
+++ /dev/null
@@ -1,151 +0,0 @@
-body {
- background-color: #aaa;
- margin: 10pt;
- padding-left: 8%;
- padding-right: 8%;
-}
-
-h1 {
- background-color: transparent;
- border-top: 1px solid #bc8517;
- border-bottom: 1px solid #bc8517;
-}
-
-h2 {
- color: #bc6217;
- padding-bottom: .2em;
- border-bottom: 1px solid #db7521;
- font-weight: bolder;
-}
-
-h3 {
- color: Black;
- padding-top: 1em;
-}
-
-a, a:visited {
- color: #333;
- font-style: oblique;
- font-weight: bolder;
- text-decoration: none;
-}
-
-a:hover {
- color: #aaa;
- font-style: oblique;
- font-weight: bolder;
- text-decoration: none;
-}
-
-li {
- list-style-type: disc;
- margin-bottom: 4px;
-}
-
-pre {
- padding: .5em .5em .5em .5em;
- border: 1px solid Black;
- border-style: dashed;
- background-color: #bbc;
- display: inline-block;
-}
-
-/* main div */
-#body {
- color: Black;
- background-color: #ffffc7;
-}
-
-#logo_picture {
- position: relative;
- top: 0.1em;
- left: 0.5em;
- display: inline;
-}
-
-#logo_picture_prim {
- position: relative;
- display: inline;
- left: 0.2em;
- top: 30px;
-}
-
-#logo {
- background-color: #f7e177;
-}
-
-#clever_line {
- font-size: 40%;
- color: #bc6217;
- float: right;
- position: relative;
- top: 10px;
-}
-
-#content {
- padding: 0 2em 1em 12em;
-}
-
-#menu {
- float: left;
- color: #eee;
- width: 10em;
- margin: 0em 0em 1em 1em;
- padding: 0;
- border: 1px solid #bc6217;
- background-color: #f7e177;
-}
-
-#cleaner {
- clear: both;
-}
-
-#footer {
- background-color: #f7e177;
- text-align: center;
- padding-top: .3em;
- padding-bottom: .3em;
- color: #bc6217;
- border-top: 1px solid #bc6217;
- border-bottom: 1px solid #bc6217;
-}
-
-/* text markers */
-#term {
- font-variant: small-caps;
-}
-
-#path {
- font-style: italic;
-}
-
-#command {
- font-style: oblique;
-}
-
-/* right menu basic style */
-.menu-tree {
- line-height: 2em;
- margin: 0 0 0 1em;
- padding: 0;
-}
-
-.menu-tree-item {
- font-size: 89%;
- display: block;
- margin: 0;
- padding: 0;
-}
-
-.menu-tree-item a {
- font-variant: small-caps;
- text-decoration: none;
- font-style: normal;
- padding-top: 0.2em;
- padding-bottom: 0.25em;
- color: #db7521;
-}
-
-.menu-tree-item a:hover {
- color: #eee;
-}
diff --git a/doc/text_api.txt b/doc/text.txt
similarity index 97%
rename from doc/text_api.txt
rename to doc/text.txt
index 46f93f3..2ade0f5 100644
--- a/doc/text_api.txt
+++ b/doc/text.txt
@@ -1,16 +1,12 @@
Text
----
-
-NOTE: You may want to see the link:coordinate_system.html[coordinate system] first.
-
-Text
-~~~~
-
Text drawing is controlled by the <<TextStyle,GP_TextStyle>> structure. This
-structure carries the information about font, letter spacing and pixel
+structure carries information about font, letter spacing and pixel
multiplication and spacing. (If no font is specified, the default mono-space
font is used.)
+You may want to see the link:coordinate_system.html[coordinate system] first.
+
[source,c]
--------------------------------------------------------------------------------
#include <GP.h>
-----------------------------------------------------------------------
Summary of changes:
Makefile | 2 +-
configure | 3 +-
demos/spiv/Makefile | 4 +
doc/Makefile | 14 +--
doc/{general.txt => about.txt} | 24 ++--
doc/api.txt | 86 ---------------
doc/asciidoc.conf | 144 ++++++++++----------------
doc/asciidoc.css | 211 ++++++++++++++++----------------------
doc/backends.txt | 2 +-
doc/compilation.txt | 38 +++----
doc/favicon.png | Bin 768 -> 4929 bytes
doc/get_put_pixel.txt | 36 ++++++-
doc/{drawing_api.txt => gfx.txt} | 48 ++++++++-
doc/gfxprim_logo.png | Bin 11242 -> 8112 bytes
doc/gfxprim_logo_prim.png | Bin 4751 -> 0 bytes
doc/grabbers.txt | 3 +-
doc/index.html | 92 -----------------
doc/index.txt | 55 ++++++++++
doc/spiv.txt | 31 ++++++
doc/style.css | 151 ---------------------------
doc/{text_api.txt => text.txt} | 10 +--
install.sh | 1 -
pylib/gfxprim/text/text.i | 2 +
tests/Makefile | 1 +
24 files changed, 359 insertions(+), 599 deletions(-)
rename doc/{general.txt => about.txt} (90%)
delete mode 100644 doc/api.txt
rename doc/{drawing_api.txt => gfx.txt} (84%)
delete mode 100644 doc/gfxprim_logo_prim.png
delete mode 100644 doc/index.html
create mode 100644 doc/index.txt
create mode 100644 doc/spiv.txt
delete mode 100644 doc/style.css
rename doc/{text_api.txt => text.txt} (97%)
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
16 Oct '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 af3ab64dd671ec59cc44f58490401b96f48c66bc (commit)
via 6104f5d98b1793065962388fc1a17ae801358e32 (commit)
via b699a8f5b247291820a1a8e494d42cd033ae120f (commit)
from 21f49beeb9dfc819dd0b7f2b84118b83d02aa612 (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/af3ab64dd671ec59cc44f58490401b96f48c…
commit af3ab64dd671ec59cc44f58490401b96f48c66bc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 15 23:02:02 2013 +0200
build: Add check make target.
Which just runs check_symbols.sh script which looks if there are any
symbols exported by mistake.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/check_symbols.sh b/build/check_symbols.sh
index 245b324..641df38 100755
--- a/build/check_symbols.sh
+++ b/build/check_symbols.sh
@@ -76,4 +76,6 @@ if [ -n "$FOUND" ]; then
echo "Set them static or update lists of exported functions in syms/Foo_symbols.txt"
echo
echo "$WARN"
+else
+ echo "No unexpected symbols found :)"
fi
diff --git a/post.mk b/post.mk
index 0b9fc90..dbc6d13 100644
--- a/post.mk
+++ b/post.mk
@@ -29,12 +29,18 @@ help:
@echo ""
@echo "rebuild: does clean and all"
@echo ""
+ @echo "check: do pre-commit check"
+ @echo " (currently checks for exported symbols)"
+ @echo ""
@echo "The default silent output could be turned off by defining"
@echo "'VERBOSE' shell variable as 'VERBOSE=1 make'"
@echo ""
doc:
- cd doc && make
+ @cd $(TOPDIR)/doc && make
+
+check:
+ @cd $(TOPDIR)/build && ./check_symbols.sh
#
# Determine mode (eg do not generate anything if not in compile mode
http://repo.or.cz/w/gfxprim.git/commit/6104f5d98b1793065962388fc1a17ae80135…
commit 6104f5d98b1793065962388fc1a17ae801358e32
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 15 22:56:47 2013 +0200
build: Update list of exported symbols.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Text_symbols.txt b/build/syms/Text_symbols.txt
index 1b371e6..3b04747 100644
--- a/build/syms/Text_symbols.txt
+++ b/build/syms/Text_symbols.txt
@@ -15,6 +15,7 @@ GP_TextDescent
GP_TextClearStr
GP_Text
GP_Print
+GP_VPrint
GP_DefaultStyle
http://repo.or.cz/w/gfxprim.git/commit/b699a8f5b247291820a1a8e494d42cd033ae…
commit b699a8f5b247291820a1a8e494d42cd033ae120f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 15 22:56:11 2013 +0200
doc: Update general information.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/general.txt b/doc/general.txt
index 2c5bc9f..a2a9167 100644
--- a/doc/general.txt
+++ b/doc/general.txt
@@ -28,7 +28,7 @@ operations in Filters.
link:blits.html[Blits] are functions used to copy part of one bitmap into
another bitmap. The blits be also used for primitive bitmap pixel type
-conversions (i.e. RGB888 vs BGR888).
+conversions (i.e. RGB888 vs BGR888).
link:progress_callback.html[Progress Callback] is an interface that allows you
to monitor progress of an operation it is mainly used in loaders and filters.
@@ -134,9 +134,9 @@ image filters.
[width="100%",options="header"]
|=============================================================================
| Filter Name | Supported Pixel Type | Mutithreaded
-| Convolution | RGB888 | Yes
-| Separable Convolution | RGB888 | Yes
-| Gaussian Blur | RGB888 | Yes
+| Convolution | All | Yes
+| Separable Convolution | All | Yes
+| Gaussian Blur | All | Yes
| Sobel Edge Detection | RGB888 | Yes
| Prewitt Edge Detection | RGB888 | Yes
|=============================================================================
@@ -160,8 +160,8 @@ NOTE: Linear filters are implemented using generic convolution filters, once
[width="100%",options="header"]
|=============================================================================
| Filter Name | Supported Pixel Type | Multithreaded
- | Floyd Steinberg | RGB888 -> Any | No
-| Hilbert Peano | RGB888 -> Any | No
+| Floyd Steinberg | All -> Any | No
+| Hilbert Peano | All -> Any | No
|=============================================================================
.Currently Implemented Resamplings
-----------------------------------------------------------------------
Summary of changes:
build/check_symbols.sh | 2 ++
build/syms/Text_symbols.txt | 1 +
doc/general.txt | 12 ++++++------
post.mk | 8 +++++++-
4 files changed, 16 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
15 Oct '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 21f49beeb9dfc819dd0b7f2b84118b83d02aa612 (commit)
via 2ced0b701ab21aa80097e34669ba18a7bdd112b7 (commit)
via 50e78cb9a15435c9d009f40ca46c73d90bd99a2d (commit)
via b24b8b26fb9ef3841dc973e6d921da8b793ae42e (commit)
from dc4ff99fcfb3320e4627e7f7c35c09c916da0809 (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/21f49beeb9dfc819dd0b7f2b84118b83d02a…
commit 21f49beeb9dfc819dd0b7f2b84118b83d02aa612
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 15 22:23:38 2013 +0200
spiv: image_loader: Drop cur_img before dropping cache.
The image loader keeps reference to the top image, if drop cache is
called the top image is freed with the rest of the cache so we need to
drop the currently used image beforhand.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/image_loader.c b/demos/spiv/image_loader.c
index ae4ac6d..e03426e 100644
--- a/demos/spiv/image_loader.c
+++ b/demos/spiv/image_loader.c
@@ -230,6 +230,7 @@ unsigned int image_loader_dir_pos(void)
void image_loader_drop_cache(void)
{
+ drop_cur_img();
image_cache_drop(img_cache);
}
http://repo.or.cz/w/gfxprim.git/commit/2ced0b701ab21aa80097e34669ba18a7bdd1…
commit 2ced0b701ab21aa80097e34669ba18a7bdd112b7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 15 22:14:16 2013 +0200
backends: Implement ResizeAck() for virtual backend.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_BackendVirtual.c b/libs/backends/GP_BackendVirtual.c
index 5ebf621..fd1c2d2 100644
--- a/libs/backends/GP_BackendVirtual.c
+++ b/libs/backends/GP_BackendVirtual.c
@@ -115,6 +115,21 @@ static void virt_exit(GP_Backend *self)
free(self);
}
+static int virt_resize_ack(GP_Backend *self)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+ int ret;
+
+ ret = virt->backend->ResizeAck(virt->backend);
+
+ if (ret)
+ return ret;
+
+ return GP_ContextResize(self->context,
+ virt->backend->context->w,
+ virt->backend->context->h);
+}
+
GP_Backend *GP_BackendVirtualInit(GP_Backend *backend,
GP_PixelType pixel_type, int flags)
{
@@ -147,6 +162,7 @@ GP_Backend *GP_BackendVirtualInit(GP_Backend *backend,
self->Flip = virt_flip;
self->UpdateRect = virt_update_rect;
self->Exit = virt_exit;
+ self->ResizeAck = virt_resize_ack;
self->Poll = backend->Poll ? virt_poll : NULL;
self->Wait = backend->Wait ? virt_wait : NULL;
self->SetAttributes = backend->SetAttributes ? virt_set_attrs : NULL;
http://repo.or.cz/w/gfxprim.git/commit/50e78cb9a15435c9d009f40ca46c73d90bd9…
commit 50e78cb9a15435c9d009f40ca46c73d90bd99a2d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 15 22:11:20 2013 +0200
spiv: Add forgotten -e config opt
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv_config.c b/demos/spiv/spiv_config.c
index 08b2f63..44a16d1 100644
--- a/demos/spiv/spiv_config.c
+++ b/demos/spiv/spiv_config.c
@@ -311,6 +311,7 @@ struct cfg_opt spiv_opts[] = {
},
{.name_space = "Devel",
.key = "BackendEmulation",
+ .opt = 'e',
.opt_long = "backend-emulation",
.opt_has_value = 1,
.set = set_emulation,
http://repo.or.cz/w/gfxprim.git/commit/b24b8b26fb9ef3841dc973e6d921da8b793a…
commit b24b8b26fb9ef3841dc973e6d921da8b793ae42e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 15 22:01:18 2013 +0200
filters: ditherings: Enable all pixel types.
Make ditherings work with all pixel types.
Add conversion from any pixel type to RGB888 before the dithering is
done. While this is not 100% correct solution it's good enough for the
time being.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_FloydSteinberg.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t
index 32a2534..f38cb8c 100644
--- a/libs/filters/GP_FloydSteinberg.gen.c.t
+++ b/libs/filters/GP_FloydSteinberg.gen.c.t
@@ -50,11 +50,11 @@
%% for pt in pixeltypes
%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
/*
- * Floyd Steinberg RGB888 to {{ pt.name }}
+ * Floyd Steinberg to {{ pt.name }}
*/
-static int floyd_steinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback)
+static int floyd_steinberg_to_{{ pt.name }}_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
{
%% for c in pt.chanslist
float errors_{{ c[0] }}[2][src->w];
@@ -74,7 +74,10 @@ static int floyd_steinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src,
for (y = 0; y < (GP_Coord)src->h; y++) {
for (x = 0; x < (GP_Coord)src->w; x++) {
- GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, x, y);
+ GP_Pixel pix;
+
+ pix = GP_GetPixel_Raw(src, x, y);
+ pix = GP_PixelToRGB888(pix, src->pixel_type);
%% for c in pt.chanslist
%% if pt.is_gray()
@@ -131,7 +134,7 @@ static int floyd_steinberg(const GP_Context *src, GP_Context *dst,
%% for pt in pixeltypes
%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
case GP_PIXEL_{{ pt.name }}:
- return floyd_steinberg_RGB888_to_{{ pt.name }}_Raw(src, dst, callback);
+ return floyd_steinberg_to_{{ pt.name }}_Raw(src, dst, callback);
%% endif
%% endfor
default:
@@ -145,11 +148,6 @@ int GP_FilterFloydSteinberg(const GP_Context *src, GP_Context *dst,
GP_CHECK(src->w <= dst->w);
GP_CHECK(src->h <= dst->h);
- if (src->pixel_type != GP_PIXEL_RGB888) {
- errno = ENOSYS;
- return 1;
- }
-
return floyd_steinberg(src, dst, callback);
}
@@ -160,11 +158,6 @@ GP_Context *GP_FilterFloydSteinbergAlloc(const GP_Context *src,
{
GP_Context *ret;
- if (src->pixel_type != GP_PIXEL_RGB888) {
- errno = ENOSYS;
- return NULL;
- }
-
ret = GP_ContextAlloc(src->w, src->h, pixel_type);
if (ret == NULL)
diff --git a/libs/filters/GP_HilbertPeano.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t
index c1660e4..46a3eb9 100644
--- a/libs/filters/GP_HilbertPeano.gen.c.t
+++ b/libs/filters/GP_HilbertPeano.gen.c.t
@@ -56,9 +56,9 @@ static unsigned int count_bits(unsigned int n)
/*
* Hilbert Peano RGB888 to {{ pt.name }}
*/
-static int hilbert_peano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback)
+static int hilbert_peano_to_{{ pt.name }}_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
{
struct GP_CurveState state;
unsigned int n;
@@ -79,7 +79,10 @@ static int hilbert_peano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src,
while (GP_HilbertCurveContinues(&state)) {
if (state.x < src->w && state.y < src->h) {
- GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, state.x, state.y);
+ GP_Pixel pix;
+
+ pix = GP_GetPixel_Raw(src, state.x, state.y);
+ pix = GP_PixelToRGB888(pix, src->pixel_type);
%% for c in pt.chanslist
%% if pt.is_gray()
@@ -141,7 +144,7 @@ static int hilbert_peano(const GP_Context *src, GP_Context *dst,
%% for pt in pixeltypes
%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
case GP_PIXEL_{{ pt.name }}:
- return hilbert_peano_RGB888_to_{{ pt.name }}_Raw(src, dst, callback);
+ return hilbert_peano_to_{{ pt.name }}_Raw(src, dst, callback);
%% endif
%% endfor
default:
@@ -155,11 +158,6 @@ int GP_FilterHilbertPeano(const GP_Context *src, GP_Context *dst,
GP_CHECK(src->w <= dst->w);
GP_CHECK(src->h <= dst->h);
- if (src->pixel_type != GP_PIXEL_RGB888) {
- errno = ENOSYS;
- return 1;
- }
-
return hilbert_peano(src, dst, callback);
}
@@ -169,11 +167,6 @@ GP_Context *GP_FilterHilbertPeanoAlloc(const GP_Context *src,
{
GP_Context *ret;
- if (src->pixel_type != GP_PIXEL_RGB888) {
- errno = ENOSYS;
- return NULL;
- }
-
ret = GP_ContextAlloc(src->w, src->h, pixel_type);
if (ret == NULL)
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/image_loader.c | 1 +
demos/spiv/spiv_config.c | 1 +
libs/backends/GP_BackendVirtual.c | 16 ++++++++++++++++
libs/filters/GP_FloydSteinberg.gen.c.t | 25 +++++++++----------------
libs/filters/GP_HilbertPeano.gen.c.t | 23 ++++++++---------------
5 files changed, 35 insertions(+), 31 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
14 Oct '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 dc4ff99fcfb3320e4627e7f7c35c09c916da0809 (commit)
via 67843356569850ec5c7f6e4e77c55dcb97fc6721 (commit)
via 12806aae7921c0e11b2908d3bb842f294d1acdab (commit)
via e66493630e62bac979731f58c0232c14c1f699d9 (commit)
via d12cf1d15e383df010846ee3a53a36cc7ac64724 (commit)
via 6c19433d1a062473a6bdc2a21b67168d3cec04fd (commit)
via 15db0fc3351d6a78f3f654defde550aaf8813a7d (commit)
via 5adcb7f068d9c8814fc1abecea76de442a3267bc (commit)
via 8dba9bc6f1f94b008a6f4475d0af9d1e8c810f36 (commit)
from 3d14cb78419fe54e86e6a838b919a303ae9e536f (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/dc4ff99fcfb3320e4627e7f7c35c09c916da…
commit dc4ff99fcfb3320e4627e7f7c35c09c916da0809
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Oct 10 22:39:59 2013 +0200
spiv: Rewrite configuration, add config file.
* Rewrite spiv command line parameters parsing
(adds long options)
* Add support for configuration files
(now it tries /etc/spiv.conf and ~/.spiv)
* Add --print-man switch to generate man page
Not finished yet, more will come soon.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/Makefile b/demos/spiv/Makefile
index 93750f3..80cfa29 100644
--- a/demos/spiv/Makefile
+++ b/demos/spiv/Makefile
@@ -12,7 +12,7 @@ LDLIBS+=$(LDLIBS_LOADERS) $(LDLIBS_BACKENDS)
APPS=spiv
spiv: cpu_timer.o image_cache.o image_list.o image_actions.o spiv_help.o- image_loader.o
+ image_loader.o cfg.o spiv_config.o
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
diff --git a/demos/spiv/cfg.c b/demos/spiv/cfg.c
new file mode 100644
index 0000000..629929d
--- /dev/null
+++ b/demos/spiv/cfg.c
@@ -0,0 +1,525 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <core/GP_Debug.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <getopt.h>
+
+#include "cfg.h"
+
+static int terminal(struct cfg_opt *opt)
+{
+ return opt->key == NULL && opt->opt == 0 && opt->opt_long == NULL;
+}
+
+struct cfg_opt *opt_by_key(struct cfg_opt *cfg_opts, const char *name_space,
+ const char *key)
+{
+ struct cfg_opt *i;
+
+ GP_DEBUG(1, "Looking for key '%s' in name space '%s'",
+ key, name_space);
+
+ for (i = cfg_opts; !terminal(i); i++) {
+ if (name_space == NULL) {
+ if (i->name_space == NULL && !strcmp(key, i->key))
+ break;
+ } else {
+ if (i->name_space != NULL && !strcmp(key, i->key))
+ break;
+ }
+ }
+
+ if (terminal(i))
+ return NULL;
+
+ return i;
+}
+
+int cfg_getopt(struct cfg_opt *opts, int argc, char *argv[])
+{
+ unsigned int count = 0;
+ unsigned int long_count = 0;
+ struct cfg_opt *i;
+ int c, opt_idx;
+
+ for (i = opts; !terminal(i); i++) {
+ if (i->opt) {
+ count++;
+
+ if (i->opt_has_value)
+ count++;
+ }
+
+ if (i->opt_long)
+ long_count++;
+ }
+
+ char gopt[count+1];
+ struct option gopt_long[long_count+1];
+ struct cfg_opt *gopts_long[long_count+1];
+ struct cfg_opt *gopts[256];
+
+ memset(gopt_long, 0, sizeof(gopt_long));
+ memset(gopts, 0, sizeof(gopts));
+
+ count = 0;
+ long_count = 0;
+
+ for (i = opts; !terminal(i); i++) {
+ if (i->opt) {
+ gopt[count++] = i->opt;
+
+ if (i->opt_has_value)
+ gopt[count++] = ':';
+
+ if ((unsigned)i->opt >= sizeof(gopts)/(sizeof(*gopts))) {
+ GP_WARN("Char value > 256???");
+ } else {
+ gopts[(unsigned)i->opt] = i;
+ }
+ }
+
+ if (i->opt_long) {
+ gopt_long[long_count].name = i->opt_long;
+ gopt_long[long_count].has_arg = i->opt_has_value;
+ gopt_long[long_count].flag = NULL;
+ gopt_long[long_count].val = 0;
+ gopts_long[long_count] = i;
+ long_count++;
+ }
+ }
+
+ gopt[count] = 0;
+
+ GP_DEBUG(1, "Have getopt string '%s' and %u long opts",
+ gopt, long_count);
+
+ for (;;) {
+ c = getopt_long(argc, argv, gopt, gopt_long, &opt_idx);
+
+ switch (c) {
+ case -1:
+ return optind;
+ case 0:
+ GP_DEBUG(2, "Long option '%s'",
+ gopts_long[opt_idx]->opt_long);
+
+ i = gopts_long[opt_idx];
+ i->val = optarg;
+
+ if (i->set(i, 0))
+ return -1;
+ break;
+ default:
+ GP_DEBUG(2, "Short option '%c'", c);
+
+ if ((unsigned)((char)c) >= sizeof(gopts)/(sizeof(*gopts))) {
+ GP_WARN("Getopt returned %i???", c);
+ break;
+ }
+
+ i = gopts[(unsigned)((char)c)];
+
+ if (!i)
+ return -1;
+
+ i->val = optarg;
+
+ if (i->set(i, 0))
+ return -1;
+ break;
+ }
+
+ }
+}
+
+struct parser_state {
+ struct cfg_opt *opts;
+ unsigned int lineno;
+ FILE *f;
+ char name_space[128];
+ char buf[1024];
+};
+
+static void parser_error(struct parser_state *state, const char *fmt, ...)
+ __attribute__ ((format (printf, 2, 3)));
+
+static void parser_error(struct parser_state *state, const char *fmt, ...)
+{
+ va_list va;
+
+ fprintf(stderr, "ERROR: %u: ", state->lineno);
+ va_start(va, fmt);
+ vfprintf(stderr, fmt, va);
+ va_end(va);
+ fprintf(stderr, "n");
+}
+
+static void read_comment(struct parser_state *state)
+{
+ int c;
+
+ for (;;) {
+ c = getc_unlocked(state->f);
+
+ switch (c) {
+ case EOF:
+ return;
+ case 'n':
+ state->lineno++;
+ return;
+ default:
+ break;
+ }
+ }
+}
+
+static int parse_namespace(struct parser_state *state)
+{
+ size_t len = 0;
+ int c;
+
+ for (;;) {
+ c = getc_unlocked(state->f);
+
+ switch (c) {
+ case EOF:
+ parser_error(state,
+ "End of file while parsing namespace");
+ return 1;
+ case 'n':
+ parser_error(state, "Newline while parsing namespace");
+ return 1;
+ case ']':
+ state->name_space[len] = '0';
+ return 0;
+ default:
+ state->name_space[len++] = c;
+
+ if (len >= sizeof(state->name_space)) {
+ parser_error(state, "Namespace too long");
+ return 1;
+ }
+ break;
+ }
+ }
+
+
+ GP_DEBUG(1, "In namespace '%s'", state->name_space);
+}
+
+static int read_key(struct parser_state *state)
+{
+ size_t len = 0;
+ int c;
+
+ for (;;) {
+ c = getc_unlocked(state->f);
+
+ switch (c) {
+ case 'n':
+ state->lineno++;
+ case EOF:
+ case ' ':
+ case 't':
+ state->buf[len] = '0';
+ GP_DEBUG(1, "Have key '%s'", state->buf);
+ return 0;
+ default:
+ state->buf[len++] = c;
+
+ if (len >= sizeof(state->buf)) {
+ state->buf[sizeof(state->buf) - 1] = '0';
+ parser_error(state, "Key '%s...' is too long",
+ state->buf);
+ return 1;
+ }
+ break;
+ }
+ }
+}
+
+static void read_whitespaces(struct parser_state *state)
+{
+ int c;
+
+ for (;;) {
+ c = getc_unlocked(state->f);
+
+ switch (c) {
+ case 'n':
+ state->lineno++;
+ case ' ':
+ case 't':
+ break;
+ case EOF:
+ return;
+ default:
+ ungetc(c, state->f);
+ return;
+ }
+ }
+}
+
+static const char *name_space(struct parser_state *state)
+{
+ if (state->name_space[0])
+ return state->name_space;
+
+ return NULL;
+}
+
+static int parse_pair(struct parser_state *state)
+{
+ struct cfg_opt *opt;
+ int c;
+
+ if (read_key(state))
+ return 1;
+
+ opt = opt_by_key(state->opts, name_space(state), state->buf);
+
+ if (!opt) {
+ parser_error(state, "There is no key '%s' in name space '%s'",
+ state->buf, name_space(state));
+ return 1;
+ }
+
+ if (!opt->opt_has_value) {
+ if (opt->set(opt, state->lineno))
+ return 1;
+
+ return 0;
+ }
+
+ read_whitespaces(state);
+
+ c = fgetc_unlocked(state->f);
+
+ switch (c) {
+ case EOF:
+ parser_error(state, "End of file while looking for =");
+ return 1;
+ case '=':
+ break;
+ default:
+ parser_error(state, "Expected = got '%c'", c);
+ }
+
+ read_whitespaces(state);
+
+ //TODO write read val with quotation marks and poker
+ if (read_key(state))
+ return 1;
+
+ opt->val = state->buf;
+
+ if (opt->set(opt, state->lineno))
+ return 1;
+
+ return 0;
+}
+
+static int parse_cfg(struct parser_state *state)
+{
+ int c;
+
+ for (;;) {
+ c = getc_unlocked(state->f);
+
+ switch (c) {
+ case EOF:
+ GP_DEBUG(1, "End of config reached at %u",
+ state->lineno);
+ return 0;
+ case 'n':
+ state->lineno++;
+ case ' ':
+ case 't':
+ break;
+ case '#':
+ read_comment(state);
+ break;
+ case '[':
+ if (parse_namespace(state))
+ return 1;
+ break;
+ default:
+ ungetc(c, state->f);
+ if (parse_pair(state))
+ return 1;
+ break;
+ }
+ }
+}
+
+int cfg_load(struct cfg_opt *opts, const char *path)
+{
+ struct parser_state state;
+ int ret;
+
+ state.opts = opts;
+ state.lineno = 1;
+ state.f = fopen(path, "r");
+ state.name_space[0] = '0';
+
+ if (!state.f) {
+ GP_WARN("Failed to open '%s': %s'", path, strerror(errno));
+ return 1;
+ }
+
+ ret = parse_cfg(&state);
+ fclose(state.f);
+
+ return ret;
+}
+
+const char *has_value(struct cfg_opt *opt)
+{
+ if (opt->opt_has_value)
+ return "=value";
+
+ return "";
+}
+
+void cfg_print_help(struct cfg_opt *opts)
+{
+ struct cfg_opt *i;
+ const char *name_space = NULL;
+
+ printf("n");
+
+ for (i = opts; !terminal(i); i++) {
+ if ((name_space && !i->name_space) ||
+ (name_space && strcmp(i->name_space, name_space)) ||
+ (!name_space && i->name_space)) {
+
+ printf("n");
+
+ if (i->name_space)
+ printf(" %s:n", i->name_space);
+
+ name_space = i->name_space;
+ }
+
+ if (i->opt && !i->opt_long)
+ printf(" -%c%sn", i->opt, has_value(i));
+
+ if (!i->opt && i->opt_long)
+ printf(" --%s%sn", i->opt_long, has_value(i));
+
+ if (i->opt && i->opt_long) {
+ printf(" -%c%s, --%s%sn", i->opt, has_value(i),
+ i->opt_long, has_value(i));
+ }
+
+ if (i->help)
+ printf(" t%snn", i->help);
+ }
+}
+
+static void man_escape_print(const char *str)
+{
+ while (*str) {
+ switch (*str) {
+ case '-':
+ printf("\-");
+ break;
+ default:
+ printf("%c", *str);
+ break;
+ }
+ str++;
+ }
+}
+
+void cfg_print_man(struct cfg_opt *opts)
+{
+ struct cfg_opt *i;
+ const char *name_space = NULL;
+
+ printf(".SH OPTIONSn");
+
+ for (i = opts; !terminal(i); i++) {
+ if ((name_space && !i->name_space) ||
+ (name_space && strcmp(i->name_space, name_space)) ||
+ (!name_space && i->name_space)) {
+
+ if (i->name_space)
+ printf(".TPn.I %sn", i->name_space);
+
+ name_space = i->name_space;
+ }
+
+ if (i->opt || i->opt_long)
+ printf(".TPn");
+
+ if (i->opt && !i->opt_long)
+ printf(".B \-%c%sn", i->opt, has_value(i));
+
+ if (!i->opt && i->opt_long)
+ printf(".B \-\-");
+
+ if (i->opt && i->opt_long)
+ printf(".B \-%c%s, \-\-", i->opt, has_value(i));
+
+ if (i->opt_long) {
+ man_escape_print(i->opt_long);
+ printf("%sn", has_value(i));
+ }
+
+ if (i->help) {
+ man_escape_print(i->help);
+ printf("n");
+ }
+ }
+
+ printf(".SH CONFIGURATION FILEn");
+
+ printf("Configuraton file has simple key = value syntax, ");
+ printf("keys without values are written just as key.n");
+ printf("Lines started with # are comments.n");
+ printf("Keys are grouped in namespaces, namespace block is startedn");
+ printf("by [NameSpace] and continues until next namespace.n");
+
+ name_space = NULL;
+
+ for (i = opts; !terminal(i); i++) {
+ if ((name_space && !i->name_space) ||
+ (name_space && strcmp(i->name_space, name_space)) ||
+ (!name_space && i->name_space)) {
+ if (i->name_space)
+ printf(".TPn.I [%s]n", i->name_space);
+
+ name_space = i->name_space;
+ }
+ if (i->key) {
+ printf(".TPn.B %s%sn", i->key, has_value(i));
+ if (i->help)
+ printf("%sn", i->help);
+ }
+ }
+}
diff --git a/demos/spiv/cfg.h b/demos/spiv/cfg.h
new file mode 100644
index 0000000..49107b7
--- /dev/null
+++ b/demos/spiv/cfg.h
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+ /*
+
+ Configuration loader/storage.
+
+ Configuration is simple namespace,key -> value storage, the configuration
+ could either be loaded from config file and/or overriden by argumant parser.
+
+ */
+
+#ifndef __CFG_H__
+#define __CFG_H__
+
+struct cfg_opt {
+ /* Could be NULL for global values */
+ const char *name_space;
+ /* Must be set */
+ const char *key;
+ /* Short command line option, i.e. -f */
+ const char opt;
+ /* Long command option, i.e. --foo */
+ const char *opt_long;
+ /* set to 1 if option has parameter */
+ int opt_has_value;
+ /* help string */
+ const char *help;
+ /* setter function, called for each parset key = val pair */
+ int (*set)(struct cfg_opt *self, unsigned int lineno);
+ /* pointer to pass value from parser */
+ const char *val;
+};
+
+/*
+ * Loads configuration from a file.
+ *
+ * Returns zero on success, non-zero on failure (and prints error message into
+ * stderr).
+ */
+int cfg_load(struct cfg_opt *opts, const char *path);
+
+/*
+ * Parses configuration options from command line parameters.
+ *
+ * Returns number of used strings from argv on success, -1 on failure.
+ */
+int cfg_getopt(struct cfg_opt *opts, int argc, char *argv[]);
+
+/*
+ * Prints help for switches.
+ */
+void cfg_print_help(struct cfg_opt *opts);
+
+/*
+ * Prints man-page formatted options + config.
+ */
+void cfg_print_man(struct cfg_opt *opts);
+
+#endif /* __CFG_H__ */
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 076bea3..4b2d414 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -26,7 +26,6 @@
*/
-#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
@@ -39,6 +38,7 @@
#include "image_loader.h"
#include "image_actions.h"
#include "spiv_help.h"
+#include "spiv_config.h"
#include "cpu_timer.h"
static GP_Pixel black_pixel;
@@ -80,19 +80,11 @@ struct loader_params {
/* current resize ratio */
float rat;
- /* show loader progress */
- long show_progress:1;
long show_progress_once:2;
- /* show image info in topleft corner */
- long show_info:3;
/* use nearest neighbour resampling first */
long show_nn_first:4;
- /* use dithering when blitting to display */
- long use_dithering:5;
/* use low pass before resampling */
long use_low_pass:6;
- /* image orientation 0, 90, 180, 270 */
- int orientation;
/* resampling method */
int resampling_method;
@@ -278,7 +270,7 @@ static void show_info(struct loader_params *params, GP_Context *img,
set_caption(img_path, params->rat);
- if (!params->show_info)
+ if (!config.show_info)
return;
GP_Size th = GP_TextHeight(NULL);
@@ -314,18 +306,18 @@ static void update_display(struct loader_params *params, GP_Context *img,
struct cpu_timer timer;
GP_ProgressCallback callback = {.callback = image_loader_callback};
- switch (params->orientation) {
- case 0:
+ switch (config.orientation) {
+ case ROTATE_0:
break;
- case 90:
+ case ROTATE_90:
callback.priv = "Rotating image (90)";
img = GP_FilterRotate90Alloc(img, &callback);
break;
- case 180:
+ case ROTATE_180:
callback.priv = "Rotating image (180)";
img = GP_FilterRotate180Alloc(img, &callback);
break;
- case 270:
+ case ROTATE_270:
callback.priv = "Rotating image (270)";
img = GP_FilterRotate270Alloc(img, &callback);
break;
@@ -354,7 +346,7 @@ static void update_display(struct loader_params *params, GP_Context *img,
cpu_timer_start(&timer, "Blitting");
- if (params->use_dithering) {
+ if (config.floyd_steinberg) {
callback.priv = "Dithering";
GP_SubContext(context, &sub_display, cx, cy, img->w, img->h);
GP_FilterFloydSteinberg(img, &sub_display, NULL);
@@ -384,7 +376,7 @@ static void update_display(struct loader_params *params, GP_Context *img,
show_info(params, img, orig_img);
- if (params->orientation)
+ if (config.orientation)
GP_ContextFree(img);
GP_BackendFlip(backend);
@@ -472,13 +464,13 @@ static float calc_img_size(struct loader_params *params,
float w_rat;
float h_rat;
- switch (params->orientation) {
- case 0:
- case 180:
+ switch (config.orientation) {
+ case ROTATE_0:
+ case ROTATE_180:
default:
break;
- case 90:
- case 270:
+ case ROTATE_90:
+ case ROTATE_270:
GP_SWAP(src_w, src_h);
break;
}
@@ -509,7 +501,7 @@ static void *image_loader(void *ptr)
cpu_timer_start(&sum_timer, "sum");
- show_progress = params->show_progress || params->show_progress_once;
+ show_progress = config.show_progress || params->show_progress_once;
params->show_progress_once = 0;
if ((orig_img = load_image(0)) == NULL) {
@@ -679,18 +671,12 @@ static uint32_t timer_callback(GP_Timer *self)
int main(int argc, char *argv[])
{
GP_Context *context = NULL;
- const char *backend_opts = "X11";
- int opt;
int shift_flag;
- GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
+ int opts;
struct loader_params params = {
- .show_progress = 0,
.show_progress_once = 0,
- .show_info = 0,
.show_nn_first = 0,
- .use_dithering = 0,
- .orientation = 0,
.resampling_method = GP_INTERP_LINEAR_LF_INT,
.zoom_type = ZOOM_FIT,
@@ -703,77 +689,29 @@ int main(int argc, char *argv[])
GP_TIMER_DECLARE(timer, 0, 0, "Slideshow", timer_callback, ¶ms);
- while ((opt = getopt(argc, argv, "b:ce:fhIPr:s:tz:0:1:2:3:4:5:6:7:8:9:")) != -1) {
- switch (opt) {
- case 'I':
- params.show_info = 1;
- break;
- case 'P':
- params.show_progress = 1;
- break;
- case 'f':
- params.use_dithering = 1;
- break;
- case 's':
- params.sleep_ms = 1000 * atof(optarg) + 0.5;
- break;
- case 'c':
- params.resampling_method = GP_INTERP_CUBIC_INT;
- /* Cubic resampling needs low pass */
- params.use_low_pass = 1;
- /* Cubic resampling is slow, show nn first */
- params.show_nn_first = 1;
- break;
- case 'e':
- emul_type = GP_PixelTypeByName(optarg);
-
- if (emul_type == GP_PIXEL_UNKNOWN) {
- fprintf(stderr, "Invalid pixel type '%s'n", optarg);
- return 1;
- }
- break;
- case 'r':
- if (!strcmp(optarg, "90"))
- params.orientation = 90;
- else if (!strcmp(optarg, "180"))
- params.orientation = 180;
- else if (!strcmp(optarg, "270"))
- params.orientation = 270;
- case 'b':
- backend_opts = optarg;
- break;
- case 'h':
- print_help();
- exit(0);
- break;
- case 't':
- cpu_timer_switch(1);
- break;
- case 'z':
- switch (optarg[0]) {
- case 'f':
- params.zoom_type = ZOOM_FIXED;
- break;
- case 'w':
- params.zoom_type = ZOOM_FIXED_WIN;
- break;
- }
- break;
- case '0':
- /* -0 is mapped to action 10 */
- image_action_set(9, optarg);
- break;
- case '1' ... '9':
- image_action_set(opt - '1', optarg);
- break;
- default:
- fprintf(stderr, "Invalid paramter '%c'n", opt);
- print_help();
- return 1;
- }
+ if (access("/etc/spiv.conf", R_OK) == 0)
+ spiv_config_load("/etc/spiv.conf");
+
+ if (getenv("HOME")) {
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "%s/%s", getenv("HOME"), ".spiv");
+
+ if (access(buf, R_OK) == 0)
+ spiv_config_load(buf);
}
- if (optind >= argc) {
+ opts = spiv_config_parse_args(argc, argv);
+
+ if (opts < 0) {
+ print_help();
+ return 1;
+ }
+
+ cpu_timer_switch(config.timers);
+ params.sleep_ms = 1000 * config.slideshow_delay + 0.5;
+
+ if (opts >= argc) {
fprintf(stderr, "Requires path to at least one imagenn");
print_help();
return 1;
@@ -784,13 +722,15 @@ int main(int argc, char *argv[])
signal(SIGBUS, sighandler);
signal(SIGABRT, sighandler);
- if (init_loader(¶ms, (const char **)argv + optind))
+ if (init_loader(¶ms, (const char **)argv + opts))
return 1;
- init_backend(backend_opts);
+ init_backend(config.backend_init);
- if (emul_type != GP_PIXEL_UNKNOWN)
- backend = GP_BackendVirtualInit(backend, emul_type, GP_BACKEND_CALL_EXIT);
+ if (config.emul_type != GP_PIXEL_UNKNOWN) {
+ backend = GP_BackendVirtualInit(backend, config.emul_type,
+ GP_BACKEND_CALL_EXIT);
+ }
context = backend->context;
@@ -849,18 +789,28 @@ int main(int argc, char *argv[])
GP_BackendX11RequestFullscreen(backend, 2);
break;
case GP_KEY_I:
- params.show_info = !params.show_info;
+ config.show_info = !config.show_info;
params.show_progress_once = 1;
show_image(¶ms);
break;
case GP_KEY_P:
- params.show_progress = !params.show_progress;
+ config.show_progress = !config.show_progress;
break;
case GP_KEY_R:
- params.orientation += 90;
- if (params.orientation > 270)
- params.orientation = 0;
+ config.orientation++;
+
+ if (config.orientation > ROTATE_270)
+ config.orientation = 0;
+
+ params.show_progress_once = 1;
+ show_image(¶ms);
+ break;
+ case GP_KEY_E:
+ if (config.orientation > 0)
+ config.orientation--;
+ else
+ config.orientation = ROTATE_270;
params.show_progress_once = 1;
show_image(¶ms);
diff --git a/demos/spiv/spiv_config.c b/demos/spiv/spiv_config.c
new file mode 100644
index 0000000..08b2f63
--- /dev/null
+++ b/demos/spiv/spiv_config.c
@@ -0,0 +1,348 @@
+/*****************************************************************************
+ * 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 <stdlib.h>
+#include <string.h>
+
+#include "cfg.h"
+#include "image_actions.h"
+#include "spiv_config.h"
+
+/*
+ * These are default config values, you can hardcompile yours here.
+ */
+struct spiv_config config = {
+ .slideshow_delay = 0,
+ .show_info = 0,
+ .backend_init = "X11",
+ .emul_type = GP_PIXEL_UNKNOWN,
+};
+
+static int set_zoom_strategy(struct cfg_opt *self, unsigned int lineno)
+{
+ (void) lineno;
+ //TODO!!!
+ printf("ZoomStrategy = %sn", self->val);
+
+ return 0;
+}
+
+static int set_action(struct cfg_opt *self, unsigned int lineno)
+{
+ (void) lineno;
+ image_action_set(atoi(self->key), self->val);
+ return 0;
+}
+
+static int set_opt(struct cfg_opt *self, unsigned int lineno)
+{
+ (void) self;
+ (void) lineno;
+
+ switch (self->opt) {
+ case 'f':
+ config.floyd_steinberg = 1;
+ break;
+ case 'i':
+ config.show_info = 1;
+ break;
+ case 'p':
+ config.show_progress = 1;
+ break;
+ case 't':
+ config.timers = 1;
+ break;
+ }
+
+ return 0;
+}
+
+static int set_orientation(struct cfg_opt *self, unsigned int lineno)
+{
+ if (!strcmp("0", self->val)) {
+ config.orientation = ROTATE_0;
+ return 0;
+ }
+
+ if (!strcmp("90", self->val)) {
+ config.orientation = ROTATE_90;
+ return 0;
+ }
+
+ if (!strcmp("180", self->val)) {
+ config.orientation = ROTATE_180;
+ return 0;
+ }
+
+ if (!strcmp("270", self->val)) {
+ config.orientation = ROTATE_270;
+ return 0;
+ }
+
+ fprintf(stderr, "ERROR: %u: Invalid orientation '%s'n",
+ lineno, self->val);
+ return 1;
+}
+
+static int set_backend_init(struct cfg_opt *self, unsigned int lineno)
+{
+ if (strlen(self->val) + 1 >= sizeof(config.backend_init)) {
+ fprintf(stderr, "ERROR: %u: Backend init string too longn",
+ lineno);
+ return 1;
+ }
+
+ strcpy(config.backend_init, self->val);
+
+ return 0;
+}
+
+static int set_slideshow(struct cfg_opt *self, unsigned int lineno)
+{
+ config.slideshow_delay = atof(self->val);
+
+ if (config.slideshow_delay == 0) {
+ fprintf(stderr, "ERROR: %u: Invalid slideshow delay '%s'n",
+ lineno, self->val);
+ return 1;
+ }
+
+ return 0;
+}
+
+static int set_emulation(struct cfg_opt *self, unsigned int lineno)
+{
+ config.emul_type = GP_PixelTypeByName(optarg);
+
+ if (config.emul_type == GP_PIXEL_UNKNOWN) {
+ fprintf(stderr, "ERROR: %u: Invalid pixel type '%s'n",
+ lineno, self->val);
+ return 1;
+ }
+
+ return 0;
+}
+
+static int help(struct cfg_opt *self, unsigned int lineno)
+{
+ (void) self;
+ (void) lineno;
+
+ print_help();
+ exit(0);
+}
+
+static int man(struct cfg_opt *self, unsigned int lineno)
+{
+ (void) self;
+ (void) lineno;
+
+ print_man();
+ exit(0);
+}
+
+struct cfg_opt spiv_opts[] = {
+ {.name_space = NULL,
+ .key = NULL,
+ .opt = 'h',
+ .opt_long = "help",
+ .opt_has_value = 0,
+ .set = help,
+ .help = "Shows this help",
+ },
+
+ {.name_space = "Gui",
+ .key = "ShowInfo",
+ .opt = 'i',
+ .opt_long = "show-info",
+ .opt_has_value = 0,
+ .set = set_opt,
+ .help = "Show image info such as filename, size, etc...",
+ },
+ {.name_space = "Gui",
+ .key = "ShowProgress",
+ .opt = 'p',
+ .opt_long = "show-progress",
+ .set = set_opt,
+ .help = "Show progress bar when loading/resampling/... images",
+ },
+ {.name_space = "Gui",
+ .key = "SlideshowDelay",
+ .opt = 's',
+ .opt_long = "slideshow-delay",
+ .opt_has_value = 1,
+ .set = set_slideshow,
+ .help = "Delay between images in seconds (float) for slideshow",
+ },
+ {.name_space = "Gui",
+ .key = "UseFloydSteinberg",
+ .opt = 'f',
+ .opt_long = "floyd-steinberg",
+ .opt_has_value = 0,
+ .set = set_opt,
+ .help = "Turn on Floyd-Steinberg dithering",
+ },
+ {.name_space = "Gui",
+ .key = "Orientation",
+ .opt = 'o',
+ .opt_long = "orientation",
+ .opt_has_value = 1,
+ .set = set_orientation,
+ .help = "Orientation, one of 0, 90, 180, 270",
+ },
+ {.name_space = "Gui",
+ .key = "BackendInit",
+ .opt = 'b',
+ .opt_long = "backend-init",
+ .opt_has_value = 1,
+ .set = set_backend_init,
+ .help = "Backend init string, set it to 'help' for more info",
+ },
+
+ {.name_space = "Zoom",
+ .key = "ZoomStrategy",
+ .opt = 'z',
+ .opt_long = "zoom-strategy",
+ .opt_has_value = 1,
+ .set = set_zoom_strategy,
+ .help = "Zoom strategy",
+ },
+
+
+ {.name_space = "Actions",
+ .key = "1",
+ .opt = '1',
+ .opt_long = "action-1",
+ .opt_has_value = 1,
+ .set = set_action,
+ },
+ {.name_space = "Actions",
+ .key = "2",
+ .opt = '2',
+ .opt_long = "action-2",
+ .opt_has_value = 1,
+ .set = set_action,
+ },
+ {.name_space = "Actions",
+ .key = "3",
+ .opt = '3',
+ .opt_long = "action-3",
+ .opt_has_value = 1,
+ .set = set_action,
+ },
+ {.name_space = "Actions",
+ .key = "4",
+ .opt = '4',
+ .opt_long = "action-4",
+ .opt_has_value = 1,
+ .set = set_action,
+ },
+ {.name_space = "Actions",
+ .key = "5",
+ .opt = '5',
+ .opt_long = "action-5",
+ .opt_has_value = 1,
+ .set = set_action,
+ },
+ {.name_space = "Actions",
+ .key = "6",
+ .opt = '6',
+ .opt_long = "action-6",
+ .opt_has_value = 1,
+ .set = set_action,
+ },
+ {.name_space = "Actions",
+ .key = "7",
+ .opt = '7',
+ .opt_long = "action-7",
+ .opt_has_value = 1,
+ .set = set_action,
+ },
+ {.name_space = "Actions",
+ .key = "8",
+ .opt = '8',
+ .opt_long = "action-8",
+ .opt_has_value = 1,
+ .set = set_action,
+ },
+ {.name_space = "Actions",
+ .key = "9",
+ .opt = '9',
+ .opt_long = "action-9",
+ .opt_has_value = 1,
+ .set = set_action,
+ },
+ {.name_space = "Actions",
+ .key = "10",
+ .opt = '0',
+ .opt_long = "action-10",
+ .opt_has_value = 1,
+ .set = set_action,
+ .help = "Sets command line for action 1-10",
+ },
+
+ {.name_space = "Devel",
+ .key = "Timers",
+ .opt = 't',
+ .opt_long = "timers",
+ .opt_has_value = 0,
+ .set = set_opt,
+ .help = "Turns on cpu and wall clock measurement (printed to stdout)",
+ },
+ {.name_space = "Devel",
+ .key = "BackendEmulation",
+ .opt_long = "backend-emulation",
+ .opt_has_value = 1,
+ .set = set_emulation,
+ .help = "Emulate different backend pixel type (G1, G2, RGB555, ...)",
+ },
+ {.name_space = "Devel",
+ .key = NULL,
+ .opt_long = "print-man",
+ .opt_has_value = 0,
+ .set = man,
+ .help = "Prints spiv man page to stdout",
+ },
+
+ {NULL}
+};
+
+int spiv_config_load(const char *path)
+{
+ return cfg_load(spiv_opts, path);
+}
+
+int spiv_config_parse_args(int argc, char *argv[])
+{
+ return cfg_getopt(spiv_opts, argc, argv);
+}
+
+void spiv_config_print_help(void)
+{
+ cfg_print_help(spiv_opts);
+}
+
+void spiv_config_print_man(void)
+{
+ cfg_print_man(spiv_opts);
+}
diff --git a/demos/spiv/spiv_config.h b/demos/spiv/spiv_config.h
new file mode 100644
index 0000000..41a83b2
--- /dev/null
+++ b/demos/spiv/spiv_config.h
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * 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_CONFIG_H__
+#define __SPIV_CONFIG_H__
+
+#include <GP.h>
+
+enum orientation {
+ ROTATE_0,
+ ROTATE_90,
+ ROTATE_180,
+ ROTATE_270,
+};
+
+struct spiv_config {
+ float slideshow_delay;
+ enum orientation orientation;
+ int show_progress:1;
+ int show_info:1;
+ int floyd_steinberg:1;
+ int timers:1;
+ char backend_init[128];
+ GP_PixelType emul_type;
+};
+
+extern struct spiv_config config;
+
+int spiv_config_load(const char *path);
+
+int spiv_config_parse_args(int argc, char *argv[]);
+
+void spiv_config_print_help(void);
+
+void spiv_config_print_man(void);
+
+#endif /* __SPIV_CONFIG_H__ */
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
index f6abe41..0d6a6b6 100644
--- a/demos/spiv/spiv_help.c
+++ b/demos/spiv/spiv_help.c
@@ -23,102 +23,207 @@
#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",
- "S - stop/restart slideshow",
- "",
- "] - 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 1 - 10",
- "",
- "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",
- "0 - resize spiv window to the tenth of the image size",
- "",
- "Shift 2 - resize spiv window twice of the image size",
- "Shift 3 - resize spiv window three times of the image size",
- "...",
+#include "spiv_config.h"
+#include "spiv_help.h"
+
+struct key_help {
+ const char *keys;
+ const char *desc;
+};
+
+#define KEYS_MAX "13"
+
+static struct key_help help_keys[] = {
+ {"Esc, Enter, Q", "Quit spiv"},
+ {"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"},
+ {"R", "Rotate by 90 degrees clockwise"},
+ {"E", "Rotate by 90 degrees counterclockwise"},
+ {"H", "Show help"},
+ {"I", "Toggle show info box"},
+ {"P", "Toggle show progress"},
+ {"S", "Start/stop slideshow"},
+ {"", ""},
+ {"F1-F10", "Execute action 1 - 10"},
+ {"", ""},
+ {"<, KP Minus", "Zoom out by 50%"},
+ {">, KP Plus", "Zoom in by 50%"},
+ {"1", "Resize spiv window to the image size"},
+ {"2", "Resize spiv window to a half of the image size"},
+ {"3", "Resize spiv window to one third of the image size"},
+ {"9", "Resize spiv window to one ninth of the image size"},
+ {"...", ""},
+ {"0", "Resize spiv window to one tenth of the image size"},
+ {"Shift 2", "Resize spiv window twice of the image size"},
+ {"Shift 3", "Resize spiv window three times of the image size"},
+ {"...", ""},
+ {"Up", "Move image by 1px up (by 10 with Shift)"},
+ {"Down", "Move image by 1px down (by 10 with Shift)"},
+ {"Left", "Move image by 1px left (by 10 with Shift)"},
+ {"Right", "Move image by 1px right (by 10 with Shift)"},
+ {"", ""},
+ {"]", "Change to next resampling method"},
+ {"[", "Change to prev resampling method"},
+ {"L", "Toggle low pass filter"},
+ {"D", "Drop image cache"},
};
-static const int keys_help_len = sizeof(keys_help) / sizeof(char*);
+static const int help_keys_len = sizeof(help_keys) / sizeof(*help_keys);
+
+struct examples {
+ const char *example;
+ const char *desc;
+};
+
+static const struct examples examples[] = {
+ {"spiv *.jpg",
+ "Shows all jpeg images in current directory"},
+ {"spiv images.zip",
+ "Shows all images stored in zip file"},
+ {"spiv .",
+ "Shows all loadable images in current directory"},
+ {"spiv -t 5 vacation/",
+ "Runs slideshow with 5 second delay"},
+ {"spiv -1 'cp %F sorted' images/",
+ "Copies currently loaded image into directory 'sorted/' on pressing F1"},
+ {"spiv -e G1 -f images/",
+ "Emulates 1-bit Grayscale display and turns on Floyd-Steinberg dithering"},
+ {"spiv -b 'X11:ROOT_WIN' -t 10 images/",
+ "Runs slideshow using X root window as backend window"},
+ {"spiv -b 'X11:CREATE_ROOT' -t 10 images/",
+ "Same as abowe but works in KDEn"}
+};
+
+static const int examples_len = sizeof(examples) / sizeof(*examples);
+
+struct actions {
+ const char modifier;
+ const char *desc;
+};
+
+static struct actions actions[] = {
+ {'f', "Path to current image"},
+ {'F', "Shell escaped path to current image"},
+ {'n', "Current image filename without extension"},
+ {'N', "Shell escaped image filename without extension"},
+ {'e', "Current image file extension"},
+};
+
+static const int actions_len = sizeof(actions) / sizeof(*actions);
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 slideshow interval in seconds (floating point value)n");
- 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");
- printf(" -t enable timersn");
- printf(" if set timers that measure cpu and wall timen");
- printf(" of certain operations are printed into stdoutn");
- puts("n");
- printf("Actions:nn");
- printf(" -1 'cmd' sets first actionn");
- printf(" ...n");
- printf(" -9 'cmd' sets ninth actionn");
- printf(" -0 '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");
+ printf("Usage: spiv [opts] images or dirs with imagesn");
+ spiv_config_print_help();
+
+ printf(" Action shell command modifiers:n");
- for (i = 0; i < keys_help_len; i++)
- puts(keys_help[i]);
+ for (i = 0; i < actions_len; i++)
+ printf(" %%%c %sn", actions[i].modifier, actions[i].desc);
+
+ printf("n");
+
+ printf("Keyboard controls:nn");
+
+ for (i = 0; i < help_keys_len; i++) {
+ if (help_keys[i].desc[0] == '0') {
+ printf(" %sn", help_keys[i].keys);
+ } else {
+ printf(" %-"KEYS_MAX"s - %sn",
+ help_keys[i].keys, help_keys[i].desc);
+ }
+ }
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");
+ printf("Example usage:nn");
+ for (i = 0; i < examples_len; i++)
+ printf("%snt%sn", examples[i].example, examples[i].desc);
+}
+
+const char *man_head =
+ ".TH spiv 1 2013 GFXprim "Simple yet Powerful Image Viewer"nn"
+ ".SH NAMEn"
+ "spiv \- Simple yet Powerful Image Viewern"
+ ".SH SYNOPSISn"
+ ".B spivn"
+ "[options] images|dirsn"
+ ".SH DESCRIPTIONn"
+ ".B spivn"
+ "is a fast, lightweight and minimalistic image viewer build on then"
+ "top of the GFXprim library.n"
+ ".PPn"
+ "Spiv supports wide range of image formats, currently supported aren"
+ "JPEG, PNG, GIF, BMP, TIFF, PSP, PPM, JP2 and CBZ (as well generaln"
+ "ZIP archives with images), and more will come in the near future.n"
+ ".PPn"
+ "Spiv supports variety of video backends (via GFXprim backends)n"
+ "currently these are X11, Linux Framebuffer, SDL and AAlib. Spiv alson"
+ "supports wide range of backend pixel types from 1bit Grayscale to 32bit RGBn"
+ "with optional Floyd-Steinberg dithering (even, for example, from RGB888 to RGB565).n"
+ ".PPn"
+ "Spiv implements feh-like image actions, which are short shell scripts withn"
+ "printf-like modifiers.n"
+ "Seen.B ACTIONSnbellow for further information.n";
+
+static const char *man_tail =
+ ".SH BUGSn"
+ "Bugs happen. If you find one, report it on the GFXprim mailing list atn"
+ ".I gfxprim(a)ucw.czn"
+ ".SH AUTHORSn"
+ "Spiv is developed by Cyril Hrubis <chrubis(a)ucw.cz>n"
+ ".PPnGFXprim was/is developed by:n"
+ ".PPn.nfnCyril Hrubis <chrubis(a)ucw.cz>n"
+ ".nfnJiri "BlueBear" Dluhos <jiri.bluebear.dluhos(a)gmail.com>n"
+ ".nfnTomas Gavenciak <gavento(a)ucw.cz>n";
+
+static const char *actions_help =
+ ".SH ACTIONSn"
+ "Actions are short shell scripts with printf-like modifiers, the n"
+ "modifiers are substituted to current image path, name, etc. and executedn"
+ "by pressing function keys).n"
+ ".PPn"
+ "Actions could be set via command line parameters or written into then"
+ "configuration file and support following modifiers:n";
+
+void print_man(void)
+{
+ int i;
+
+ puts(man_head);
+
+ printf(".SH KEYBOARD CONTROLn");
+
+ for (i = 0; i < help_keys_len; i++) {
+ if (help_keys[i].desc[0] != '0') {
+ printf(".IP "%s"n", help_keys[i].keys);
+ printf("%sn", help_keys[i].desc);
+ }
+ }
+
+ spiv_config_print_man();
+
+ puts(".PPnConfiguration is loaded from /etc/spiv.conf");
+ puts("then ~/.spiv and overriden by command line parameters.n");
+
+ puts(actions_help);
+
+ for (i = 0; i < actions_len; i++)
+ printf(".PPn.B %%%cn%sn", actions[i].modifier, actions[i].desc);
+
+ puts(".SH EXAMPLES");
+
+ for (i = 0; i < examples_len; i++)
+ printf(".PPn.B %sn.nfn%snn", examples[i].desc, examples[i].example);
+
+ puts(man_tail);
}
static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff)
@@ -130,14 +235,17 @@ static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff)
GP_Fill(c, black);
- for (i = loff; i < keys_help_len; i++) {
- GP_Coord h = 2 + (i - loff) * 15;
+ GP_Print(c, NULL, 20 + 10 * xoff, 2, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ white, black, "%s", "Keyboard Controls:");
+
+ for (i = loff; i < help_keys_len; i++) {
+ GP_Coord h = 2 + (i - loff + 1) * 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]);
+ white, black, "%-"KEYS_MAX"s - %s", help_keys[i].keys, help_keys[i].desc);
}
out:
@@ -167,7 +275,7 @@ void draw_help(GP_Backend *backend)
switch (ev.val.key.key) {
case GP_KEY_DOWN:
- if (last < keys_help_len)
+ if (last < help_keys_len)
last = redraw_help(backend, ++loff, xoff);
break;
case GP_KEY_UP:
@@ -181,8 +289,8 @@ void draw_help(GP_Backend *backend)
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)
+ if (last < help_keys_len) {
+ if (loff + max_lines(backend) >= help_keys_len)
break;
loff += max_lines(backend);
http://repo.or.cz/w/gfxprim.git/commit/67843356569850ec5c7f6e4e77c55dcb97fc…
commit 67843356569850ec5c7f6e4e77c55dcb97fc6721
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 12 02:07:59 2013 +0200
doc: Add AALib to supported backend in general info.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/general.txt b/doc/general.txt
index 00dd795..2c5bc9f 100644
--- a/doc/general.txt
+++ b/doc/general.txt
@@ -201,8 +201,8 @@ Backends
link:backends.html[Backends] together with link:input.html[Input] are API for
drawing on screen (or into a window) and for getting keystrokes/mouse
-coordinates. So far we support X11, linux framebuffer and SDL as a graphics
-backend.
+coordinates. So far we support X11, linux framebuffer, SDL and AALib as a
+graphics backend.
There is also a virtual backend used for testing that allows you to create a
backend of any pixel type on the top of other backends.
http://repo.or.cz/w/gfxprim.git/commit/12806aae7921c0e11b2908d3bb842f294d1a…
commit 12806aae7921c0e11b2908d3bb842f294d1acdab
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Oct 10 16:18:44 2013 +0200
spiv: Another cleanup.
Shuffle the code a bit, remove unused cruft.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 4eb4433..076bea3 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -92,7 +92,7 @@ struct loader_params {
/* use low pass before resampling */
long use_low_pass:6;
/* image orientation 0, 90, 180, 270 */
- int rotate;
+ int orientation;
/* resampling method */
int resampling_method;
@@ -168,31 +168,6 @@ static void resize_backend(float ratio, int shift_flag)
}
-static float calc_img_size(struct loader_params *params,
- uint32_t img_w, uint32_t img_h,
- uint32_t src_w, uint32_t src_h)
-{
- float w_rat;
- 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;
- return GP_MIN(w_rat, h_rat);
- case ZOOM_FIXED:
- return params->zoom;
- case ZOOM_FIXED_WIN:
- resize_backend(params->zoom, 0);
- return params->zoom;
- }
-
- return 1.00;
-}
-
static const char *img_name(const char *img_path)
{
int i, len = strlen(img_path);
@@ -272,6 +247,66 @@ static void pattern_fill(GP_Context *ctx, unsigned int x0, unsigned int y0,
}
}
+
+static void info_printf(GP_Context *ctx, GP_Coord x, GP_Coord y,
+ const char *fmt, ...)
+ __attribute__ ((format (printf, 4, 5)));
+
+static void info_printf(GP_Context *ctx, GP_Coord x, GP_Coord y,
+ const char *fmt, ...)
+{
+ va_list va, vac;
+
+ va_start(va, fmt);
+
+ va_copy(vac, va);
+ GP_VPrint(ctx, NULL, x-1, y-1, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ black_pixel, white_pixel, fmt, vac);
+ va_end(vac);
+
+ GP_VPrint(ctx, NULL, x, y, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ white_pixel, black_pixel, fmt, va);
+
+ va_end(va);
+}
+
+static void show_info(struct loader_params *params, GP_Context *img,
+ GP_Context *orig_img)
+{
+ GP_Context *context = backend->context;
+ const char *img_path = image_loader_img_path();
+
+ set_caption(img_path, params->rat);
+
+ if (!params->show_info)
+ return;
+
+ GP_Size th = GP_TextHeight(NULL);
+
+ info_printf(context, 10, 10, "%ux%u (%ux%u) 1:%3.3f",
+ img->w, img->h, orig_img->w, orig_img->h, params->rat);
+
+ info_printf(context, 10, 12 + th, "%s", img_name(img_path));
+
+ info_printf(context, 10, 14 + 2 * th, "%s%s",
+ params->use_low_pass && params->rat < 1 ? "Gaussian LP + " : "",
+ GP_InterpolationTypeName(params->resampling_method));
+
+ unsigned int count = image_loader_count();
+ unsigned int pos = image_loader_pos() + 1;
+
+ info_printf(context, 10, 16 + 3 * th, "%u of %u", pos, count);
+
+ if (!image_loader_is_in_dir())
+ return;
+
+ unsigned int dir_count = image_loader_dir_count();
+ unsigned int dir_pos = image_loader_dir_pos() + 1;
+
+ info_printf(context, 10, 18 + 4 * th,
+ "%u of %u in directory", dir_pos, dir_count);
+}
+
static void update_display(struct loader_params *params, GP_Context *img,
GP_Context *orig_img)
{
@@ -279,7 +314,7 @@ static void update_display(struct loader_params *params, GP_Context *img,
struct cpu_timer timer;
GP_ProgressCallback callback = {.callback = image_loader_callback};
- switch (params->rotate) {
+ switch (params->orientation) {
case 0:
break;
case 90:
@@ -347,61 +382,9 @@ static void update_display(struct loader_params *params, GP_Context *img,
if (h > 0)
GP_FillRectXYWH(context, 0, img->h + cy, context->w, h, black_pixel);
- const char *img_path = image_loader_img_path();
-
- set_caption(img_path, params->rat);
-
- if (!params->show_info)
- goto out;
-
- GP_Size th = GP_TextHeight(NULL);
-
- GP_Print(context, NULL, 11, 11, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- black_pixel, white_pixel, "%ux%u (%ux%u) 1:%3.3f",
- img->w, img->h, orig_img->w, orig_img->h, params->rat);
-
- GP_Print(context, NULL, 10, 10, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- white_pixel, black_pixel, "%ux%u (%ux%u) 1:%3.3f",
- img->w, img->h, orig_img->w, orig_img->h, params->rat);
-
- GP_Print(context, NULL, 11, 13 + th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- black_pixel, white_pixel, "%s", img_name(img_path));
-
- GP_Print(context, NULL, 10, 12 + th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- white_pixel, black_pixel, "%s", img_name(img_path));
-
- GP_Print(context, NULL, 11, 13 + 2 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- black_pixel, white_pixel, "%s%s",
- params->use_low_pass && params->rat < 1 ? "Gaussian LP + " : "",
- GP_InterpolationTypeName(params->resampling_method));
-
- GP_Print(context, NULL, 10, 14 + 2 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- white_pixel, black_pixel, "%s%s",
- params->use_low_pass && params->rat < 1 ? "Gaussian LP + " : "",
- GP_InterpolationTypeName(params->resampling_method));
-
- unsigned int count = image_loader_count();
- unsigned int pos = image_loader_pos() + 1;
-
- GP_Print(context, NULL, 11, 17 + 3 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- black_pixel, white_pixel, "%u of %u", pos, count);
-
- GP_Print(context, NULL, 10, 16 + 3 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- white_pixel, black_pixel, "%u of %u", pos, count);
-
- if (!image_loader_is_in_dir())
- goto out;
-
- unsigned int dir_count = image_loader_dir_count();
- unsigned int dir_pos = image_loader_dir_pos() + 1;
-
- GP_Print(context, NULL, 11, 19 + 4 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- black_pixel, white_pixel, "%u of %u in directory", dir_pos, dir_count);
+ show_info(params, img, orig_img);
- GP_Print(context, NULL, 10, 18 + 4* th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- white_pixel, black_pixel, "%u of %u in directory", dir_pos, dir_count);
-out:
- if (params->rotate)
+ if (params->orientation)
GP_ContextFree(img);
GP_BackendFlip(backend);
@@ -457,13 +440,7 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
cpu_timer_start(&timer, "Resampling");
callback.priv = "Resampling Image";
GP_Context *i1 = GP_FilterResizeAlloc(img, w, h, params->resampling_method, &callback);
-// img->gamma = NULL;
-// GP_Context *i2 = GP_FilterResizeAlloc(img, w, h, params->resampling_method, &callback);
-// img = GP_FilterDifferenceAlloc(i2, i1, NULL);
-// img = GP_FilterInvert(img, NULL, NULL);
img = i1;
-// if (params->resampling_method == GP_INTERP_CUBIC_INT)
-// GP_FilterEdgeSharpening(img, img, 0.2, NULL);
cpu_timer_stop(&timer);
/*
@@ -488,50 +465,73 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
return img;
}
-static void *image_loader(void *ptr)
+static float calc_img_size(struct loader_params *params,
+ uint32_t img_w, uint32_t img_h,
+ uint32_t src_w, uint32_t src_h)
{
- struct loader_params *params = ptr;
- struct cpu_timer sum_timer;
- GP_Context *img, *orig_img, *context = backend->context;
-
- cpu_timer_start(&sum_timer, "sum");
-
- show_progress = params->show_progress || params->show_progress_once;
- params->show_progress_once = 0;
-
- /* Figure out rotation */
- GP_Size w, h;
+ float w_rat;
+ float h_rat;
- switch (params->rotate) {
+ switch (params->orientation) {
case 0:
case 180:
default:
- w = context->w;
- h = context->h;
break;
case 90:
case 270:
- w = context->h;
- h = context->w;
+ GP_SWAP(src_w, src_h);
break;
}
+ 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;
+ return GP_MIN(w_rat, h_rat);
+ case ZOOM_FIXED:
+ return params->zoom;
+ case ZOOM_FIXED_WIN:
+ resize_backend(params->zoom, 0);
+ return params->zoom;
+ }
+
+ return 1.00;
+}
+
+static void *image_loader(void *ptr)
+{
+ struct loader_params *params = ptr;
+ struct cpu_timer sum_timer;
+ GP_Context *img, *orig_img, *context = backend->context;
+
+ cpu_timer_start(&sum_timer, "sum");
+
+ show_progress = params->show_progress || params->show_progress_once;
+ params->show_progress_once = 0;
+
if ((orig_img = load_image(0)) == NULL) {
loader_running = 0;
return NULL;
}
- params->rat = calc_img_size(params, orig_img->w, orig_img->h, w, h);
+ /* Figure out rotation */
+ GP_Size w, h;
+
+ params->rat = calc_img_size(params, orig_img->w, orig_img->h,
+ context->w, context->h);
+
+ w = orig_img->w * params->rat + 0.5;
+ h = orig_img->h * params->rat + 0.5;
/* Special case => no need to resize */
- if (params->rat == 1.0) {
+ if (w == orig_img->w && h == orig_img->h) {
img = orig_img;
goto update;
}
- w = orig_img->w * params->rat + 0.5;
- h = orig_img->h * params->rat + 0.5;
-
img = load_resized_image(params, w, h);
if (img == NULL) {
@@ -539,7 +539,6 @@ static void *image_loader(void *ptr)
return NULL;
}
- //image_cache_print(params->img_resized_cache);
update:
update_display(params, img, orig_img);
cpu_timer_stop(&sum_timer);
@@ -691,7 +690,7 @@ int main(int argc, char *argv[])
.show_info = 0,
.show_nn_first = 0,
.use_dithering = 0,
- .rotate = 0,
+ .orientation = 0,
.resampling_method = GP_INTERP_LINEAR_LF_INT,
.zoom_type = ZOOM_FIT,
@@ -735,11 +734,11 @@ int main(int argc, char *argv[])
break;
case 'r':
if (!strcmp(optarg, "90"))
- params.rotate = 90;
+ params.orientation = 90;
else if (!strcmp(optarg, "180"))
- params.rotate = 180;
+ params.orientation = 180;
else if (!strcmp(optarg, "270"))
- params.rotate = 270;
+ params.orientation = 270;
case 'b':
backend_opts = optarg;
break;
@@ -859,9 +858,9 @@ int main(int argc, char *argv[])
params.show_progress = !params.show_progress;
break;
case GP_KEY_R:
- params.rotate += 90;
- if (params.rotate > 270)
- params.rotate = 0;
+ params.orientation += 90;
+ if (params.orientation > 270)
+ params.orientation = 0;
params.show_progress_once = 1;
show_image(¶ms);
http://repo.or.cz/w/gfxprim.git/commit/e66493630e62bac979731f58c0232c14c1f6…
commit e66493630e62bac979731f58c0232c14c1f699d9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Oct 10 15:02:05 2013 +0200
text: Add va_list variant for GP_Print()
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/text_api.txt b/doc/text_api.txt
index 1a77a7d..46f93f3 100644
--- a/doc/text_api.txt
+++ b/doc/text_api.txt
@@ -35,6 +35,11 @@ void GP_Text(GP_Context *context, const GP_TextStyle *style,
GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style,
GP_Coord x, GP_Coord y, int align,
GP_Pixel fg_color, GP_Pixel bg_color, const char *fmt, ...);
+
+GP_Size GP_VPrint(GP_Context *context, const GP_TextStyle *style,
+ GP_Coord x, GP_Coord y, int align,
+ GP_Pixel fg_color, GP_Pixel bg_color,
+ const char *fmt, va_list va);
--------------------------------------------------------------------------------
Draws text at the position x and y; the alignment of the text in relation
diff --git a/include/text/GP_Text.h b/include/text/GP_Text.h
index 6834417..30176d0 100644
--- a/include/text/GP_Text.h
+++ b/include/text/GP_Text.h
@@ -26,6 +26,8 @@
#ifndef TEXT_GP_TEXT_H
#define TEXT_GP_TEXT_H
+#include <stdarg.h>
+
#include "core/GP_Context.h"
#include "text/GP_TextStyle.h"
@@ -91,6 +93,10 @@ GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style,
GP_Pixel fg_color, GP_Pixel bg_color, const char *fmt, ...)
__attribute__ ((format (printf, 8, 9)));
+GP_Size GP_VPrint(GP_Context *context, const GP_TextStyle *style,
+ GP_Coord x, GP_Coord y, int align,
+ GP_Pixel fg_color, GP_Pixel bg_color,
+ const char *fmt, va_list va);
/*
* Clears rectangle that would be used to draw text of size pixels.
*/
diff --git a/libs/text/GP_Text.c b/libs/text/GP_Text.c
index 8a712ec..07df462 100644
--- a/libs/text/GP_Text.c
+++ b/libs/text/GP_Text.c
@@ -19,11 +19,10 @@
* Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-#include <stdarg.h>
#include "gfx/GP_Gfx.h"
#include "core/GP_FnPerBpp.h"
#include "core/GP_Debug.h"
@@ -96,18 +95,16 @@ void GP_Text(GP_Context *context, const GP_TextStyle *style,
align & GP_TEXT_NOBG, fg_color, bg_color, str);
}
-
-GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style,
- GP_Coord x, GP_Coord y, int align,
- GP_Pixel fg_color, GP_Pixel bg_color, const char *fmt, ...)
+GP_Size GP_VPrint(GP_Context *context, const GP_TextStyle *style,
+ GP_Coord x, GP_Coord y, int align,
+ GP_Pixel fg_color, GP_Pixel bg_color,
+ const char *fmt, va_list va)
{
- va_list va, vac;
+ va_list vac;
int size;
- va_start(va, fmt);
va_copy(vac, va);
size = vsnprintf(NULL, 0, fmt, va);
- va_end(va);
char buf[size+1];
vsnprintf(buf, sizeof(buf), fmt, vac);
va_end(vac);
@@ -117,6 +114,20 @@ GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style,
return GP_TextWidth(style, buf);
}
+GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style,
+ GP_Coord x, GP_Coord y, int align,
+ GP_Pixel fg_color, GP_Pixel bg_color, const char *fmt, ...)
+{
+ va_list va;
+ GP_Size ret;
+
+ va_start(va, fmt);
+ ret = GP_VPrint(context, style, x, y, align,
+ fg_color, bg_color, fmt, va);
+ va_end(va);
+
+ return ret;
+}
void GP_TextClear(GP_Context *context, const GP_TextStyle *style,
GP_Coord x, GP_Coord y, int align,
http://repo.or.cz/w/gfxprim.git/commit/d12cf1d15e383df010846ee3a53a36cc7ac6…
commit d12cf1d15e383df010846ee3a53a36cc7ac64724
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 8 13:57:09 2013 +0200
filters: GaussianNoise: Set errno.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_GaussianNoise.gen.c.t b/libs/filters/GP_GaussianNoise.gen.c.t
index 2ec5a92..939533b 100644
--- a/libs/filters/GP_GaussianNoise.gen.c.t
+++ b/libs/filters/GP_GaussianNoise.gen.c.t
@@ -87,6 +87,7 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src,
if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) {
GP_TempAllocFree(temp);
+ errno = ECANCELED;
return 1;
}
}
@@ -153,7 +154,7 @@ GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src,
float sigma, float mu,
GP_ProgressCallback *callback)
{
- int ret;
+ int ret, err;
GP_Context *dst = GP_ContextAlloc(w_src, h_src, src->pixel_type);
@@ -164,7 +165,9 @@ GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src,
dst, 0, 0, sigma, mu, callback);
if (ret) {
+ err = errno;
GP_ContextFree(dst);
+ errno = err;
return NULL;
}
http://repo.or.cz/w/gfxprim.git/commit/6c19433d1a062473a6bdc2a21b67168d3cec…
commit 6c19433d1a062473a6bdc2a21b67168d3cec04fd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 8 13:48:22 2013 +0200
backends: X11: Avoid warning on GravityNotify
Avoid useless warning on GravityNotify event.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_InputDriverX11.c b/libs/backends/GP_InputDriverX11.c
index fc6149f..a271360 100644
--- a/libs/backends/GP_InputDriverX11.c
+++ b/libs/backends/GP_InputDriverX11.c
@@ -292,6 +292,9 @@ void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue,
case ReparentNotify:
GP_DEBUG(1, "ReparentNotify event received");
break;
+ case GravityNotify:
+ GP_DEBUG(1, "GravityNotify event received");
+ break;
default:
GP_WARN("Unhandled X11 event type %u", ev->type);
}
http://repo.or.cz/w/gfxprim.git/commit/15db0fc3351d6a78f3f654defde550aaf881…
commit 15db0fc3351d6a78f3f654defde550aaf8813a7d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 8 13:34:26 2013 +0200
tests: filters: Fix filters compare.
Some of the filters cannot run in-place, fix it by passing src as the
first arg.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/filters/FiltersCompare.gen.c.t b/tests/filters/FiltersCompare.gen.c.t
index 5ee38c6..d22890b 100644
--- a/tests/filters/FiltersCompare.gen.c.t
+++ b/tests/filters/FiltersCompare.gen.c.t
@@ -60,21 +60,17 @@ All results from filters listed under one name are compared.
['SymmetryAlloc', ['src', 'GP_MIRROR_V', 'NULL']],
],
['Rotate90',
- ['Rotate90', ['dst', 'dst', 'NULL']],
['Rotate90Alloc', ['src', 'NULL']],
- ['Symmetry', ['dst', 'dst', 'GP_ROTATE_90', 'NULL']],
['SymmetryAlloc', ['src', 'GP_ROTATE_90', 'NULL']],
],
['Rotate180',
- ['Rotate180', ['dst', 'dst', 'NULL']],
+ ['Rotate180', ['src', 'dst', 'NULL']],
['Rotate180Alloc', ['src', 'NULL']],
- ['Symmetry', ['dst', 'dst', 'GP_ROTATE_180', 'NULL']],
+ ['Symmetry', ['src', 'dst', 'GP_ROTATE_180', 'NULL']],
['SymmetryAlloc', ['src', 'GP_ROTATE_180', 'NULL']],
],
['Rotate270',
- ['Rotate270', ['dst', 'dst', 'NULL']],
['Rotate270Alloc', ['src', 'NULL']],
- ['Symmetry', ['dst', 'dst', 'GP_ROTATE_270', 'NULL']],
['SymmetryAlloc', ['src', 'GP_ROTATE_270', 'NULL']],
],
@@ -105,16 +101,16 @@ All results from filters listed under one name are compared.
],
['Laplace',
- ['Laplace', ['dst', 'dst', 'NULL']],
+ ['Laplace', ['src', 'dst', 'NULL']],
['LaplaceAlloc', ['src', 'NULL']],
],
['EdgeSharpening',
- ['EdgeSharpening', ['dst', 'dst', '0.2', 'NULL']],
+ ['EdgeSharpening', ['src', 'dst', '0.2', 'NULL']],
['EdgeSharpeningAlloc', ['src', '0.2', 'NULL']],
],
['Median',
- ['Median', ['dst', 'dst', '3', '2', 'NULL']],
+ ['Median', ['src', 'dst', '3', '2', 'NULL']],
['MedianAlloc', ['src', '3', '2', 'NULL']],
],
http://repo.or.cz/w/gfxprim.git/commit/5adcb7f068d9c8814fc1abecea76de442a32…
commit 5adcb7f068d9c8814fc1abecea76de442a3267bc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Oct 7 18:59:19 2013 +0200
filters: ResizeCubicInt: Set errno.
Set errno on invalid pixel types.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_ResizeCubic.gen.c.t b/libs/filters/GP_ResizeCubic.gen.c.t
index 9120fa7..ae84901 100644
--- a/libs/filters/GP_ResizeCubic.gen.c.t
+++ b/libs/filters/GP_ResizeCubic.gen.c.t
@@ -210,6 +210,7 @@ static int resize_cubic(const GP_Context *src, GP_Context *dst,
%% endif
%% endfor
default:
+ errno = EINVAL;
return -1;
}
}
http://repo.or.cz/w/gfxprim.git/commit/8dba9bc6f1f94b008a6f4475d0af9d1e8c81…
commit 8dba9bc6f1f94b008a6f4475d0af9d1e8c810f36
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Oct 7 18:52:36 2013 +0200
filters: GaussianNoise: Set errno.
Set errno to EINVAL on unsupported pixel types (palette).
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_GaussianNoise.gen.c.t b/libs/filters/GP_GaussianNoise.gen.c.t
index 3e4764b..2ec5a92 100644
--- a/libs/filters/GP_GaussianNoise.gen.c.t
+++ b/libs/filters/GP_GaussianNoise.gen.c.t
@@ -26,6 +26,8 @@
%% block body
+#include <errno.h>
+
#include "core/GP_Context.h"
#include "core/GP_GetPutPixel.h"
#include "core/GP_TempAlloc.h"
@@ -117,6 +119,7 @@ int GP_FilterGaussianNoiseAdd_Raw(const GP_Context *src,
%% endif
%% endfor
default:
+ errno = EINVAL;
return -1;
}
}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/Makefile | 2 +-
demos/spiv/cfg.c | 525 ++++++++++++++++++++
include/loaders/GP_JP2.h => demos/spiv/cfg.h | 52 ++-
demos/spiv/spiv.c | 367 ++++++--------
demos/spiv/spiv_config.c | 348 +++++++++++++
.../pretty_print.c => spiv/spiv_config.h} | 41 +-
demos/spiv/spiv_help.c | 288 ++++++++----
doc/general.txt | 4 +-
doc/text_api.txt | 5 +
include/text/GP_Text.h | 6 +
libs/backends/GP_InputDriverX11.c | 3 +
libs/filters/GP_GaussianNoise.gen.c.t | 8 +-
libs/filters/GP_ResizeCubic.gen.c.t | 1 +
libs/text/GP_Text.c | 29 +-
tests/filters/FiltersCompare.gen.c.t | 14 +-
15 files changed, 1344 insertions(+), 349 deletions(-)
create mode 100644 demos/spiv/cfg.c
copy include/loaders/GP_JP2.h => demos/spiv/cfg.h (56%)
create mode 100644 demos/spiv/spiv_config.c
copy demos/{c_simple/pretty_print.c => spiv/spiv_config.h} (75%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
07 Oct '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 3d14cb78419fe54e86e6a838b919a303ae9e536f (commit)
via 74c604b15d7fcc320bd64b1efda533ea0d54c228 (commit)
from 22988118088f5fb0de21f8ea6ada75be2b42f446 (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/3d14cb78419fe54e86e6a838b919a303ae9e…
commit 3d14cb78419fe54e86e6a838b919a303ae9e536f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Oct 7 18:42:21 2013 +0200
tests: filters: Better API Converage test.
* More filters covered
* Now with checks for correct errno values
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/filters/APICoverage.gen.c.t b/tests/filters/APICoverage.gen.c.t
index 323f614..b4c8281 100644
--- a/tests/filters/APICoverage.gen.c.t
+++ b/tests/filters/APICoverage.gen.c.t
@@ -20,96 +20,123 @@
* *
*****************************************************************************/
- /*
-
- The purpose of this test is to exercise as much codepaths as possible
- without checking for result corectness.
+%% extends "base.test.c.t"
- */
+%% block descr
+Filters API coverage tests.
-%% extends "base.test.c.t"
+The purpose of this test is to exercise as much codepaths as possible
+without checking for result corectness.
-{% block descr %}Filters API coverage tests.{% endblock %}
+We check for correct return value correcness though.
+%% endblock descr
%% block body
#include <stdio.h>
+#include <string.h>
+#include <errno.h>
#include <core/GP_Context.h>
#include <filters/GP_Filters.h>
#include "tst_test.h"
-%% set API_List = [['MirrorH', 'GP_Context:in', 'GP_Context:out',
+%% set API_List = [['MirrorH', '', 'GP_Context:in', 'GP_Context:out',
+ 'GP_ProgressCallback'],
+ ['MirrorHAlloc', '', 'GP_Context:in', 'GP_ProgressCallback'],
+
+ ['MirrorV', '', 'GP_Context:in', 'GP_Context:out',
+ 'GP_ProgressCallback'],
+ ['MirrorVAlloc', '', 'GP_Context:in', 'GP_ProgressCallback'],
+
+ ['Rotate90', '', 'GP_Context:in', 'GP_Context:out',
'GP_ProgressCallback'],
- ['MirrorHAlloc', 'GP_Context:in', 'GP_ProgressCallback'],
+ ['Rotate90Alloc', '', 'GP_Context:in', 'GP_ProgressCallback'],
- ['MirrorV', 'GP_Context:in', 'GP_Context:out',
+ ['Rotate180', '', 'GP_Context:in', 'GP_Context:out',
'GP_ProgressCallback'],
- ['MirrorVAlloc', 'GP_Context:in', 'GP_ProgressCallback'],
+ ['Rotate180Alloc', '', 'GP_Context:in', 'GP_ProgressCallback'],
- ['Rotate90', 'GP_Context:in', 'GP_Context:out',
+ ['Rotate270', '', 'GP_Context:in', 'GP_Context:out',
'GP_ProgressCallback'],
- ['Rotate90Alloc', 'GP_Context:in', 'GP_ProgressCallback'],
+ ['Rotate270Alloc', '', 'GP_Context:in', 'GP_ProgressCallback'],
- ['Rotate180', 'GP_Context:in', 'GP_Context:out',
+ ['Symmetry', 'H', 'GP_Context:in', 'GP_Context:out',
+ 'GP_MIRROR_H', 'GP_ProgressCallback'],
+ ['SymmetryAlloc', 'H', 'GP_Context:in', 'GP_MIRROR_H',
'GP_ProgressCallback'],
- ['Rotate180Alloc', 'GP_Context:in', 'GP_ProgressCallback'],
- ['Rotate270', 'GP_Context:in', 'GP_Context:out',
+ ['Symmetry', 'V', 'GP_Context:in', 'GP_Context:out',
+ 'GP_MIRROR_V', 'GP_ProgressCallback'],
+ ['SymmetryAlloc', 'V', 'GP_Context:in', 'GP_MIRROR_V',
'GP_ProgressCallback'],
- ['Rotate270Alloc', 'GP_Context:in', 'GP_ProgressCallback'],
- ['Convolution', 'GP_Context:in', 'GP_Context:out',
+ ['Symmetry', '90', 'GP_Context:in', 'GP_Context:out',
+ 'GP_ROTATE_90', 'GP_ProgressCallback'],
+ ['SymmetryAlloc', '90', 'GP_Context:in', 'GP_ROTATE_90',
+ 'GP_ProgressCallback'],
+
+ ['Symmetry', '180', 'GP_Context:in', 'GP_Context:out',
+ 'GP_ROTATE_180', 'GP_ProgressCallback'],
+ ['SymmetryAlloc', '180', 'GP_Context:in', 'GP_ROTATE_180',
+ 'GP_ProgressCallback'],
+
+ ['Symmetry', '270', 'GP_Context:in', 'GP_Context:out',
+ 'GP_ROTATE_270', 'GP_ProgressCallback'],
+ ['SymmetryAlloc', '270', 'GP_Context:in', 'GP_ROTATE_270',
+ 'GP_ProgressCallback'],
+
+ ['Convolution', '', 'GP_Context:in', 'GP_Context:out',
'GP_FilterKernel2D:kernel', 'GP_ProgressCallback'],
- ['ConvolutionAlloc', 'GP_Context:in',
+ ['ConvolutionAlloc', '', 'GP_Context:in',
'GP_FilterKernel2D:kernel', 'GP_ProgressCallback'],
- ['GaussianBlur', 'GP_Context:in', 'GP_Context:out',
+ ['GaussianBlur', '', 'GP_Context:in', 'GP_Context:out',
'float:sigma_x', 'float:sigma_y', 'GP_ProgressCallback'],
- ['GaussianBlurAlloc', 'GP_Context:in', 'float:sigma_x',
+ ['GaussianBlurAlloc', '', 'GP_Context:in', 'float:sigma_x',
'float:sigma_y', 'GP_ProgressCallback'],
- ['GaussianNoiseAdd', 'GP_Context:in', 'GP_Context:out',
+ ['GaussianNoiseAdd', '', 'GP_Context:in', 'GP_Context:out',
'float:sigma', 'float:mu', 'GP_ProgressCallback'],
- ['GaussianNoiseAddAlloc', 'GP_Context:in',
+ ['GaussianNoiseAddAlloc', '', 'GP_Context:in',
'float:sigma', 'float:mu', 'GP_ProgressCallback'],
- ['Median', 'GP_Context:in', 'GP_Context:out',
+ ['Median', '', 'GP_Context:in', 'GP_Context:out',
'int:xmed', 'int:ymed', 'GP_ProgressCallback'],
- ['MedianAlloc', 'GP_Context:in',
+ ['MedianAlloc', '', 'GP_Context:in',
'int:xmed', 'int:ymed', 'GP_ProgressCallback'],
- ['WeightedMedian', 'GP_Context:in', 'GP_Context:out',
+ ['WeightedMedian', '', 'GP_Context:in', 'GP_Context:out',
'GP_MedianWeights:weights', 'GP_ProgressCallback'],
- ['WeightedMedianAlloc', 'GP_Context:in',
+ ['WeightedMedianAlloc', '', 'GP_Context:in',
'GP_MedianWeights:weights', 'GP_ProgressCallback'],
- ['Sigma', 'GP_Context:in', 'GP_Context:out',
+ ['Sigma', '', 'GP_Context:in', 'GP_Context:out',
'int:xrad', 'int:yrad', 'int:min', 'float:sigma',
'GP_ProgressCallback'],
- ['SigmaAlloc', 'GP_Context:in',
+ ['SigmaAlloc', '', 'GP_Context:in',
'int:xrad', 'int:yrad', 'int:min', 'float:sigma',
'GP_ProgressCallback'],
- ['ResizeNN', 'GP_Context:in', 'GP_Context:out',
+ ['ResizeNN', '', 'GP_Context:in', 'GP_Context:out',
'GP_ProgressCallback'],
- ['ResizeNNAlloc', 'GP_Context:in', 'int:w', 'int:h',
+ ['ResizeNNAlloc', '', 'GP_Context:in', 'int:w', 'int:h',
'GP_ProgressCallback'],
- ['FloydSteinberg', 'GP_Context:in', 'GP_Context:out',
+ ['FloydSteinberg', '', 'GP_Context:in', 'GP_Context:out',
'GP_ProgressCallback'],
- ['FloydSteinbergAlloc', 'GP_Context:in', 'GP_PixelType:G8',
+ ['FloydSteinbergAlloc', '', 'GP_Context:in', 'GP_PixelType:G8',
'GP_ProgressCallback'],
- ['HilbertPeano', 'GP_Context:in', 'GP_Context:out',
+ ['HilbertPeano', '', 'GP_Context:in', 'GP_Context:out',
'GP_ProgressCallback'],
- ['HilbertPeanoAlloc', 'GP_Context:in', 'GP_PixelType:G8',
+ ['HilbertPeanoAlloc', '', 'GP_Context:in', 'GP_PixelType:G8',
'GP_ProgressCallback'],
]
-%% macro prep_context(id, pt)
- GP_Context *{{ id }} = GP_ContextAlloc(331, 331, GP_PIXEL_{{ pt.name }});
+%% macro prep_context(id)
+ GP_Context *{{ id }} = GP_ContextAlloc(331, 331, pt);
%% endmacro
%% macro prep_float(id)
@@ -159,9 +186,9 @@
GP_FilterKernel2D *{{ id }} = &{{ id }}_s;
%% endmacro
-%% macro prep_param(param, pt)
+%% macro prep_param(param)
%% if (param.split(':', 1)[0] == 'GP_Context')
-{{ prep_context(param.split(':', 1)[1], pt) }}
+{{ prep_context(param.split(':', 1)[1]) }}
%% endif
%% if (param.split(':', 1)[0] == 'float')
{{ prep_float(param.split(':', 1)[1]) }}
@@ -180,23 +207,55 @@
%% endif
%% endmacro
-{% macro get_param(param) %}{% if len(param.split(':', 1)) == 1 %}NULL{% else %}{{ param.split(':', 1)[1] }}{% endif %}{% endmacro %}
+{% macro do_param(param) %}{% if param == 'GP_ProgressCallback' %}NULL{% else %}{{ param }}{% endif %}{% endmacro %}
-%% for fn in API_List
-%% for pt in pixeltypes
-%% if not pt.is_unknown()
+{% macro get_param(param) %}{% if len(param.split(':', 1)) == 1 %}{{ do_param(param) }}{% else %}{{ param.split(':', 1)[1] }}{% endif %}{% endmacro %}
-static int Filter_{{ fn[0]}}_{{ pt.name }}(void)
+%% for fn in API_List
+static int filter_{{ fn[0] }}_{{ fn[1] }}(GP_PixelType pt)
{
-%% for param in fn[1:]
-{{ prep_param(param, pt) }}
-%% endfor
+%% for param in fn[1:]
+{{ prep_param(param) }}
+%% endfor
+%% if 'Alloc' in fn[0]
+ GP_Context *res;
+%% else
+ int res;
+%% endif
+
+ res = GP_Filter{{ fn[0] }}({{ get_param(fn[2]) }}{% for param in fn[3:] %}, {{ get_param(param) }}{% endfor %});
- GP_Filter{{ fn[0] }}({{ get_param(fn[1]) }}{% for param in fn[2:] %}, {{ get_param(param) }}{% endfor %});
+%% if 'Alloc' in fn[0]
+ if (res == NULL) {
+%% else
+ if (res) {
+%% endif
+ switch (errno) {
+ case ENOSYS:
+ tst_msg("Not Implemented");
+ return TST_SUCCESS;
+ break;
+ case EINVAL:
+ tst_msg("Not suitable pixel type");
+ return TST_SUCCESS;
+ break;
+ default:
+ tst_msg("Unexpected errno %s", strerror(errno));
+ return TST_FAILED;
+ }
+ }
return TST_SUCCESS;
}
+%% endfor
+%% for fn in API_List
+%% for pt in pixeltypes
+%% if not pt.is_unknown()
+static int filter_{{ fn[0] }}_{{ fn[1] }}_{{ pt.name }}(void)
+{
+ return filter_{{ fn[0] }}_{{ fn[1] }}({{ pt.C_type }});
+}
%% endif
%% endfor
%% endfor
@@ -207,8 +266,8 @@ const struct tst_suite tst_suite = {
%% for fn in API_List
%% for pt in pixeltypes
%% if not pt.is_unknown()
- {.name = "Filter {{ fn[0] }} {{ pt.name }}",
- .tst_fn = Filter_{{ fn[0] }}_{{ pt.name }}},
+ {.name = "Filter {{ fn[0] }} {{ fn[1] }} {{ pt.name }}",
+ .tst_fn = filter_{{ fn[0] }}_{{ fn[1] }}_{{ pt.name }}},
%% endif
%% endfor
%% endfor
http://repo.or.cz/w/gfxprim.git/commit/74c604b15d7fcc320bd64b1efda533ea0d54…
commit 74c604b15d7fcc320bd64b1efda533ea0d54c228
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Oct 7 17:59:39 2013 +0200
tests: filters: Implement compare tests.
The tests runs the same filter using different APIs and compares
results, fails if resulting contexts does not match.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/filters/FiltersCompare.gen.c.t b/tests/filters/FiltersCompare.gen.c.t
new file mode 100644
index 0000000..5ee38c6
--- /dev/null
+++ b/tests/filters/FiltersCompare.gen.c.t
@@ -0,0 +1,241 @@
+/*****************************************************************************
+ * 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 descr
+Filters Compare
+
+Calls different API for the same filter (Alloc vs In-place, etc.) and copares
+the results (which must be the same).
+%% endblock descr
+
+%% block body
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <core/GP_Context.h>
+#include <filters/GP_Filters.h>
+
+#include "tst_test.h"
+
+/*
+The format is [[name1, [fn1, [params]], [fn2, [params]], ...],
+ [name2, [fn3, [params]], [fn4, [params]], ...],
+ ...]
+
+All results from filters listed under one name are compared.
+*/
+%% set compare_list = [['MirrorH',
+ ['MirrorH', ['dst', 'dst', 'NULL']],
+ ['MirrorHAlloc', ['src', 'NULL']],
+ ['Symmetry', ['dst', 'dst', 'GP_MIRROR_H', 'NULL']],
+ ['SymmetryAlloc', ['src', 'GP_MIRROR_H', 'NULL']],
+ ],
+ ['MirrorV',
+ ['MirrorV', ['dst', 'dst', 'NULL']],
+ ['MirrorVAlloc', ['src', 'NULL']],
+ ['Symmetry', ['dst', 'dst', 'GP_MIRROR_V', 'NULL']],
+ ['SymmetryAlloc', ['src', 'GP_MIRROR_V', 'NULL']],
+ ],
+ ['Rotate90',
+ ['Rotate90', ['dst', 'dst', 'NULL']],
+ ['Rotate90Alloc', ['src', 'NULL']],
+ ['Symmetry', ['dst', 'dst', 'GP_ROTATE_90', 'NULL']],
+ ['SymmetryAlloc', ['src', 'GP_ROTATE_90', 'NULL']],
+ ],
+ ['Rotate180',
+ ['Rotate180', ['dst', 'dst', 'NULL']],
+ ['Rotate180Alloc', ['src', 'NULL']],
+ ['Symmetry', ['dst', 'dst', 'GP_ROTATE_180', 'NULL']],
+ ['SymmetryAlloc', ['src', 'GP_ROTATE_180', 'NULL']],
+ ],
+ ['Rotate270',
+ ['Rotate270', ['dst', 'dst', 'NULL']],
+ ['Rotate270Alloc', ['src', 'NULL']],
+ ['Symmetry', ['dst', 'dst', 'GP_ROTATE_270', 'NULL']],
+ ['SymmetryAlloc', ['src', 'GP_ROTATE_270', 'NULL']],
+ ],
+
+ ['ResizeNN',
+ ['Resize', ['dst', 'dst', 'GP_INTERP_NN', 'NULL']],
+ ['ResizeAlloc', ['src', 'src->w', 'src->h',
+ 'GP_INTERP_NN', 'NULL']],
+ ],
+ ['ResizeLinearInt',
+ ['Resize', ['dst', 'dst', 'GP_INTERP_LINEAR_INT', 'NULL']],
+ ['ResizeAlloc', ['src', 'src->w', 'src->h',
+ 'GP_INTERP_LINEAR_INT', 'NULL']],
+ ],
+ ['ResizeLinearLFInt',
+ ['Resize', ['dst', 'dst', 'GP_INTERP_LINEAR_LF_INT', 'NULL']],
+ ['ResizeAlloc', ['src', 'src->w', 'src->h',
+ 'GP_INTERP_LINEAR_LF_INT', 'NULL']],
+ ],
+ ['ResizeCubicInt',
+ ['Resize', ['dst', 'dst', 'GP_INTERP_CUBIC_INT', 'NULL']],
+ ['ResizeAlloc', ['src', 'src->w', 'src->h',
+ 'GP_INTERP_CUBIC_INT', 'NULL']],
+ ],
+ ['ResizeCubic',
+ ['Resize', ['dst', 'dst', 'GP_INTERP_CUBIC', 'NULL']],
+ ['ResizeAlloc', ['src', 'src->w', 'src->h',
+ 'GP_INTERP_CUBIC', 'NULL']],
+ ],
+
+ ['Laplace',
+ ['Laplace', ['dst', 'dst', 'NULL']],
+ ['LaplaceAlloc', ['src', 'NULL']],
+ ],
+ ['EdgeSharpening',
+ ['EdgeSharpening', ['dst', 'dst', '0.2', 'NULL']],
+ ['EdgeSharpeningAlloc', ['src', '0.2', 'NULL']],
+ ],
+
+ ['Median',
+ ['Median', ['dst', 'dst', '3', '2', 'NULL']],
+ ['MedianAlloc', ['src', '3', '2', 'NULL']],
+ ],
+
+ ['Sigma',
+ ['Sigma', ['dst', 'dst', '3', '2', '4', '0.5', 'NULL']],
+ ['SigmaAlloc', ['src', '3', '2', '4', '0.5', 'NULL']],
+ ],
+
+ ['GaussianBlur',
+ ['GaussianBlur', ['dst', 'dst', '10', '12', 'NULL']],
+ ['GaussianBlurAlloc', ['src', '10', '12', 'NULL']]
+ ],
+]
+
+%%- macro arr2params(arr)
+{{ arr[0] }}{% for i in arr[1:] %}, {{ i }}{% endfor%}
+%%- endmacro
+
+%% macro apply_filter(filter)
+%% if 'dst' in filter[1]
+ dst = GP_ContextCopy(src, GP_COPY_WITH_PIXELS);
+ if (GP_Filter{{ filter[0] }}({{ arr2params(filter[1]) }})) {
+ int err = errno;
+ GP_ContextFree(dst);
+ dst = NULL;
+ errno = err;
+ }
+
+%% else
+ dst = GP_Filter{{ filter[0] }}({{ arr2params(filter[1]) }});
+%% endif
+
+%% endmacro
+
+
+%% for fs in compare_list
+static int compare_{{ fs[0] }}(GP_PixelType pt)
+{
+ GP_Context *src = GP_ContextAlloc(134, 1072, pt);
+ GP_Context *dst, *ref;
+ int fail = 0;
+
+ errno = 0;
+
+ if (!src) {
+ tst_msg("Malloc Failed :(");
+ return TST_UNTESTED;
+ }
+
+ /* randomize context content */
+ GP_FilterGaussianNoiseAdd(src, src, 10, 0, NULL);
+
+ /* Create reference result */
+{{ apply_filter(fs[1]) }}
+ ref = dst;
+
+ if (ref == NULL) {
+ GP_ContextFree(src);
+ switch (errno) {
+ case ENOSYS:
+ tst_msg("Not implemented");
+ return TST_SKIPPED;
+ case EINVAL:
+ tst_msg("Couldn't be implemented");
+ return TST_SKIPPED;
+ default:
+ tst_msg("Unexpected errno %s", strerror(errno));
+ return TST_FAILED;
+ }
+ }
+
+%% for i in fs[2:]
+{{ apply_filter(i) }}
+
+ if (!GP_ContextEqual(ref, dst)) {
+ fail++;
+ tst_msg("Results for {{ fs[1][0] }} and {{ i[0] }} differs");
+ }
+
+
+ GP_ContextFree(dst);
+%% endfor
+
+ GP_ContextFree(src);
+ GP_ContextFree(ref);
+
+ if (fail) {
+ tst_msg("%i failure(s)", fail);
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+%% endfor
+
+%% for fs in compare_list
+%% for pt in pixeltypes
+%% if not pt.is_unknown()
+static int compare_{{ fs[0] }}_{{ pt.name }}(void)
+{
+ return compare_{{ fs[0] }}({{ pt.C_type }});
+}
+%% endif
+%% endfor
+%% endfor
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Filters Compare",
+ .tests = {
+%% for fs in compare_list
+%% for pt in pixeltypes
+%% if not pt.is_unknown()
+ {.name = "Compare {{ fs[0] }} {{ pt.name }}",
+ .tst_fn = compare_{{ fs[0] }}_{{ pt.name }},
+ .flags = TST_CHECK_MALLOC},
+%% endif
+%% endfor
+%% endfor
+ {.name = NULL}
+ }
+};
+
+%% endblock body
diff --git a/tests/filters/Makefile b/tests/filters/Makefile
index 986710f..8834428 100644
--- a/tests/filters/Makefile
+++ b/tests/filters/Makefile
@@ -3,9 +3,9 @@ include $(TOPDIR)/pre.mk
CSOURCES=FilterMirrorH.c
-GENSOURCES=APICoverage.gen.c
+GENSOURCES=APICoverage.gen.c FiltersCompare.gen.c
-APPS=FilterMirrorH APICoverage.gen
+APPS=FilterMirrorH APICoverage.gen FiltersCompare.gen
include ../tests.mk
diff --git a/tests/filters/test_list.txt b/tests/filters/test_list.txt
index 4b3dee1..0e62d87 100644
--- a/tests/filters/test_list.txt
+++ b/tests/filters/test_list.txt
@@ -1,4 +1,5 @@
# Filters test list
APICoverage.gen
+FiltersCompare.gen
FilterMirrorH
-----------------------------------------------------------------------
Summary of changes:
tests/filters/APICoverage.gen.c.t | 159 +++++++++++++++-------
tests/filters/FiltersCompare.gen.c.t | 241 ++++++++++++++++++++++++++++++++++
tests/filters/Makefile | 4 +-
tests/filters/test_list.txt | 1 +
4 files changed, 353 insertions(+), 52 deletions(-)
create mode 100644 tests/filters/FiltersCompare.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
07 Oct '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 22988118088f5fb0de21f8ea6ada75be2b42f446 (commit)
via 02949ce0fdd4f830bdf22fee95464373933aa7ec (commit)
from 5a637f76e46988a072403ed95db859f61e12193c (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/22988118088f5fb0de21f8ea6ada75be2b42…
commit 22988118088f5fb0de21f8ea6ada75be2b42f446
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Oct 7 15:41:38 2013 +0200
configure: Fix _FORTIFY_SOURCE redefinition.
Some systems enables _FORTIFY_SOURCE by default which leads to tons of
redefiniton warnings. Fix this by checking if _FORTIFY_SOURCE is defined
in configure script (also disable _FORTIFY_SOURCE if no optimalizations
are done).
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/configure b/configure
index c7b7409..5af836e 100755
--- a/configure
+++ b/configure
@@ -23,8 +23,8 @@ def header_exists(cfg, filename):
def c_try_compile(cfg, code, msg):
sys.stderr.write(msg)
- ret = os.system("echo '%s' | %s -x c -o /dev/null - > /dev/null 2>&1" %
- (code, cfg["CC"][0]))
+ ret = os.system("echo '%s' | %s %s -x c -o /dev/null - > /dev/null 2>&1" %
+ (code, cfg['CC'][0], cfg['CFLAGS'][0]))
if ret:
sys.stderr.write("Non")
@@ -38,6 +38,16 @@ def c_compiler_exists(cfg):
"Checking for working compiler (%s) ... " %
cfg["CC"][0])
+def define_fortify_source(cfg):
+ return c_try_compile(cfg, "int main(void) {n" +
+ "#if !defined _FORTIFY_SOURCE &&" +
+ "defined __OPTIMIZE__ && __OPTIMIZE__n" +
+ " return 0;n" +
+ "#elsen" +
+ " #error FORTIFY_SOURCE not usablen" +
+ "#endifn" +
+ "}", "Whether to define _FORTIFY_SOURCE ... ");
+
def python_version(cfg):
sys.stderr.write("Checking for python-config Python version ... ")
@@ -209,6 +219,9 @@ def basic_checks(cfg):
check_for_swig(cfg)
check_for_python_config(cfg)
+ if define_fortify_source(cfg):
+ cfg['CFLAGS'][0] = cfg['CFLAGS'][0] + " -D_FORTIFY_SOURCE=2"
+
cfg['PYTHON_VER'][0] = python_version(cfg)
if cfg['libdir'][0] == '':
@@ -290,7 +303,7 @@ if __name__ == '__main__':
# Dictionary for default configuration parameters
#
cfg = {'CC' : ['gcc', 'Path/name of the C compiler'],
- 'CFLAGS' : ['-pthread -W -Wall -Wextra -fPIC -O2 -ggdb -D_FORTIFY_SOURCE=2', 'C compiler flags'],
+ 'CFLAGS' : ['-pthread -W -Wall -Wextra -fPIC -O2 -ggdb', 'C compiler flags'],
'PYTHON_BIN' : ['python', 'Path/name of python interpreter'],
'SWIG' : ['swig', 'Simplified Wrapper and Interface Generator'],
'PYTHON_CONFIG' : ['python-config', 'Python config helper'],
http://repo.or.cz/w/gfxprim.git/commit/02949ce0fdd4f830bdf22fee95464373933a…
commit 02949ce0fdd4f830bdf22fee95464373933aa7ec
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Oct 7 15:22:21 2013 +0200
gen: Rename pixeltype.C_enum to pixeltype.C_type
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gp_codegen/pixeltype.py b/pylib/gp_codegen/pixeltype.py
index 2e89931..bcad7fc 100644
--- a/pylib/gp_codegen/pixeltype.py
+++ b/pylib/gp_codegen/pixeltype.py
@@ -51,8 +51,7 @@ class PixelType(object):
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
-
+ self.C_type = "GP_PIXEL_" + self.name
# Verify channel bits for overlaps
# also builds a bit-map of the PixelType
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t
index 8e9cf2a..945903a 100644
--- a/tests/core/Convert.gen.c.t
+++ b/tests/core/Convert.gen.c.t
@@ -39,7 +39,7 @@ static GP_Pixel get_black(GP_PixelType pixel_type)
{
switch (pixel_type) {
%% for pt in pixeltypes
- case {{ pt.C_enum }}:
+ case {{ pt.C_type }}:
%% if pt.is_cmyk()
%% set K = pt.chans['K']
/* Black in CMYK is full K rest zero */
@@ -65,7 +65,7 @@ static GP_Pixel get_white(GP_PixelType pixel_type)
{
switch (pixel_type) {
%% for pt in pixeltypes
- case {{ pt.C_enum }}:
+ case {{ pt.C_type }}:
%% if pt.is_cmyk()
/* White in CMYK is zero */
return 0x0;
@@ -110,7 +110,7 @@ static GP_Pixel get_red(GP_PixelType pixel_type)
{
switch (pixel_type) {
%% for pt in pixeltypes
- case {{ pt.C_enum }}:
+ case {{ pt.C_type }}:
%% if pt.is_cmyk()
%% set M = pt.chans['M']
%% set Y = pt.chans['Y']
-----------------------------------------------------------------------
Summary of changes:
configure | 19 ++++++++++++++++---
pylib/gp_codegen/pixeltype.py | 3 +--
tests/core/Convert.gen.c.t | 6 +++---
3 files changed, 20 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
01 Oct '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 5a637f76e46988a072403ed95db859f61e12193c (commit)
via 4be253c7c450ff945dc6a032161d85a49c985989 (commit)
via db44ff814ac02e9d8eff0e6069e75e3a49b86922 (commit)
from 2da60240b7ffcf3d81eb0c303a1f363fc6ea2732 (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/5a637f76e46988a072403ed95db859f61e12…
commit 5a637f76e46988a072403ed95db859f61e12193c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 1 22:08:39 2013 +0200
filters: Add missing header for edge detection filters.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/c_simple/v4l2_show.c b/demos/c_simple/v4l2_show.c
index c564f95..f11fb83 100644
--- a/demos/c_simple/v4l2_show.c
+++ b/demos/c_simple/v4l2_show.c
@@ -103,8 +103,8 @@ int main(int argc, char *argv[])
res = img;
break;
case 1:
- GP_FilterEdgePrewitt(img, &res, NULL, NULL);
- // GP_FilterEdgeSobel(img, &res, NULL, NULL);
+ // GP_FilterEdgePrewitt(img, &res, NULL, NULL);
+ GP_FilterEdgeSobel(img, &res, NULL, NULL);
break;
case 2:
GP_FilterGaussianBlur(img, img, 1, 1, NULL);
diff --git a/include/filters/GP_Filters.h b/include/filters/GP_EdgeDetection.h
similarity index 51%
copy from include/filters/GP_Filters.h
copy to include/filters/GP_EdgeDetection.h
index 621d232..94adc6e 100644
--- a/include/filters/GP_Filters.h
+++ b/include/filters/GP_EdgeDetection.h
@@ -16,68 +16,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-/*
-
- GP_Context filters.
-
- */
-
-#ifndef FILTERS_GP_FILTERS_H
-#define FILTERS_GP_FILTERS_H
-
-/* Filter per channel parameter passing interface */
-#include "filters/GP_FilterParam.h"
-
-/* Point filters, brightness, contrast ... */
-#include "filters/GP_Point.h"
-
-/* Addition, difference, min, max ... */
-#include "filters/GP_Arithmetic.h"
-
-/* Histograms, ... */
-#include "filters/GP_Stats.h"
-
-/* Image rotations (90 180 270 grads) and mirroring */
-#include "filters/GP_Rotate.h"
-
-/* Linear convolution Raw API */
-#include "filters/GP_Linear.h"
-
-/* Convolution filters */
-#include "filters/GP_Convolution.h"
-
-/* Blur filters */
-#include "filters/GP_Blur.h"
-
-/* Image scaling (resampling) */
-#include "filters/GP_Resize.h"
-#include "filters/GP_ResizeNN.h"
-#include "filters/GP_ResizeLinear.h"
-#include "filters/GP_ResizeCubic.h"
-
-/* Bitmap dithering */
-#include "filters/GP_Dither.h"
-
-/* Laplace based filters */
-#include "filters/GP_Laplace.h"
+#ifndef FILTERS_GP_EDGE_DETECTION_H
+#define FILTERS_GP_EDGE_DETECTION_H
-/* Median filter */
-#include "filters/GP_Median.h"
+#include "GP_Filter.h"
-/* Weighted Median filter */
-#include "filters/GP_WeightedMedian.h"
+int GP_FilterEdgeSobel(const GP_Context *src,
+ GP_Context **E, GP_Context **Phi,
+ GP_ProgressCallback *callback);
-/* Sigma Mean filter */
-#include "filters/GP_Sigma.h"
+int GP_FilterEdgePrewitt(const GP_Context *src,
+ GP_Context **E, GP_Context **Phi,
+ GP_ProgressCallback *callback);
-/* Gaussian noise filter */
-#include "filters/GP_GaussianNoise.h"
-#endif /* FILTERS_GP_FILTERS_H */
+#endif /* FILTERS_GP_EDGE_DETECTION_H */
diff --git a/include/filters/GP_Filters.h b/include/filters/GP_Filters.h
index 621d232..0a6b4d9 100644
--- a/include/filters/GP_Filters.h
+++ b/include/filters/GP_Filters.h
@@ -56,6 +56,9 @@
/* Blur filters */
#include "filters/GP_Blur.h"
+/* Edge detection filters */
+#include "filters/GP_EdgeDetection.h"
+
/* Image scaling (resampling) */
#include "filters/GP_Resize.h"
#include "filters/GP_ResizeNN.h"
diff --git a/libs/filters/GP_Edge.c b/libs/filters/GP_Edge.c
index 7d55077..01cc811 100644
--- a/libs/filters/GP_Edge.c
+++ b/libs/filters/GP_Edge.c
@@ -25,7 +25,8 @@
#include "core/GP_Debug.h"
#include "core/GP_GetPutPixel.h"
-#include "GP_Linear.h"
+#include "filters/GP_Linear.h"
+#include "filters/GP_EdgeDetection.h"
/*
* Apply prewitt operator.
http://repo.or.cz/w/gfxprim.git/commit/4be253c7c450ff945dc6a032161d85a49c98…
commit 4be253c7c450ff945dc6a032161d85a49c985989
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Sep 30 00:41:04 2013 +0200
filters; Blur: Fix 'assigment discards 'const' warning'.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_Blur.c b/libs/filters/GP_Blur.c
index 51155cf..147d675 100644
--- a/libs/filters/GP_Blur.c
+++ b/libs/filters/GP_Blur.c
@@ -79,7 +79,7 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src,
{
unsigned int size_x = gaussian_kernel_size(x_sigma);
unsigned int size_y = gaussian_kernel_size(y_sigma);
- GP_Context *tmp = dst;
+ const GP_Context *tmp = dst;
GP_DEBUG(1, "Gaussian blur x_sigma=%2.3f y_sigma=%2.3f kernel %ix%i image %ux%u",
x_sigma, y_sigma, size_x, size_y, w_src, h_src);
http://repo.or.cz/w/gfxprim.git/commit/db44ff814ac02e9d8eff0e6069e75e3a49b8…
commit db44ff814ac02e9d8eff0e6069e75e3a49b86922
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Sep 30 00:33:17 2013 +0200
core: include: Whitespace fixes.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/gfxprim_config.py b/gfxprim_config.py
index ae32019..4dcba55 100644
--- a/gfxprim_config.py
+++ b/gfxprim_config.py
@@ -1,7 +1,7 @@
#
# gfxprim_config.py - module configuring GfxPrim code generation and
# known PixelTypes
-#
+#
#
# 2011 Tomas Gavenciak <gavento(a)ucw.cz>
@@ -9,7 +9,7 @@
#
# This file is sourced by all the generating scripts.
# Moreover, the generated files are sourced by almost all Gfxprim sources,
-# so a complete recompilation is required after any change.
+# so a complete recompilation is required after any change.
#
# Declared pixel sizes:
@@ -38,7 +38,7 @@ config = GfxPrimConfig(
PS_18BPP_LE,
],
- # List of PixelTypes, order defines the numbering.
+ # List of PixelTypes, order defines the numbering.
# The "Undefined" type is added automatically.
pixeltypes = [
@@ -60,17 +60,17 @@ config = GfxPrimConfig(
('R', 16, 8),
('G', 8, 8),
('B', 0, 8)]),
-
+
PixelType(name='BGR888', pixelsize=PS_24BPP, chanslist=[
('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),
@@ -116,7 +116,7 @@ config = GfxPrimConfig(
PixelType(name='G8', pixelsize=PS_8BPP, chanslist=[
('V', 0, 8)]),
-
+
PixelType(name='G16', pixelsize=PS_16BPP, chanslist=[
('V', 0, 16)]),
]
diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t
index 22a3795..b59990a 100644
--- a/include/core/GP_Convert.gen.h.t
+++ b/include/core/GP_Convert.gen.h.t
@@ -56,46 +56,46 @@
%% if pt1.is_rgb() and pt2.is_cmyk()
{{ rgb_to_cmyk(pt1, pt2) -}}
%% else
-%% for c2 in pt2.chanslist
+%% for c2 in pt2.chanslist
{# case 1: just copy a channel -#}
-%% if c2[0] in pt1.chans.keys()
-%% set c1 = pt1.chans[c2[0]]
+%% if c2[0] in pt1.chans.keys()
+%% set c1 = pt1.chans[c2[0]]
/* {{ 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'
+%% elif c2[0]=='A'
/* 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()
+%% elif c2[0]=='V' and pt1.is_rgb()
/* V:=RGB_avg */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, ( -%% for c1 in [pt1.chans['R'], pt1.chans['G'], pt1.chans['B']]
+%% for c1 in [pt1.chans['R'], pt1.chans['G'], pt1.chans['B']]
/* {{ c1.name }} */ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1)) + -%% endfor
+%% endfor
0)/3); {# case 4: set each RGB to V -#}
-%% elif c2[0] in 'RGB' and pt1.is_gray()
-%% set c1 = pt1.chans['V']
+%% elif c2[0] in 'RGB' and pt1.is_gray()
+%% set c1 = pt1.chans['V']
/* {{ 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']
+%% elif c2[0] in 'RGB' and pt1.is_cmyk()
+%% set K = pt1.chans['K']
{# Get the right channel -#}
-%% if c2[0] == 'R'
-%% set V = pt1.chans['C']
-%% elif c2[0] == 'G'
-%% set V = pt1.chans['M']
-%% else
-%% set V = pt1.chans['Y']
-%% endif
+%% if c2[0] == 'R'
+%% set V = pt1.chans['C']
+%% elif c2[0] == 'G'
+%% set V = pt1.chans['M']
+%% else
+%% set V = pt1.chans['Y']
+%% 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 }})); {# case 7: invalid mapping -#}
-%% else
+%% else
{{ error('Channel conversion ' + pt1.name + ' to ' + pt2.name + ' not supported.') }}
-%% endif
-%% endfor
+%% endif
+%% endfor
%% endif
} while (0)
@@ -115,24 +115,22 @@
# Loop around "central" pixel types
-#}
%% for pt in [pixeltypes_dict['RGB888'], pixeltypes_dict['RGBA8888']]
-%% for i in pixeltypes
-%% if not i.is_unknown()
-%% if not i.is_palette()
+%% for i in pixeltypes
+%% if not i.is_unknown() and not i.is_palette()
{{ GP_Pixel_TYPE_TO_TYPE(pt, i) }}
-%% if i.name not in ['RGB888', 'RGBA8888']
+%% if i.name not in ['RGB888', 'RGBA8888']
{{ GP_Pixel_TYPE_TO_TYPE(i, pt) }}
-%% endif
-%% endif
-%% endif
-%% endfor
+%% endif
+%% endif
+%% endfor
-/*
+/*
* Convert {{ pt.name }} to any other PixelType
* Does not work on palette types at all (yet)
*/
GP_Pixel GP_{{ pt.name }}ToPixel(GP_Pixel pixel, GP_PixelType type);
-/*
+/*
* Function converting to {{ pt.name }} from any other PixelType
* Does not work on palette types at all (yet)
*/
diff --git a/include/core/GP_Convert_Scale.gen.h.t b/include/core/GP_Convert_Scale.gen.h.t
index 497fea7..b0156ad 100644
--- a/include/core/GP_Convert_Scale.gen.h.t
+++ b/include/core/GP_Convert_Scale.gen.h.t
@@ -30,7 +30,7 @@
{%- endmacro %}
%% block body
-/*
+/*
* Helper macros to transfer s1-bit value to s2-bit value.
* Efficient and accurate for both up- and downscaling.
* WARNING: GP_SCALE_VAL requires constants numbers as first two parameters
diff --git a/include/core/GP_FnPerBpp.gen.h.t b/include/core/GP_FnPerBpp.gen.h.t
index 11d5002..9b1cdcd 100644
--- a/include/core/GP_FnPerBpp.gen.h.t
+++ b/include/core/GP_FnPerBpp.gen.h.t
@@ -37,7 +37,7 @@
{% macro bpp_suffix(suffix) %}{% if suffix == "LE" or suffix == "BE" %}_{{ suffix }}{% endif %}{% endmacro %}
/*
- * Branch on bpp and bit_endian.
+ * Branch on bpp and bit_endian.
*/
#define GP_FN_PER_BPP(FN_NAME, bpp, bit_endian, ...) switch (bpp) { @@ -56,7 +56,7 @@
}
/*
- * Branch on bpp and bit_endian.
+ * Branch on bpp and bit_endian.
*/
#define GP_FN_RET_PER_BPP(FN_NAME, bpp, bit_endian, ...) switch (bpp) { diff --git a/include/core/GP_GetPutPixel.gen.h.t b/include/core/GP_GetPutPixel.gen.h.t
index 46325db..28ee82d 100644
--- a/include/core/GP_GetPutPixel.gen.h.t
+++ b/include/core/GP_GetPutPixel.gen.h.t
@@ -64,7 +64,7 @@ Do not include directly, use GP_Pixel.h
If pixel_size is coprime to 8, the offsets generates whole group and so the
max + pixel_size = 7 + pixel_size. The 17 BPP fits into 24 bits and so 3
bytes are needed. The 19 BPP fits into 26 bits and because of that 4 bytes
- are needed.
+ are needed.
Once we figure maximal number of bytes and the offset all that is to be done
is to fetch first and last byte to combine it together with given pixel value
@@ -76,7 +76,7 @@ Do not include directly, use GP_Pixel.h
#include "GP_Context.h"
%% for ps in pixelsizes
-/*
+/*
* macro to get address of pixel in a {{ ps.suffix }} context
*/
#define GP_PIXEL_ADDR_{{ ps.suffix }}(context, x, y) @@ -105,7 +105,7 @@ Do not include directly, use GP_Pixel.h
%% endif
/*
- * GP_GetPixel for {{ ps.suffix }}
+ * GP_GetPixel for {{ ps.suffix }}
*/
static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Context *c, int x, int y)
{
@@ -180,7 +180,7 @@ static inline GP_Pixel GP_GetPixel_Raw_{{ ps.suffix }}(const GP_Context *c, int
}
/*
- * GP_PutPixel for {{ ps.suffix }}
+ * GP_PutPixel for {{ ps.suffix }}
*/
static inline void GP_PutPixel_Raw_{{ ps.suffix }}(GP_Context *c, int x, int y, GP_Pixel p)
{
diff --git a/include/core/GP_GetSetBits.h b/include/core/GP_GetSetBits.h
index 1cd1e36..1a18d8a 100644
--- a/include/core/GP_GetSetBits.h
+++ b/include/core/GP_GetSetBits.h
@@ -49,7 +49,7 @@
*/
#define GP_GET_BITS(offset, len, val) (sizeof(val) * 8 <= len ? - (val)>>(offset) : + (val)>>(offset) : ((val)>>(offset)) & (((((typeof(val))1)<<(len)) - 1)))
/*
diff --git a/include/core/GP_MixPixels.gen.h.t b/include/core/GP_MixPixels.gen.h.t
index 41e9c3a..8067f4b 100644
--- a/include/core/GP_MixPixels.gen.h.t
+++ b/include/core/GP_MixPixels.gen.h.t
@@ -34,7 +34,7 @@ Macros to mix two pixels accordingly to percentage.
#include "core/GP_GammaCorrection.h"
%% for pt in pixeltypes
-%% if not pt.is_unknown()
+%% if not pt.is_unknown()
/*
* Mixes two {{ pt.name }} pixels.
@@ -42,14 +42,14 @@ Macros to mix two pixels accordingly to percentage.
* The percentage is expected as 8 bit unsigned integer [0 .. 255]
*/
#define GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc) ({ -%% for c in pt.chanslist
+%% for c in pt.chanslist
GP_Pixel {{ c[0] }}; {{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix1) * (perc); {{ c[0] }} += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix2) * (255 - (perc)); {{ c[0] }} = ({{ c[0] }} + 128) / 255; -%% endfor
+%% endfor
GP_Pixel_CREATE_{{ pt.name }}({{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, {{ c[0] }}{% endfor %}); })
@@ -60,7 +60,7 @@ Macros to mix two pixels accordingly to percentage.
* The percentage is expected as 8 bit unsigned integer [0 .. 255]
*/
#define GP_MIX_PIXELS_GAMMA_{{ pt.name }}(pix1, pix2, perc) ({ -%% for c in pt.chanslist
+%% for c in pt.chanslist
GP_Pixel {{ c[0] }}; {{ c[0] }} = GP_Gamma{{ c[2] }}ToLinear10(GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix1)) * (perc); @@ -68,19 +68,19 @@ Macros to mix two pixels accordingly to percentage.
{{ c[0] }} = ({{ c[0] }} + 128) / 255; {{ c[0] }} = GP_Linear10ToGamma{{ c[2] }}({{ c[0] }}); -%% endfor
+%% endfor
GP_Pixel_CREATE_{{ pt.name }}({{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, {{ c[0] }}{% endfor %}); })
#define GP_MIX_PIXELS_{{ pt.name }}(pix1, pix2, perc) -%% if pt.is_rgb()
+%% if pt.is_rgb()
GP_MIX_PIXELS_GAMMA_{{ pt.name }}(pix1, pix2, perc)
-%% else
+%% else
GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc)
-%% endif
+%% endif
-%% endif
+%% endif
%% endfor
static inline GP_Pixel GP_MixPixels(GP_Pixel pix1, GP_Pixel pix2,
@@ -88,10 +88,10 @@ static inline GP_Pixel GP_MixPixels(GP_Pixel pix1, GP_Pixel pix2,
{
switch (pixel_type) {
%% for pt in pixeltypes
-%% if not pt.is_unknown()
+%% if not pt.is_unknown()
case GP_PIXEL_{{ pt.name }}:
return GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc);
-%% endif
+%% endif
%% endfor
default:
GP_ABORT("Unknown pixeltype");
@@ -100,7 +100,7 @@ static inline GP_Pixel GP_MixPixels(GP_Pixel pix1, GP_Pixel pix2,
%% for pt in pixeltypes
-%% if not pt.is_unknown()
+%% if not pt.is_unknown()
static inline void GP_MixPixel_Raw_{{ pt.name }}(GP_Context *context,
GP_Coord x, GP_Coord y, GP_Pixel pixel, uint8_t perc)
{
@@ -109,11 +109,11 @@ static inline void GP_MixPixel_Raw_{{ pt.name }}(GP_Context *context,
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(context, x, y, pix);
}
-%% endif
+%% endif
%% endfor
%% for pt in pixeltypes
-%% if not pt.is_unknown()
+%% if not pt.is_unknown()
static inline void GP_MixPixel_Raw_Clipped_{{ pt.name }}(GP_Context *context,
GP_Coord x, GP_Coord y, GP_Pixel pixel, uint8_t perc)
{
@@ -123,7 +123,7 @@ static inline void GP_MixPixel_Raw_Clipped_{{ pt.name }}(GP_Context *context,
GP_MixPixel_Raw_{{ pt.name }}(context, x, y, pixel, perc);
}
-%% endif
+%% endif
%% endfor
static inline void GP_MixPixel_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
@@ -131,11 +131,11 @@ static inline void GP_MixPixel_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
{
switch (context->pixel_type) {
%% for pt in pixeltypes
-%% if not pt.is_unknown()
+%% if not pt.is_unknown()
case GP_PIXEL_{{ pt.name }}:
- GP_MixPixel_Raw_{{ pt.name }}(context, x, y, pixel, perc);
+ GP_MixPixel_Raw_{{ pt.name }}(context, x, y, pixel, perc);
break;
-%% endif
+%% endif
%% endfor
default:
GP_ABORT("Unknown pixeltype");
@@ -148,11 +148,11 @@ static inline void GP_MixPixel_Raw_Clipped(GP_Context *context,
{
switch (context->pixel_type) {
%% for pt in pixeltypes
-%% if not pt.is_unknown()
+%% if not pt.is_unknown()
case GP_PIXEL_{{ pt.name }}:
GP_MixPixel_Raw_Clipped_{{ pt.name }}(context, x, y, pixel, perc);
break;
-%% endif
+%% endif
%% endfor
default:
GP_ABORT("Unknown pixeltype");
diff --git a/include/core/GP_MixPixels2.gen.h.t b/include/core/GP_MixPixels2.gen.h.t
index 5810a66..084ae55 100644
--- a/include/core/GP_MixPixels2.gen.h.t
+++ b/include/core/GP_MixPixels2.gen.h.t
@@ -56,7 +56,7 @@ static inline GP_Pixel GP_MixPixels_{{ src.name }}_{{ dst.name }}(GP_Pixel src,
sr = GP_Pixel_GET_R_RGB888(src_rgb);
sg = GP_Pixel_GET_G_RGB888(src_rgb);
sb = GP_Pixel_GET_B_RGB888(src_rgb);
-
+
dr = GP_Pixel_GET_R_RGB888(dst_rgb);
dg = GP_Pixel_GET_G_RGB888(dst_rgb);
db = GP_Pixel_GET_B_RGB888(dst_rgb);
diff --git a/include/core/GP_Pixel.gen.h.t b/include/core/GP_Pixel.gen.h.t
index e0c0a61..2bc5469 100644
--- a/include/core/GP_Pixel.gen.h.t
+++ b/include/core/GP_Pixel.gen.h.t
@@ -30,8 +30,8 @@ Do not include directly, use GP_Pixel.h
%% block body
-/*
- * List of all known pixel types
+/*
+ * List of all known pixel types
*/
typedef enum GP_PixelType {
%% for pt in pixeltypes
@@ -45,24 +45,24 @@ typedef enum GP_PixelType {
%% endfor
%% for pt in pixeltypes
-%% if not pt.is_unknown()
+%% if not pt.is_unknown()
/* Automatically generated code for pixel type {{ pt.name }}
*
* Size (bpp): {{ pt.pixelsize.size }} ({{ pt.pixelsize.suffix }})
* Bit endian: {{ pt.pixelsize.bit_endian_const }}
* Pixel structure: {{ pt.bits|join("") }}
- * Channels:
-%% for c in pt.chanslist
+ * Channels:
+%% for c in pt.chanslist
* {{ c[0] }} offset:{{ c[1] }} size:{{ c[2] }}
-%% endfor
+%% endfor
*/
/*
* macros to get channels of pixel type {{ pt.name }}
*/
-%% for c in pt.chanslist
+%% for c in pt.chanslist
#define GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(p) (GP_GET_BITS({{ c[1] }}, {{ c[2] }}, (p)))
-%% endfor
+%% endfor
/*
* macros to get address and bit-offset of a pixel {{ pt.name }} in a context
@@ -70,33 +70,33 @@ typedef enum GP_PixelType {
#define GP_PIXEL_ADDR_{{ pt.name }}(context, x, y) GP_PIXEL_ADDR_{{ pt.pixelsize.suffix }}(context, x, y)
#define GP_PIXEL_ADDR_OFFSET_{{ pt.name }}(x) GP_PIXEL_ADDR_OFFSET_{{ pt.pixelsize.suffix }}(x)
-/*
+/*
* macros to create GP_Pixel of pixel type {{ pt.name }} directly from given values.
* The values MUST be already clipped/converted to relevant value ranges.
*/
#define GP_Pixel_CREATE_{{ pt.name }}({{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, {{ c[0] }}{% endfor %}) (0-%% for c in pt.chanslist
+%% for c in pt.chanslist
+ (({{ c[0] }}) << {{ c[1] }}) -%% endfor
+%% endfor
)
-%% endif
+%% endif
%% endfor
-/*
+/*
* macros for branching on PixelType (similar to GP_FnPerBpp macros)
*/
%% for r in ['', 'return ']
#define GP_FN_{% if r %}RET_{% endif %}PER_PIXELTYPE(FN_NAME, type, ...) switch (type) { -%% for pt in pixeltypes
-%% if not pt.is_unknown()
+%% for pt in pixeltypes
+%% if not pt.is_unknown()
case GP_PIXEL_{{ pt.name }}: {{ r }}FN_NAME{{'##'}}_{{ pt.name }}(__VA_ARGS__); break;-%% endif
-%% endfor
+%% endif
+%% endfor
default: GP_ABORT("Invalid PixelType %d", type); }
diff --git a/include/core/GP_WritePixel.gen.h.t b/include/core/GP_WritePixel.gen.h.t
index b4ce29e..015dc7c 100644
--- a/include/core/GP_WritePixel.gen.h.t
+++ b/include/core/GP_WritePixel.gen.h.t
@@ -33,14 +33,14 @@
*/
%% for ps in pixelsizes
-%% if ps.needs_bit_endian()
+%% if ps.needs_bit_endian()
void GP_WritePixels_{{ ps.suffix }}(void *start, uint8_t off,
size_t cnt, unsigned int val);
-%% else
+%% else
void GP_WritePixels_{{ ps.suffix }}(void *start, size_t cnt, unsigned int val);
-%% endif
+%% endif
%% endfor
{% endblock body %}
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/v4l2_show.c | 4 +-
gfxprim_config.py | 14 ++--
include/core/GP_Convert.gen.h.t | 60 ++++++++++----------
include/core/GP_Convert_Scale.gen.h.t | 2 +-
include/core/GP_FnPerBpp.gen.h.t | 4 +-
include/core/GP_GetPutPixel.gen.h.t | 8 +-
include/core/GP_GetSetBits.h | 2 +-
include/core/GP_MixPixels.gen.h.t | 40 +++++++-------
include/core/GP_MixPixels2.gen.h.t | 2 +-
include/core/GP_Pixel.gen.h.t | 34 ++++++------
include/core/GP_WritePixel.gen.h.t | 6 +-
.../filters/GP_EdgeDetection.h | 26 +++-----
include/filters/GP_Filters.h | 3 +
libs/filters/GP_Blur.c | 2 +-
libs/filters/GP_Edge.c | 3 +-
15 files changed, 103 insertions(+), 107 deletions(-)
copy demos/c_simple/pretty_print.c => include/filters/GP_EdgeDetection.h (78%)
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