Gfxprim
Threads by month
- ----- 2026 -----
- February
- 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
May 2012
- 2 participants
- 55 discussions
[repo.or.cz] gfxprim.git branch master updated: c404e7e68b3d6567519cb2fcb45ea5fc652add35
by metan 27 May '12
by metan 27 May '12
27 May '12
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 c404e7e68b3d6567519cb2fcb45ea5fc652add35 (commit)
from dcc74ee0d1808272efbf16ebb9a3d6dfaa20ff26 (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/c404e7e68b3d6567519cb2fcb45ea5fc652a…
commit c404e7e68b3d6567519cb2fcb45ea5fc652add35
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 27 12:16:50 2012 +0200
demos: py_simple: Fix blur example.
diff --git a/demos/py_simple/blur.py b/demos/py_simple/blur.py
index 80c35de..ca50658 100755
--- a/demos/py_simple/blur.py
+++ b/demos/py_simple/blur.py
@@ -17,7 +17,7 @@ def main():
# Do in-place gaussian blur
filters.FilterGaussianBlur(img, img, radii, radii, None)
# Save result
- loaders.SaveJPG("out.jpg", img, None)
+ loaders.SaveJPG(img, "out.jpg", None)
if __name__ == '__main__':
main()
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/blur.py | 2 +-
1 files changed, 1 insertions(+), 1 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
[repo.or.cz] gfxprim.git branch master updated: dcc74ee0d1808272efbf16ebb9a3d6dfaa20ff26
by metan 26 May '12
by metan 26 May '12
26 May '12
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 dcc74ee0d1808272efbf16ebb9a3d6dfaa20ff26 (commit)
from 4b5f8e14db9cd157d1b3b616726b1c9fb1b3c9b5 (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/dcc74ee0d1808272efbf16ebb9a3d6dfaa20…
commit dcc74ee0d1808272efbf16ebb9a3d6dfaa20ff26
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 26 20:54:43 2012 +0200
backends: Print error when initalizing not-compiled-in backend.
diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c
index fcc0df7..5705eec 100644
--- a/libs/backends/GP_SDL.c
+++ b/libs/backends/GP_SDL.c
@@ -25,9 +25,10 @@
#include "../../config.h"
+#include "core/GP_Debug.h"
+
#ifdef HAVE_LIBSDL
-#include "core/GP_Debug.h"
#include "input/GP_InputDriverSDL.h"
#include "GP_Backend.h"
#include "GP_SDL.h"
@@ -208,6 +209,7 @@ GP_Backend *GP_BackendSDLInit(GP_Size w __attribute__((unused)),
uint8_t flags __attribute__((unused)),
const char *caption __attribute__((unused)))
{
+ GP_DEBUG(0, "FATAL: SDL support not compiled in.");
return NULL;
}
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index 3db2724..ffc7dca 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -22,12 +22,14 @@
#include "../../config.h"
+#include "core/GP_Debug.h"
+#include "core/GP_Common.h"
+
#ifdef HAVE_LIBX11
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-#include "core/GP_Debug.h"
#include "input/GP_InputDriverX11.h"
#include "GP_X11.h"
@@ -375,10 +377,13 @@ err0:
#include "GP_Backend.h"
-GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
- unsigned int w, unsigned int h,
- const char *caption)
+GP_Backend *GP_BackendX11Init(const char *GP_UNUSED(display),
+ int GP_UNUSED(x), int GP_UNUSED(y),
+ unsigned int GP_UNUSED(w),
+ unsigned int GP_UNUSED(h),
+ const char *GP_UNUSED(caption))
{
+ GP_DEBUG(0, "FATAL: X11 support not compiled in");
return NULL;
}
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_SDL.c | 4 +++-
libs/backends/GP_X11.c | 13 +++++++++----
2 files changed, 12 insertions(+), 5 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
[repo.or.cz] gfxprim.git branch master updated: 4b5f8e14db9cd157d1b3b616726b1c9fb1b3c9b5
by metan 26 May '12
by metan 26 May '12
26 May '12
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 4b5f8e14db9cd157d1b3b616726b1c9fb1b3c9b5 (commit)
via cb75b76577a6680789268db88f8133d6c5910743 (commit)
via 0fe41f6f329aa64d7f7cdefe6666b4140fcf49c9 (commit)
via 3c6ce96d9864ad661d99840a571888c2633c1f6f (commit)
from ce280e141cd211cffe37af58fe420428740ae7ba (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/4b5f8e14db9cd157d1b3b616726b1c9fb1b3…
commit 4b5f8e14db9cd157d1b3b616726b1c9fb1b3c9b5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 26 20:38:53 2012 +0200
py_simple: Fix python example after the API update.
diff --git a/demos/py_simple/rotate90.py b/demos/py_simple/rotate90.py
index d93756b..f4f2ad3 100755
--- a/demos/py_simple/rotate90.py
+++ b/demos/py_simple/rotate90.py
@@ -16,7 +16,7 @@ def main():
# Load Image
src = loaders.LoadImage(sys.argv[1], None)
# Rotate by 90 degrees
- res = filters.FilterRotate90Alloc(src, None)
+ res = filters.FilterRotate90_Alloc(src, None)
# Save Image
res.Save(sys.argv[2])
http://repo.or.cz/w/gfxprim.git/commit/cb75b76577a6680789268db88f8133d6c591…
commit cb75b76577a6680789268db88f8133d6c5910743
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 26 20:35:48 2012 +0200
pywrap: Set GP_FilterSymmetryNames array to immutable.
diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i
index 3ee7227..866ea9b 100644
--- a/pylib/gfxprim/filters/filters.i
+++ b/pylib/gfxprim/filters/filters.i
@@ -24,6 +24,8 @@
%include "GP_Resize.h"
/* Functions returning new allocated context */
+%immutable GP_FilterSymmetryNames;
+
%include "GP_Rotate.h"
%newobject GP_FilterMirrorH_Alloc;
http://repo.or.cz/w/gfxprim.git/commit/0fe41f6f329aa64d7f7cdefe6666b4140fcf…
commit 0fe41f6f329aa64d7f7cdefe6666b4140fcf49c9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 26 20:32:09 2012 +0200
doc: Update Rotate filters docs.
diff --git a/doc/filters.txt b/doc/filters.txt
index a751015..fad32b2 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -110,68 +110,83 @@ Rotation and Symmetry filters
-------------------------------------------------------------------------------
#include <GP_Filters.h>
-GP_Context *GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterMirrorH_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Mirrors context horizontally.
Works 'in-place'.
-The destination has to have the same pixel type and the destination size must
-be at least as big as source.
+The destination has to have the same pixel type and the size must be at least
+as large as source.
[source,c]
-------------------------------------------------------------------------------
#include <GP_Filters.h>
-GP_Context *GP_FilterMirrorV(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterMirrorV_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Mirrors context vertically.
Works 'in-place'.
-the destination has to have the same pixel type and the destination size must
-be at least as big as source.
+The destination has to have the same pixel type and the size must be at least
+as large as source.
[source,c]
-------------------------------------------------------------------------------
#include <GP_Filters.h>
-GP_Context *GP_FilterRotate90(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterRotate90(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterRotate90_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Rotate context by 90 degrees.
Doesn't work 'in-place' (yet).
-The destination has to have the same pixel type and destination size must be
-big enough to fit rotated context (i.e. W and H are swapped).
+The destination has to have the same pixel type and size must be large enough to
+fit rotated context (i.e. W and H are swapped).
[source,c]
-------------------------------------------------------------------------------
#include <GP_Filters.h>
-GP_Context *GP_FilterRotate180(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterRotate180(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterRotate180_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Rotate context by 180 degrees.
Doesn't work 'in-place' (yet).
-the destination has to have the same pixel type and the destination size must
-be at least as big as source.
+The destination has to have the same pixel type and the size must be at least
+as large as source.
[source,c]
-------------------------------------------------------------------------------
#include <GP_Filters.h>
-GP_Context *GP_FilterRotate270(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterRotate270(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+GP_Context *GP_FilterRotate270_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Rotate context by 270 degrees.
@@ -179,7 +194,7 @@ Rotate context by 270 degrees.
Doesn't work 'in-place' (yet).
The destination has to have the same pixel type and destination size must be
-big enough to fit rotated context (eg. W and H are swapped).
+large enough to fit rotated context (eg. W and H are swapped).
[source,c]
-------------------------------------------------------------------------------
@@ -193,9 +208,13 @@ typedef enum GP_FilterSymmetries {
GP_MIRROR_V,
} GP_FilterSymmetries;
-GP_Context *GP_FilterSymmetry(const GP_Context *src, GP_Context *dst,
+GP_Context *GP_FilterSymmetry(const GP_Context *src,
GP_FilterSymmetries symmetry,
GP_ProgressCallback *callback);
+
+int GP_FilterSymmetry(const GP_Context *src, GP_Context *dst,
+ GP_FilterSymmetries symmetry,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Catch all function for symmetry filters.
http://repo.or.cz/w/gfxprim.git/commit/3c6ce96d9864ad661d99840a571888c2633c…
commit 3c6ce96d9864ad661d99840a571888c2633c1f6f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 26 20:31:27 2012 +0200
filters: Update Rotate filters API.
diff --git a/demos/c_simple/filters_symmetry.c b/demos/c_simple/filters_symmetry.c
index 3f130a4..c1f5068 100644
--- a/demos/c_simple/filters_symmetry.c
+++ b/demos/c_simple/filters_symmetry.c
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
}
/* Apply a symmetry filter */
- res = GP_FilterSymmetryAlloc(src, sym, NULL);
+ res = GP_FilterSymmetry_Alloc(src, sym, NULL);
/* Save Image */
if (GP_SaveImage(res, argv[optind+1], NULL)) {
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c
index fe51530..3da5037 100644
--- a/demos/grinder/grinder.c
+++ b/demos/grinder/grinder.c
@@ -227,13 +227,13 @@ static GP_RetCode rotate(GP_Context **c, const char *params)
switch (rot) {
case 0:
- res = GP_FilterRotate90Alloc(*c, progress_callback);
+ res = GP_FilterRotate90_Alloc(*c, progress_callback);
break;
case 1:
- res = GP_FilterRotate180Alloc(*c, progress_callback);
+ res = GP_FilterRotate180_Alloc(*c, progress_callback);
break;
case 2:
- res = GP_FilterRotate270Alloc(*c, progress_callback);
+ res = GP_FilterRotate270_Alloc(*c, progress_callback);
break;
}
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index c6b086e..77c3bc4 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -255,15 +255,15 @@ static void *image_loader(void *ptr)
break;
case 90:
callback.priv = "Rotating image (90)";
- img = GP_FilterRotate90Alloc(ret, &callback);
+ img = GP_FilterRotate90_Alloc(ret, &callback);
break;
case 180:
callback.priv = "Rotating image (180)";
- img = GP_FilterRotate180Alloc(ret, &callback);
+ img = GP_FilterRotate180_Alloc(ret, &callback);
break;
case 270:
callback.priv = "Rotating image (270)";
- img = GP_FilterRotate270Alloc(ret, &callback);
+ img = GP_FilterRotate270_Alloc(ret, &callback);
break;
}
diff --git a/include/filters/GP_Rotate.h b/include/filters/GP_Rotate.h
index 0957010..7c39ced 100644
--- a/include/filters/GP_Rotate.h
+++ b/include/filters/GP_Rotate.h
@@ -49,9 +49,9 @@ int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst,
*
* The filter works 'in-place' which means that src and dst
* may be very same context. Note that when aborting in-place operation
- * the image buffer gets into an inconsitent state.
+ * the image buffer gets into an inconsistent state.
*
- * Retruns zero on success, non-zero if operation was aborted.
+ * Returns zero on success, non-zero if operation was aborted.
*/
int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback);
@@ -62,8 +62,8 @@ int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
* Returns pointer to newly allocated context, or NULL if malloc() has failed
* or operation was aborted from withing a callback.
*/
-GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
- GP_ProgressCallback *callback);
+GP_Context *GP_FilterMirrorH_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback);
/*
* Mirror vertically
@@ -82,9 +82,9 @@ int GP_FilterMirrorV_Raw(const GP_Context *src, GP_Context *dst,
*
* The filter works 'in-place' which means that src and dst
* may be very same context. Note that when aborting in-place operation
- * the image buffer gets into an inconsitent state.
+ * the image buffer gets into an inconsistent state.
*
- * Retruns zero on success, non-zero if operation was aborted.
+ * Returns zero on success, non-zero if operation was aborted.
*/
int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback);
@@ -95,8 +95,8 @@ int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst,
* Returns pointer to newly allocated context, or NULL if malloc() has failed
* or operation was aborted from withing a callback.
*/
-GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src,
- GP_ProgressCallback *callback);
+GP_Context *GP_FilterMirrorV_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback);
/*
* Rotate context by 90, 180 and 270.
@@ -123,20 +123,20 @@ int GP_FilterRotate270_Raw(const GP_Context *src, GP_Context *dst,
int GP_FilterRotate90(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback);
-GP_Context *GP_FilterRotate90Alloc(const GP_Context *src,
- GP_ProgressCallback *callback);
+GP_Context *GP_FilterRotate90_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback);
int GP_FilterRotate180(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback);
-GP_Context *GP_FilterRotate180Alloc(const GP_Context *src,
+GP_Context *GP_FilterRotate180_Alloc(const GP_Context *src,
GP_ProgressCallback *callback);
int GP_FilterRotate270(const GP_Context *src, GP_Context *dst,
GP_ProgressCallback *callback);
-GP_Context *GP_FilterRotate270Alloc(const GP_Context *src,
- GP_ProgressCallback *callback);
+GP_Context *GP_FilterRotate270_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback);
/*
* Calls a symmetry filter on bitmap.
@@ -168,12 +168,12 @@ extern const char **GP_FilterSymmetryNames;
*/
int GP_FilterSymmetryByName(const char *symmetry);
-GP_Context *GP_FilterSymmetryAlloc(const GP_Context *src,
- GP_FilterSymmetries symmetry,
- GP_ProgressCallback *callback);
-
int GP_FilterSymmetry(const GP_Context *src, GP_Context *dst,
GP_FilterSymmetries symmetry,
GP_ProgressCallback *callback);
+GP_Context *GP_FilterSymmetry_Alloc(const GP_Context *src,
+ GP_FilterSymmetries symmetry,
+ GP_ProgressCallback *callback);
+
#endif /* FILTERS_GP_ROTATE_H */
diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c
index d758535..7bfa309 100644
--- a/libs/filters/GP_Rotate.c
+++ b/libs/filters/GP_Rotate.c
@@ -84,8 +84,8 @@ int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
return 0;
}
-GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
- GP_ProgressCallback *callback)
+GP_Context *GP_FilterMirrorH_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback)
{
GP_Context *res;
@@ -118,8 +118,8 @@ int GP_FilterMirrorV(const GP_Context *src, GP_Context *dst,
return 0;
}
-GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src,
- GP_ProgressCallback *callback)
+GP_Context *GP_FilterMirrorV_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback)
{
GP_Context *res;
@@ -163,8 +163,8 @@ int GP_FilterRotate90(const GP_Context *src, GP_Context *dst,
return 0;
}
-GP_Context *GP_FilterRotate90Alloc(const GP_Context *src,
- GP_ProgressCallback *callback)
+GP_Context *GP_FilterRotate90_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback)
{
GP_Context *res;
@@ -198,8 +198,8 @@ int GP_FilterRotate180(const GP_Context *src, GP_Context *dst,
return 0;
}
-GP_Context *GP_FilterRotate180Alloc(const GP_Context *src,
- GP_ProgressCallback *callback)
+GP_Context *GP_FilterRotate180_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback)
{
GP_Context *res;
@@ -233,8 +233,8 @@ int GP_FilterRotate270(const GP_Context *src, GP_Context *dst,
return 0;
}
-GP_Context *GP_FilterRotate270Alloc(const GP_Context *src,
- GP_ProgressCallback *callback)
+GP_Context *GP_FilterRotate270_Alloc(const GP_Context *src,
+ GP_ProgressCallback *callback)
{
GP_Context *res;
@@ -274,21 +274,21 @@ int GP_FilterSymmetryByName(const char *symmetry)
return -1;
}
-GP_Context *GP_FilterSymmetryAlloc(const GP_Context *src,
- GP_FilterSymmetries symmetry,
- GP_ProgressCallback *callback)
+GP_Context *GP_FilterSymmetry_Alloc(const GP_Context *src,
+ GP_FilterSymmetries symmetry,
+ GP_ProgressCallback *callback)
{
switch (symmetry) {
case GP_ROTATE_90:
- return GP_FilterRotate90Alloc(src, callback);
+ return GP_FilterRotate90_Alloc(src, callback);
case GP_ROTATE_180:
- return GP_FilterRotate180Alloc(src, callback);
+ return GP_FilterRotate180_Alloc(src, callback);
case GP_ROTATE_270:
- return GP_FilterRotate270Alloc(src, callback);
+ return GP_FilterRotate270_Alloc(src, callback);
case GP_MIRROR_H:
- return GP_FilterMirrorHAlloc(src, callback);
+ return GP_FilterMirrorH_Alloc(src, callback);
case GP_MIRROR_V:
- return GP_FilterMirrorVAlloc(src, callback);
+ return GP_FilterMirrorV_Alloc(src, callback);
default:
GP_DEBUG(1, "Invalid symmetry %i", (int) symmetry);
return NULL;
diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i
index 11a2426..3ee7227 100644
--- a/pylib/gfxprim/filters/filters.i
+++ b/pylib/gfxprim/filters/filters.i
@@ -26,15 +26,13 @@
/* Functions returning new allocated context */
%include "GP_Rotate.h"
-%newobject GP_FilterMirrorHAlloc;
-%newobject GP_FilterMirrorVAlloc;
-%newobject GP_FilterRotate90Alloc;
-%newobject GP_FilterRotate180Alloc;
-%newobject GP_FilterRotate270Alloc;
-%newobject GP_FilterSymmetryAlloc;
+%newobject GP_FilterMirrorH_Alloc;
+%newobject GP_FilterMirrorV_Alloc;
+%newobject GP_FilterRotate90_Alloc;
+%newobject GP_FilterRotate180_Alloc;
+%newobject GP_FilterRotate270_Alloc;
+%newobject GP_FilterSymmetry_Alloc;
-
-/* Dithering */
%include "GP_Dither.h"
%newobject GP_FilterFloydSteinberg_RGB888_Alloc;
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/filters_symmetry.c | 2 +-
demos/grinder/grinder.c | 6 ++--
demos/py_simple/rotate90.py | 2 +-
demos/spiv/spiv.c | 6 ++--
doc/filters.txt | 59 ++++++++++++++++++++++++------------
include/filters/GP_Rotate.h | 34 ++++++++++----------
libs/filters/GP_Rotate.c | 36 +++++++++++-----------
pylib/gfxprim/filters/filters.i | 16 +++++-----
8 files changed, 90 insertions(+), 71 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
[repo.or.cz] gfxprim.git branch master updated: ce280e141cd211cffe37af58fe420428740ae7ba
by metan 26 May '12
by metan 26 May '12
26 May '12
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 ce280e141cd211cffe37af58fe420428740ae7ba (commit)
via e927ca0d6dbde34dc5ac7beda7a8665f8e4f1bdd (commit)
via 1b8274d61463a47398e4100fc554ed8fa9b0366b (commit)
via 648c8a5e14dc4159ed1cb65199b9ec7fb47116c6 (commit)
from f48d899fd136b662a6a5bd7820089dff4c309c72 (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/ce280e141cd211cffe37af58fe420428740a…
commit ce280e141cd211cffe37af58fe420428740ae7ba
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 26 19:08:58 2012 +0200
pywrap: Update dithering filter wrapping.
diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i
index b617508..11a2426 100644
--- a/pylib/gfxprim/filters/filters.i
+++ b/pylib/gfxprim/filters/filters.i
@@ -20,15 +20,22 @@
%include "GP_Arithmetic.h"
%ignore GP_Histogram::hist;
%include "GP_Stats.h"
-%include "GP_Rotate.h"
%include "GP_Linear.h"
%include "GP_Resize.h"
-/* %include "GP_Dither.h" -- missing symbols */
/* Functions returning new allocated context */
+%include "GP_Rotate.h"
+
%newobject GP_FilterMirrorHAlloc;
%newobject GP_FilterMirrorVAlloc;
%newobject GP_FilterRotate90Alloc;
%newobject GP_FilterRotate180Alloc;
%newobject GP_FilterRotate270Alloc;
%newobject GP_FilterSymmetryAlloc;
+
+
+/* Dithering */
+%include "GP_Dither.h"
+
+%newobject GP_FilterFloydSteinberg_RGB888_Alloc;
+%newobject GP_FilterHilbertPeano_RGB888_Alloc;
http://repo.or.cz/w/gfxprim.git/commit/e927ca0d6dbde34dc5ac7beda7a8665f8e4f…
commit e927ca0d6dbde34dc5ac7beda7a8665f8e4f1bdd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 26 19:03:26 2012 +0200
doc: Update dithering filter docs.
diff --git a/doc/filters.txt b/doc/filters.txt
index a2647b7..a751015 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -57,7 +57,7 @@ result and there are 'NO' sanity checks in place.
[source,c]
-------------------------------------------------------------------------------
/*
- * Raw filter common api.
+ * Raw filter common API.
*/
void GP_FilterFoo_Raw(const GP_Context *src, GP_Context *dst,
foo params ...,
@@ -268,22 +268,17 @@ finally downscale it to desired size.
Dithering
~~~~~~~~~
-[source,c]
--------------------------------------------------------------------------------
-#include <GP_Filters.h>
-
-GP_Context *GP_FilterFloydSteinberg_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_PixelType dst_pixel_type,
- GP_ProgressCallback *callback);
--------------------------------------------------------------------------------
+Currently there are two dithering algorithms implemented. Both takes an RGB888
+24bit image as input and are able to produce any RGB or Grayscale image.
+This filters doesn't work 'in-place' as the result has different pixel type.
-Floyd-Steinberg dithering the source context must be RGB888 and the
-dst_pixel_type may either be RGB or Grayscale.
+Floyd-Steinberg
+^^^^^^^^^^^^^^^
-Doesn't work 'in-place' as the result has different pixel type.
+Classical Floyd-Steinberg. Produces good results and is a little faster than
+the Hilbert-Peano dithering.
-The error is distributed to neighbour pixels as follows:
+The error is distributed to neighbor pixels as follows:
[width="10%"]
|===================
@@ -297,39 +292,118 @@ And is throwed away at the image borders.
-------------------------------------------------------------------------------
#include <GP_Filters.h>
-GP_Context *GP_FilterFloydSteinberg_to_G1(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterFloydSteinberg_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Same as above but the source is any pixel type and the result is stored into
-1-bit Grayscale.
+Renders Floyd Steinberg dithering directly into passed context. The
+destination must be at least as large as source.
+
+If operation was aborted by a callback, non-zero is returned.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP_Filters.h>
+
+GP_Context *GP_FilterFloydSteinberg_RGB888_Alloc(const GP_Context *src,
+ GP_PixelType pixel_type,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Returns pointer to allocated context of given pixel_type.
+
+If malloc(2) has failed, or operation was aborted by a callback 'NULL' is
+returned.
+
+Hilbert-Peano
+^^^^^^^^^^^^^
+
+Hilbert-Peano space filling curve based dithering.
+
+The error value is distributed around the Hilbert curve.
+
+The result is a little more noisy, but doesn't create repeating patterns like
+Floyd-Steinberg which looks generally better to human eye. On the other hand
+edges tend to be less sharp.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP_Filters.h>
+
+int GP_FilterHilbertPeano_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Renders Hilbert Peano dithering directly into passed context. The
+destination must be at least as large as source.
+
+If operation was aborted by a callback, non-zero is returned.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP_Filters.h>
+
+GP_Context *GP_FilterHilbertPeano_RGB888_Alloc(const GP_Context *src,
+ GP_PixelType pixel_type,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Returns pointer to allocated context of given pixel_type.
+
+If malloc(2) has failed, or operation was aborted by a callback 'NULL' is
+returned.
Example Images
^^^^^^^^^^^^^^
All following images were generated using 'grinder'.
(Click for bigger size)
-.Original Image; 1-bit, 2-bit, 4-bit Grayscale; 1-bit, 2-bit, 3-bit RGB
+.Original Image; Floyd-Steinberg, Hilbert-Peano: 1-bit, 2-bit, 4-bit, 8-bit Grayscale; 1-bit, 2-bit, 3-bit (per channel) RGB
image:images/dither/lenna_small.png[
"Original Image",
link="images/dither/lenna.png"]
-image:images/dither/lenna_G1_small.png[
- "1-bit Grayscale",
- link="images/dither/lenna_G1.png"]
-image:images/dither/lenna_G2_small.png[
- "2-bit Grayscale",
- link="images/dither/lenna_G2.png"]
-image:images/dither/lenna_G4_small.png[
- "4-bit Grayscale",
- link="images/dither/lenna_G4.png"]
-image:images/dither/lenna_RGB111_small.png[
- "1-bit RGB",
- link="images/dither/lenna_RGB111.png"]
-image:images/dither/lenna_RGB222_small.png[
- "2-bit RGB",
- link="images/dither/lenna_RGB222.png"]
-image:images/dither/lenna_RGB333_small.png[
- "3-bit RGB",
- link="images/dither/lenna_RGB333.png"]
+image:images/dither/lenna_G1_FS_small.png[
+ "1-bit Grayscale Floyd-Steinberg",
+ link="images/dither/lenna_G1_FS.png"]
+image:images/dither/lenna_G1_HP_small.png[
+ "1-bit Grayscale Hilbert-Peano",
+ link="images/dither/lenna_G1_HP.png"]
+image:images/dither/lenna_G2_FS_small.png[
+ "2-bit Grayscale Floyd-Steinberg",
+ link="images/dither/lenna_G2_FS.png"]
+image:images/dither/lenna_G2_HP_small.png[
+ "2-bit Grayscale Hilbert-Peano",
+ link="images/dither/lenna_G2_HP.png"]
+image:images/dither/lenna_G4_FS_small.png[
+ "4-bit Grayscale Floyd-Steinberg",
+ link="images/dither/lenna_G4_FS.png"]
+image:images/dither/lenna_G4_HP_small.png[
+ "4-bit Grayscale Hilbert-Peano",
+ link="images/dither/lenna_G4_HP.png"]
+image:images/dither/lenna_G8_FS_small.png[
+ "8-bit Grayscale Floyd-Steinberg",
+ link="images/dither/lenna_G8_FS.png"]
+image:images/dither/lenna_G8_HP_small.png[
+ "7-bit Grayscale Hilbert-Peano",
+ link="images/dither/lenna_G8_HP.png"]
+image:images/dither/lenna_RGB111_FS_small.png[
+ "1-bit RGB Floyd-Steinberg",
+ link="images/dither/lenna_RGB111_FS.png"]
+image:images/dither/lenna_RGB111_HP_small.png[
+ "1-bit RGB Hilbert-Peano",
+ link="images/dither/lenna_RGB111_HP.png"]
+image:images/dither/lenna_RGB222_FS_small.png[
+ "2-bit RGB Floyd-Steinberg",
+ link="images/dither/lenna_RGB222_FS.png"]
+image:images/dither/lenna_RGB222_HP_small.png[
+ "2-bit RGB Hilbert-Peano",
+ link="images/dither/lenna_RGB222_HP.png"]
+image:images/dither/lenna_RGB333_FS_small.png[
+ "3-bit RGB Floyd-Steinberg",
+ link="images/dither/lenna_RGB333_FS.png"]
+image:images/dither/lenna_RGB333_HP_small.png[
+ "3-bit RGB Hilbert-Peano",
+ link="images/dither/lenna_RGB333_HP.png"]
diff --git a/doc/images/dither/lenna_G1.png b/doc/images/dither/lenna_G1_FS.png
similarity index 100%
rename from doc/images/dither/lenna_G1.png
rename to doc/images/dither/lenna_G1_FS.png
diff --git a/doc/images/dither/lenna_G1_small.png b/doc/images/dither/lenna_G1_FS_small.png
similarity index 100%
rename from doc/images/dither/lenna_G1_small.png
rename to doc/images/dither/lenna_G1_FS_small.png
diff --git a/doc/images/dither/lenna_G1_HP.png b/doc/images/dither/lenna_G1_HP.png
new file mode 100644
index 0000000..f4db5f5
Binary files /dev/null and b/doc/images/dither/lenna_G1_HP.png differ
diff --git a/doc/images/dither/lenna_G1_HP_small.png b/doc/images/dither/lenna_G1_HP_small.png
new file mode 100644
index 0000000..328f1c0
Binary files /dev/null and b/doc/images/dither/lenna_G1_HP_small.png differ
diff --git a/doc/images/dither/lenna_G2.png b/doc/images/dither/lenna_G2_FS.png
similarity index 100%
rename from doc/images/dither/lenna_G2.png
rename to doc/images/dither/lenna_G2_FS.png
diff --git a/doc/images/dither/lenna_G2_small.png b/doc/images/dither/lenna_G2_FS_small.png
similarity index 100%
rename from doc/images/dither/lenna_G2_small.png
rename to doc/images/dither/lenna_G2_FS_small.png
diff --git a/doc/images/dither/lenna_G2_HP.png b/doc/images/dither/lenna_G2_HP.png
new file mode 100644
index 0000000..2c15fc0
Binary files /dev/null and b/doc/images/dither/lenna_G2_HP.png differ
diff --git a/doc/images/dither/lenna_G2_HP_small.png b/doc/images/dither/lenna_G2_HP_small.png
new file mode 100644
index 0000000..292cab6
Binary files /dev/null and b/doc/images/dither/lenna_G2_HP_small.png differ
diff --git a/doc/images/dither/lenna_G4.png b/doc/images/dither/lenna_G4_FS.png
similarity index 100%
rename from doc/images/dither/lenna_G4.png
rename to doc/images/dither/lenna_G4_FS.png
diff --git a/doc/images/dither/lenna_G4_small.png b/doc/images/dither/lenna_G4_FS_small.png
similarity index 100%
rename from doc/images/dither/lenna_G4_small.png
rename to doc/images/dither/lenna_G4_FS_small.png
diff --git a/doc/images/dither/lenna_G4_HP.png b/doc/images/dither/lenna_G4_HP.png
new file mode 100644
index 0000000..ae696a3
Binary files /dev/null and b/doc/images/dither/lenna_G4_HP.png differ
diff --git a/doc/images/dither/lenna_G4_HP_small.png b/doc/images/dither/lenna_G4_HP_small.png
new file mode 100644
index 0000000..9ff7370
Binary files /dev/null and b/doc/images/dither/lenna_G4_HP_small.png differ
diff --git a/doc/images/dither/lenna_G8_FS.png b/doc/images/dither/lenna_G8_FS.png
new file mode 100644
index 0000000..976e32a
Binary files /dev/null and b/doc/images/dither/lenna_G8_FS.png differ
diff --git a/doc/images/dither/lenna_G8_FS_small.png b/doc/images/dither/lenna_G8_FS_small.png
new file mode 100644
index 0000000..f0f6fdf
Binary files /dev/null and b/doc/images/dither/lenna_G8_FS_small.png differ
diff --git a/doc/images/dither/lenna_G8_HP.png b/doc/images/dither/lenna_G8_HP.png
new file mode 100644
index 0000000..976e32a
Binary files /dev/null and b/doc/images/dither/lenna_G8_HP.png differ
diff --git a/doc/images/dither/lenna_G8_HP_small.png b/doc/images/dither/lenna_G8_HP_small.png
new file mode 100644
index 0000000..f0f6fdf
Binary files /dev/null and b/doc/images/dither/lenna_G8_HP_small.png differ
diff --git a/doc/images/dither/lenna_RGB111.png b/doc/images/dither/lenna_RGB111_FS.png
similarity index 100%
rename from doc/images/dither/lenna_RGB111.png
rename to doc/images/dither/lenna_RGB111_FS.png
diff --git a/doc/images/dither/lenna_RGB111_small.png b/doc/images/dither/lenna_RGB111_FS_small.png
similarity index 100%
rename from doc/images/dither/lenna_RGB111_small.png
rename to doc/images/dither/lenna_RGB111_FS_small.png
diff --git a/doc/images/dither/lenna_RGB111_HP.png b/doc/images/dither/lenna_RGB111_HP.png
new file mode 100644
index 0000000..33a471f
Binary files /dev/null and b/doc/images/dither/lenna_RGB111_HP.png differ
diff --git a/doc/images/dither/lenna_RGB111_HP_small.png b/doc/images/dither/lenna_RGB111_HP_small.png
new file mode 100644
index 0000000..444a1bf
Binary files /dev/null and b/doc/images/dither/lenna_RGB111_HP_small.png differ
diff --git a/doc/images/dither/lenna_RGB222.png b/doc/images/dither/lenna_RGB222_FS.png
similarity index 100%
rename from doc/images/dither/lenna_RGB222.png
rename to doc/images/dither/lenna_RGB222_FS.png
diff --git a/doc/images/dither/lenna_RGB222_small.png b/doc/images/dither/lenna_RGB222_FS_small.png
similarity index 100%
rename from doc/images/dither/lenna_RGB222_small.png
rename to doc/images/dither/lenna_RGB222_FS_small.png
diff --git a/doc/images/dither/lenna_RGB222_HP.png b/doc/images/dither/lenna_RGB222_HP.png
new file mode 100644
index 0000000..fd22e14
Binary files /dev/null and b/doc/images/dither/lenna_RGB222_HP.png differ
diff --git a/doc/images/dither/lenna_RGB222_HP_small.png b/doc/images/dither/lenna_RGB222_HP_small.png
new file mode 100644
index 0000000..e1296aa
Binary files /dev/null and b/doc/images/dither/lenna_RGB222_HP_small.png differ
diff --git a/doc/images/dither/lenna_RGB333.png b/doc/images/dither/lenna_RGB333_FS.png
similarity index 100%
rename from doc/images/dither/lenna_RGB333.png
rename to doc/images/dither/lenna_RGB333_FS.png
diff --git a/doc/images/dither/lenna_RGB333_small.png b/doc/images/dither/lenna_RGB333_FS_small.png
similarity index 100%
rename from doc/images/dither/lenna_RGB333_small.png
rename to doc/images/dither/lenna_RGB333_FS_small.png
diff --git a/doc/images/dither/lenna_RGB333_HP.png b/doc/images/dither/lenna_RGB333_HP.png
new file mode 100644
index 0000000..a155107
Binary files /dev/null and b/doc/images/dither/lenna_RGB333_HP.png differ
diff --git a/doc/images/dither/lenna_RGB333_HP_small.png b/doc/images/dither/lenna_RGB333_HP_small.png
new file mode 100644
index 0000000..0fecb6b
Binary files /dev/null and b/doc/images/dither/lenna_RGB333_HP_small.png differ
http://repo.or.cz/w/gfxprim.git/commit/1b8274d61463a47398e4100fc554ed8fa9b0…
commit 1b8274d61463a47398e4100fc554ed8fa9b0366b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 26 13:49:43 2012 +0200
filters: Cleanup dithering filters API.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c
index 7229781..fe51530 100644
--- a/demos/grinder/grinder.c
+++ b/demos/grinder/grinder.c
@@ -445,9 +445,8 @@ static GP_RetCode dither(GP_Context **c, const char *params)
}
GP_Context *bw;
- bw = GP_FilterFloydSteinberg_from_RGB888(*c, NULL,
- dither_pixel_types[fmt],
- progress_callback);
+ bw = GP_FilterFloydSteinberg_RGB888_Alloc(*c, dither_pixel_types[fmt],
+ progress_callback);
//TODO: so far we convert the context back to RGB888
//(so we can do further work with it)
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 7095eef..c6b086e 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -285,8 +285,8 @@ static void *image_loader(void *ptr)
if (dithering) {
callback.priv = "Dithering";
GP_ContextSubContext(context, &sub_display, cx, cy, ret->w, ret->h);
- // GP_FilterFloydSteinberg_from_RGB888(ret, &sub_display, 0, NULL);
- GP_FilterHilbertPeano_from_RGB888(ret, &sub_display, NULL);
+ // GP_FilterFloydSteinberg_RGB888(ret, &sub_display, NULL);
+ GP_FilterHilbertPeano_RGB888(ret, &sub_display, NULL);
} else {
GP_Blit_Raw(ret, 0, 0, ret->w, ret->h, context, cx, cy);
}
diff --git a/include/filters/GP_Dither.h b/include/filters/GP_Dither.h
index 07a8da2..55a950c 100644
--- a/include/filters/GP_Dither.h
+++ b/include/filters/GP_Dither.h
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -32,41 +32,87 @@
#include "GP_Filter.h"
/*
- * Floyd Steinberg
+ * Classical Floyd-Steinberg. Produces good results and is a little faster than
+ * the Hilbert-Peano dithering.
+ *
+ * The error is distributed to the neighbor pixels as follows:
+ * (X denotes current position)
+ *
+ *
+ * | |
+ * | X | 7/16
+ * | |
+ * -----------------------
+ * | |
+ * 3/16 | 5/16 | 1/16
+ * | |
+ *
*/
-GP_Context *GP_FilterFloydSteinberg_to_G1(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
/*
- * Floyd Steinberg
+ * Semi internal raw version, use at your own risk.
*/
-GP_Context *GP_FilterFloydSteinberg_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_PixelType dst_pixel_type,
- GP_ProgressCallback *callback);
+int GP_FilterFloydSteinberg_RGB888_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
/*
- * Converts RGB888 to RGB or Grayscale bitmap.
+ * Converts RGB888 24bit image to any RGB or Grayscale bitmap.
+ *
+ * The source pixel_type MUST BE GP_PIXEL_RGB888.
+ *
+ * The destination must be at least as large as source.
+ *
+ * If operation was aborted from within a callback, non-zero is returned.
*/
-int GP_FilterFloydSteinberg_RGB888_to_XXX_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterFloydSteinberg_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
/*
- * Converts any bitmap to 1-bit Grayscale.
+ * If malloc() has failed, or operation was aborted by a callback, NULL is
+ * returned.
*/
-int GP_FilterFloydSteinberg_XXX_to_G1_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+GP_Context *GP_FilterFloydSteinberg_RGB888_Alloc(const GP_Context *src,
+ GP_PixelType pixel_type,
+ GP_ProgressCallback *callback);
+/*
+ * Hilbert-Peano space filling curve based dithering.
+ *
+ * The error value is distributed around the Hilbert curve.
+ *
+ * This dithering introduces a little more noisy result but doesn't create
+ * repeating patterns like Floyd-Steinberg which looks generally better to
+ * human eye. On the other hand edges tend to be less sharp.
+ */
/*
- * Hilbert-peano space filling curve based dithering.
+ * Semi internal raw version, use at your own risk.
*/
-int GP_FilterHilbertPeano_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterHilbertPeano_RGB888_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+/*
+ * Converts RGB888 24bit image to any RGB or Grayscale bitmap.
+ *
+ * The source pixel_type MUST BE GP_PIXEL_RGB888.
+ *
+ * The destination must be at least as large as source.
+ *
+ * If the operation was aborted from within a callback, non-zero is returned.
+ */
+int GP_FilterHilbertPeano_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+/*
+ * If malloc() has failed, or operation was aborted by a callback, NULL is
+ * returned.
+ */
+GP_Context *GP_FilterHilbertPeano_RGB888_Alloc(const GP_Context *src,
+ GP_PixelType pixel_type,
+ GP_ProgressCallback *callback);
#endif /* FILTERS_GP_DITHER_H */
diff --git a/libs/filters/GP_Dither.c b/libs/filters/GP_Dither.c
index d258ef4..ad87e9b 100644
--- a/libs/filters/GP_Dither.c
+++ b/libs/filters/GP_Dither.c
@@ -16,131 +16,70 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-#include "core/GP_Core.h"
-#include "core/GP_FnPerBpp.h"
-#include "core/GP_Pixel.h"
-
#include "GP_Dither.h"
-#include <string.h>
-
-/*
- * Experimental Floyd Steinberg XXX -> G1
- */
-int GP_FilterFloydSteinberg_to_G1_Raw(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
+int GP_FilterFloydSteinberg_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
{
- float errors[2][src->w];
-
- GP_DEBUG(1, "Floyd Steinberg %s to %s size %ux%u",
- GP_PixelTypeName(src->pixel_type),
- GP_PixelTypeName(GP_PIXEL_G1), src->w, src->h);
-
- GP_Coord x, y;
-
- memset(errors[0], 0, src->w * sizeof(float));
- memset(errors[1], 0, src->w * sizeof(float));
-
- for (y = 0; y < (GP_Coord)src->h; y++) {
- for (x = 0; x < (GP_Coord)src->w; x++) {
- GP_Pixel pix = GP_GetPixel(src, x, y);
- float val = GP_ConvertPixel(pix, src->pixel_type,
- GP_PIXEL_G8);
-
- val += errors[y%2][x];
-
- float err;
-
- if (val > 127) {
- err = val - 255;
- GP_PutPixel_Raw_1BPP_LE(dst, x, y, 1);
- } else {
- err = val - 0;
- GP_PutPixel_Raw_1BPP_LE(dst, x, y, 0);
- }
+ GP_CHECK(src->pixel_type == GP_PIXEL_RGB888);
+ GP_CHECK(src->w <= dst->w);
+ GP_CHECK(src->h <= dst->h);
- if (x + 1 < (GP_Coord)src->w)
- errors[y%2][x+1] += 7 * err / 16;
-
- if (x > 1)
- errors[!(y%2)][x-1] += 3 * err / 16;
-
- errors[!(y%2)][x] += 5 * err / 16;
-
- if (x + 1 < (GP_Coord)src->w)
- errors[!(y%2)][x+1] += err / 16;
- }
-
- memset(errors[y%2], 0, src->w * sizeof(float));
-
- if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
- return 1;
- }
-
- GP_ProgressCallbackDone(callback);
- return 0;
+ return GP_FilterFloydSteinberg_RGB888_Raw(src, dst, callback);
}
-GP_Context *GP_FilterFloydSteinberg_to_G1(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- GP_Context *ret = dst;
- if (ret == NULL) {
- ret = GP_ContextAlloc(src->w, src->h, GP_PIXEL_G1);
+GP_Context *GP_FilterFloydSteinberg_RGB888_Alloc(const GP_Context *src,
+ GP_PixelType pixel_type,
+ GP_ProgressCallback *callback)
+{
+ GP_Context *ret;
- if (ret == NULL) {
- GP_DEBUG(1, "Malloc failed :(");
- return NULL;
- }
- }
+ ret = GP_ContextAlloc(src->w, src->h, pixel_type);
+
+ if (ret == NULL)
+ return NULL;
- if (GP_FilterFloydSteinberg_to_G1_Raw(src, ret, callback)) {
- if (dst == NULL)
- free(ret);
+ if (GP_FilterFloydSteinberg_RGB888_Raw(src, ret, callback)) {
+ GP_ContextFree(ret);
return NULL;
}
return ret;
}
-GP_Context *GP_FilterFloydSteinberg_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_PixelType pixel_type,
- GP_ProgressCallback *callback)
+
+int GP_FilterHilbertPeano_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
{
- GP_Context *ret = dst;
+ GP_CHECK(src->pixel_type == GP_PIXEL_RGB888);
+ GP_CHECK(src->w <= dst->w);
+ GP_CHECK(src->h <= dst->h);
- if (ret == NULL) {
- ret = GP_ContextAlloc(src->w, src->h, pixel_type);
-
- if (ret == NULL) {
- GP_DEBUG(1, "Malloc failed :(");
- return NULL;
- }
- }
+ return GP_FilterHilbertPeano_RGB888_Raw(src, dst, callback);
+}
+
+GP_Context *GP_FilterHilbertPeano_RGB888_Alloc(const GP_Context *src,
+ GP_PixelType pixel_type,
+ GP_ProgressCallback *callback)
+{
+ GP_Context *ret;
- if (GP_FilterFloydSteinberg_RGB888_to_XXX_Raw(src, ret, callback)) {
- if (dst == NULL)
- free(ret);
+ ret = GP_ContextAlloc(src->w, src->h, pixel_type);
+
+ if (ret == NULL)
+ return NULL;
+
+ if (GP_FilterHilbertPeano_RGB888_Raw(src, ret, callback)) {
+ GP_ContextFree(ret);
return NULL;
}
return ret;
}
-
-int GP_FilterHilbertPeano_RGB888_to_XXX_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
-
-int GP_FilterHilbertPeano_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- return GP_FilterHilbertPeano_RGB888_to_XXX_Raw(src, dst, callback);
-}
diff --git a/libs/filters/GP_Dither.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t
similarity index 97%
rename from libs/filters/GP_Dither.gen.c.t
rename to libs/filters/GP_FloydSteinberg.gen.c.t
index c1ec2bf..9886945 100644
--- a/libs/filters/GP_Dither.gen.c.t
+++ b/libs/filters/GP_FloydSteinberg.gen.c.t
@@ -1,4 +1,3 @@
-
%% extends "base.c.t"
{% block descr %}Floyd Steinberg dithering RGB888 -> any pixel{% endblock %}
@@ -99,7 +98,7 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G
%% endif
%% endfor
-int GP_FilterFloydSteinberg_RGB888_to_XXX_Raw(const GP_Context *src,
+int GP_FilterFloydSteinberg_RGB888_Raw(const GP_Context *src,
GP_Context *dst,
GP_ProgressCallback *callback)
{
diff --git a/libs/filters/GP_HilbertPeanoDithering.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t
similarity index 93%
rename from libs/filters/GP_HilbertPeanoDithering.gen.c.t
rename to libs/filters/GP_HilbertPeano.gen.c.t
index 78a9b53..2157580 100644
--- a/libs/filters/GP_HilbertPeanoDithering.gen.c.t
+++ b/libs/filters/GP_HilbertPeano.gen.c.t
@@ -109,9 +109,9 @@ int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src,
%% endif
%% endfor
-int GP_FilterHilbertPeano_RGB888_to_XXX_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback)
+int GP_FilterHilbertPeano_RGB888_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
{
switch (dst->pixel_type) {
%% for pt in pixeltypes
diff --git a/libs/filters/Makefile b/libs/filters/Makefile
index 7a9a670..4bed64a 100644
--- a/libs/filters/Makefile
+++ b/libs/filters/Makefile
@@ -8,7 +8,7 @@ POINT_FILTERS=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c GP_Max.gen.c GP_Multiply.gen.c
-GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_Dither.gen.c GP_HilbertPeanoDithering.gen.c+GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_FloydSteinberg.gen.c GP_HilbertPeano.gen.c $(POINT_FILTERS) $(ARITHMETIC_FILTERS) $(STATS_FILTERS)
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
http://repo.or.cz/w/gfxprim.git/commit/648c8a5e14dc4159ed1cb65199b9ec7fb471…
commit 648c8a5e14dc4159ed1cb65199b9ec7fb47116c6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 25 23:20:24 2012 +0200
backends: Simplify the backend fd interface.
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h
index 63020db..b28917e 100644
--- a/include/backends/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -46,15 +46,6 @@
struct GP_Backend;
-/*
- * Linked list of file descriptors with callbacks.
- */
-typedef struct GP_BackendFD {
- int fd;
- void (*Callback)(struct GP_BackendFD *self, struct GP_Backend *backend);
- struct GP_BackendFD *next;
-} GP_BackendFD;
-
typedef struct GP_Backend {
/*
* Backend name.
@@ -109,11 +100,9 @@ typedef struct GP_Backend {
void (*Exit)(struct GP_Backend *self);
/*
- * Linked List of file descriptors with callbacks to poll.
- *
- * May be NULL.
+ * Connection fd. Set to -1 if not available
*/
- GP_BackendFD *fd_list;
+ int fd;
/*
* Some of the backends doesn't expose file descriptor
diff --git a/libs/backends/GP_LinuxFB.c b/libs/backends/GP_LinuxFB.c
index d6de2de..a374cbe 100644
--- a/libs/backends/GP_LinuxFB.c
+++ b/libs/backends/GP_LinuxFB.c
@@ -311,8 +311,8 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag)
backend->UpdateRect = fb_update_rect_noop;
backend->Exit = fb_exit;
backend->SetAttributes = NULL;
- backend->fd_list = NULL;
backend->Poll = flag ? fb_poll : NULL;
+ backend->fd = fb->con_fd;
return backend;
err3:
diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c
index 3923619..fcc0df7 100644
--- a/libs/backends/GP_SDL.c
+++ b/libs/backends/GP_SDL.c
@@ -142,7 +142,7 @@ static struct GP_Backend backend = {
.UpdateRect = sdl_update_rect,
.SetAttributes = sdl_set_attributes,
.Exit = sdl_exit,
- .fd_list = NULL,
+ .fd = -1,
.Poll = sdl_poll,
};
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index a1d9733..3db2724 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -359,9 +359,9 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
backend->Flip = x11_flip;
backend->UpdateRect = x11_update_rect;
backend->Exit = x11_exit;
- backend->fd_list = NULL;
backend->Poll = x11_poll;
backend->SetAttributes = x11_set_attributes;
+ backend->fd = XConnectionNumber(x11->dpy);
return backend;
err1:
-----------------------------------------------------------------------
Summary of changes:
demos/grinder/grinder.c | 5 +-
demos/spiv/spiv.c | 4 +-
doc/filters.txt | 150 +++++++++++++++-----
.../dither/{lenna_G1.png => lenna_G1_FS.png} | Bin 44134 -> 44134 bytes
.../{lenna_G1_small.png => lenna_G1_FS_small.png} | Bin 11690 -> 11690 bytes
doc/images/dither/lenna_G1_HP.png | Bin 0 -> 54940 bytes
doc/images/dither/lenna_G1_HP_small.png | Bin 0 -> 14357 bytes
.../dither/{lenna_G2.png => lenna_G2_FS.png} | Bin 69665 -> 69665 bytes
.../{lenna_G2_small.png => lenna_G2_FS_small.png} | Bin 18380 -> 18380 bytes
doc/images/dither/lenna_G2_HP.png | Bin 0 -> 74316 bytes
doc/images/dither/lenna_G2_HP_small.png | Bin 0 -> 20234 bytes
.../dither/{lenna_G4.png => lenna_G4_FS.png} | Bin 92560 -> 92560 bytes
.../{lenna_G4_small.png => lenna_G4_FS_small.png} | Bin 26452 -> 26452 bytes
doc/images/dither/lenna_G4_HP.png | Bin 0 -> 116264 bytes
doc/images/dither/lenna_G4_HP_small.png | Bin 0 -> 31754 bytes
doc/images/dither/lenna_G8_FS.png | Bin 0 -> 221478 bytes
doc/images/dither/lenna_G8_FS_small.png | Bin 0 -> 67801 bytes
doc/images/dither/lenna_G8_HP.png | Bin 0 -> 221478 bytes
doc/images/dither/lenna_G8_HP_small.png | Bin 0 -> 67801 bytes
.../{lenna_RGB111.png => lenna_RGB111_FS.png} | Bin 109889 -> 109889 bytes
..._RGB111_small.png => lenna_RGB111_FS_small.png} | Bin 27757 -> 27757 bytes
doc/images/dither/lenna_RGB111_HP.png | Bin 0 -> 124334 bytes
doc/images/dither/lenna_RGB111_HP_small.png | Bin 0 -> 31358 bytes
.../{lenna_RGB222.png => lenna_RGB222_FS.png} | Bin 162688 -> 162688 bytes
..._RGB222_small.png => lenna_RGB222_FS_small.png} | Bin 41646 -> 41646 bytes
doc/images/dither/lenna_RGB222_HP.png | Bin 0 -> 167382 bytes
doc/images/dither/lenna_RGB222_HP_small.png | Bin 0 -> 43323 bytes
.../{lenna_RGB333.png => lenna_RGB333_FS.png} | Bin 196644 -> 196644 bytes
..._RGB333_small.png => lenna_RGB333_FS_small.png} | Bin 52995 -> 52995 bytes
doc/images/dither/lenna_RGB333_HP.png | Bin 0 -> 227055 bytes
doc/images/dither/lenna_RGB333_HP_small.png | Bin 0 -> 63795 bytes
include/backends/GP_Backend.h | 15 +--
include/filters/GP_Dither.h | 90 +++++++++---
libs/backends/GP_LinuxFB.c | 2 +-
libs/backends/GP_SDL.c | 2 +-
libs/backends/GP_X11.c | 2 +-
libs/filters/GP_Dither.c | 143 ++++++-------------
...GP_Dither.gen.c.t => GP_FloydSteinberg.gen.c.t} | 3 +-
...noDithering.gen.c.t => GP_HilbertPeano.gen.c.t} | 6 +-
libs/filters/Makefile | 2 +-
pylib/gfxprim/filters/filters.i | 11 ++-
41 files changed, 244 insertions(+), 191 deletions(-)
rename doc/images/dither/{lenna_G1.png => lenna_G1_FS.png} (100%)
rename doc/images/dither/{lenna_G1_small.png => lenna_G1_FS_small.png} (100%)
create mode 100644 doc/images/dither/lenna_G1_HP.png
create mode 100644 doc/images/dither/lenna_G1_HP_small.png
rename doc/images/dither/{lenna_G2.png => lenna_G2_FS.png} (100%)
rename doc/images/dither/{lenna_G2_small.png => lenna_G2_FS_small.png} (100%)
create mode 100644 doc/images/dither/lenna_G2_HP.png
create mode 100644 doc/images/dither/lenna_G2_HP_small.png
rename doc/images/dither/{lenna_G4.png => lenna_G4_FS.png} (100%)
rename doc/images/dither/{lenna_G4_small.png => lenna_G4_FS_small.png} (100%)
create mode 100644 doc/images/dither/lenna_G4_HP.png
create mode 100644 doc/images/dither/lenna_G4_HP_small.png
create mode 100644 doc/images/dither/lenna_G8_FS.png
create mode 100644 doc/images/dither/lenna_G8_FS_small.png
create mode 100644 doc/images/dither/lenna_G8_HP.png
create mode 100644 doc/images/dither/lenna_G8_HP_small.png
rename doc/images/dither/{lenna_RGB111.png => lenna_RGB111_FS.png} (100%)
rename doc/images/dither/{lenna_RGB111_small.png => lenna_RGB111_FS_small.png} (100%)
create mode 100644 doc/images/dither/lenna_RGB111_HP.png
create mode 100644 doc/images/dither/lenna_RGB111_HP_small.png
rename doc/images/dither/{lenna_RGB222.png => lenna_RGB222_FS.png} (100%)
rename doc/images/dither/{lenna_RGB222_small.png => lenna_RGB222_FS_small.png} (100%)
create mode 100644 doc/images/dither/lenna_RGB222_HP.png
create mode 100644 doc/images/dither/lenna_RGB222_HP_small.png
rename doc/images/dither/{lenna_RGB333.png => lenna_RGB333_FS.png} (100%)
rename doc/images/dither/{lenna_RGB333_small.png => lenna_RGB333_FS_small.png} (100%)
create mode 100644 doc/images/dither/lenna_RGB333_HP.png
create mode 100644 doc/images/dither/lenna_RGB333_HP_small.png
rename libs/filters/{GP_Dither.gen.c.t => GP_FloydSteinberg.gen.c.t} (97%)
rename libs/filters/{GP_HilbertPeanoDithering.gen.c.t => GP_HilbertPeano.gen.c.t} (93%)
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
[repo.or.cz] gfxprim.git branch master updated: f48d899fd136b662a6a5bd7820089dff4c309c72
by metan 25 May '12
by metan 25 May '12
25 May '12
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 f48d899fd136b662a6a5bd7820089dff4c309c72 (commit)
via b76587f53f5976a66cc44cdbb5e7ee2dae0807b0 (commit)
via 61e0747c9dfcf12d7eb3a3315a559d63dcd176e7 (commit)
via 943bd6a63a5c34460b95441da36313d35d0a877b (commit)
via 5b6b8f9395af8ef7d017642a6e6ca37eaf5abf54 (commit)
via 0211dcc91eef550bdb079f6a2f3410bf3bda985a (commit)
from a2551d947cc9e247126f7f6576c9b74b726484cc (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/f48d899fd136b662a6a5bd7820089dff4c30…
commit f48d899fd136b662a6a5bd7820089dff4c309c72
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 25 20:28:57 2012 +0200
X11: Add option to run X11 backend in root window.
diff --git a/include/backends/GP_X11.h b/include/backends/GP_X11.h
index 16be681..e03baf4 100644
--- a/include/backends/GP_X11.h
+++ b/include/backends/GP_X11.h
@@ -25,6 +25,14 @@
#include "GP_Backend.h"
+enum GP_BackendX11Flags {
+ /*
+ * When set, w and h is ignored and root window is used
+ */
+ GP_X11_USE_ROOT_WIN = 0x01,
+};
+
+
/*
* Initalize X11 backend.
*
@@ -37,6 +45,7 @@
*/
GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
unsigned int w, unsigned int h,
- const char *caption);
+ const char *caption,
+ enum GP_BackendX11Flags flags);
#endif /* BACKENDS_GP_X11_H */
diff --git a/libs/backends/GP_BackendInit.c b/libs/backends/GP_BackendInit.c
index b00fd10..316b137 100644
--- a/libs/backends/GP_BackendInit.c
+++ b/libs/backends/GP_BackendInit.c
@@ -133,24 +133,66 @@ static void backend_x11_help(FILE *help, const char *err)
fprintf(help, "ERROR: %sn", err);
fprintf(help, "X11 backendn"
- "-----------n"
- "X11:WxHn");
+ "--------------n"
+ "X11:WxH:[ROOT_WIN]nn"
+ "ROOT_WIN - starts the backend in the root windown"
+ " (w and h, if set, are ignored)n");
+}
+
+static int x11_params_to_flags(const char *param, GP_Size *w, GP_Size *h,
+ enum GP_BackendX11Flags *flags, FILE *help)
+{
+ if (!strcasecmp(param, "ROOT_WIN")) {
+ *flags |= GP_X11_USE_ROOT_WIN;
+ return 0;
+ }
+
+ /*
+ * Accepts only string with format "intxint" or "intXint"
+ */
+ int sw, sh;
+ unsigned int n;
+
+ if (sscanf(param, "%i%*[xX]%i%n", &sw, &sh, &n) == 2 && n == strlen(param)) {
+ *w = sw;
+ *h = sh;
+ return 0;
+ }
+
+ backend_sdl_help(help, "X11: Invalid parameters");
+ return 1;
}
+
static GP_Backend *backend_x11_init(char *params, const char *caption,
FILE *help)
{
- unsigned int n, w = 640, h = 480;
-
+ GP_Size w = 640, h = 480;
+ enum GP_BackendX11Flags flags = 0;
+
if (params == NULL)
- return GP_BackendX11Init(NULL, 0, 0, w, h, caption);
+ return GP_BackendX11Init(NULL, 0, 0, w, h, caption, 0);
- if (sscanf(params, "%u%*[xX]%u%n", &w, &h, &n) == 2 &&
- n == strlen(params))
- return GP_BackendX11Init(NULL, 0, 0, w, h, caption);
+ char *s = params;
- backend_x11_help(help, "X11: Invalid parameters");
- return NULL;
+ for (;;) {
+ switch (*s) {
+ case ':':
+ (*s) = '0';
+ if (x11_params_to_flags(params, &w, &h, &flags, help))
+ return NULL;
+ s++;
+ params = s;
+ break;
+ case '0':
+ if (x11_params_to_flags(params, &w, &h, &flags, help))
+ return NULL;
+
+ return GP_BackendX11Init(NULL, 0, 0, w, h, caption, flags);
+ break;
+ }
+ s++;
+ }
}
static const char *backend_names[] = {
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index 657087f..a1d9733 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -254,9 +254,60 @@ static int resize_ximage(GP_Backend *self, int w, int h)
return 0;
}
+void create_window(struct x11_priv *x11, int x, int y,
+ unsigned int *w, unsigned int *h,
+ const char *caption, enum GP_BackendX11Flags flags)
+{
+ XSetWindowAttributes attrs;
+ unsigned long attr_mask = 0;
+
+ /* Set event mask */
+ attrs.event_mask = ExposureMask | StructureNotifyMask |KeyPressMask |
+ KeyReleaseMask | PointerMotionMask;
+ attr_mask |= CWEventMask;
+
+ /*
+ * If root window was selected, resize w and h and set x11->win to root
+ * window.
+ */
+ if (flags & GP_X11_USE_ROOT_WIN) {
+ x11->win = DefaultRootWindow(x11->dpy);
+ *w = DisplayWidth(x11->dpy, x11->scr);
+ *h = DisplayHeight(x11->dpy, x11->scr);
+
+ GP_DEBUG(2, "Using root window, owerriding size to %ux%u",
+ *w, *h);
+
+ XChangeWindowAttributes(x11->dpy, x11->win, attr_mask, &attrs);
+
+ return;
+ }
+
+ GP_DEBUG(2, "Opening window '%s' %ix%i-%ux%u",
+ caption, x, y, *w, *h);
+
+ /*
+ * For some reason reading mouse button clicks on root win are not
+ * allowed...
+ */
+ attrs.event_mask |= ButtonPressMask | ButtonReleaseMask ;
+
+ x11->win = XCreateWindow(x11->dpy, DefaultRootWindow(x11->dpy),
+ x, y, *w, *h, 0, CopyFromParent,
+ InputOutput, CopyFromParent, attr_mask, &attrs);
+
+ /* Set window caption */
+ XmbSetWMProperties(x11->dpy, x11->win, caption, caption,
+ NULL, 0, NULL, NULL, NULL);
+
+ /* Show window */
+ XMapWindow(x11->dpy, x11->win);
+}
+
GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
unsigned int w, unsigned int h,
- const char *caption)
+ const char *caption,
+ enum GP_BackendX11Flags flags)
{
GP_Backend *backend;
struct x11_priv *x11;
@@ -288,39 +339,22 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
GP_DEBUG(2, "Have Visual id %i, depth %u", (int)x11->vis->visualid, x11->scr_depth);
- if (create_ximage(backend, w, h))
- goto err1;
-
- GP_DEBUG(2, "Opening window '%s' %ix%i-%ux%u",
- caption, x, y, w, h);
-
- x11->win = XCreateWindow(x11->dpy, DefaultRootWindow(x11->dpy),
- x, y, w, h, 0, CopyFromParent,
- InputOutput, CopyFromParent, 0, NULL);
-
+ create_window(x11, x, y, &w, &h, caption, flags);
+
if (x11->win == None) {
//TODO: Error message?
GP_DEBUG(1, "Failed to create window");
- goto err2;
+ goto err1;
}
- /* Select events */
- XSelectInput(x11->dpy, x11->win, ExposureMask | StructureNotifyMask |
- KeyPressMask | KeyReleaseMask |
- ButtonPressMask | ButtonReleaseMask |
- PointerMotionMask);
+ if (create_ximage(backend, w, h))
+ goto err1;
+
- /* Set window caption */
- XmbSetWMProperties(x11->dpy, x11->win, caption, caption,
- NULL, 0, NULL, NULL, NULL);
-
- /* Show window */
- XMapWindow(x11->dpy, x11->win);
XFlush(x11->dpy);
x11->resized_flag = 0;
-
backend->name = "X11";
backend->Flip = x11_flip;
backend->UpdateRect = x11_update_rect;
@@ -330,8 +364,6 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
backend->SetAttributes = x11_set_attributes;
return backend;
-err2:
- destroy_ximage(backend);
err1:
XCloseDisplay(x11->dpy);
err0:
http://repo.or.cz/w/gfxprim.git/commit/b76587f53f5976a66cc44cdbb5e7ee2dae08…
commit b76587f53f5976a66cc44cdbb5e7ee2dae0807b0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 25 20:20:49 2012 +0200
demos: Change particle demo default backend to X11.
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c
index 82c8e74..4143ffe 100644
--- a/demos/particle/particle_demo.c
+++ b/demos/particle/particle_demo.c
@@ -61,7 +61,7 @@ static void init_backend(const char *backend_opts)
int main(int argc, char *argv[])
{
- const char *backend_opts = "SDL";
+ const char *backend_opts = "X11";
int opt;
int pause_flag = 0;
@@ -75,7 +75,7 @@ int main(int argc, char *argv[])
}
}
- GP_SetDebugLevel(10);
+// GP_SetDebugLevel(10);
signal(SIGINT, sighandler);
signal(SIGSEGV, sighandler);
http://repo.or.cz/w/gfxprim.git/commit/61e0747c9dfcf12d7eb3a3315a559d63dcd1…
commit 61e0747c9dfcf12d7eb3a3315a559d63dcd176e7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 25 18:25:28 2012 +0200
X11: Remove temporarily XResizeWindow
To avoid to infinite resize loop.
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index aec3bce..657087f 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -159,7 +159,7 @@ static int x11_set_attributes(struct GP_Backend *self,
return 1;
/* Resize X11 window */
- XResizeWindow(x11->dpy, x11->win, w, h);
+ // XResizeWindow(x11->dpy, x11->win, w, h);
XFlush(x11->dpy);
x11->resized_flag = 1;
http://repo.or.cz/w/gfxprim.git/commit/943bd6a63a5c34460b95441da36313d35d0a…
commit 943bd6a63a5c34460b95441da36313d35d0a877b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 25 18:23:29 2012 +0200
build: Remove the useless -dPIC compilation switch.
diff --git a/lib.mk b/lib.mk
index c801e07..d9a6f0b 100644
--- a/lib.mk
+++ b/lib.mk
@@ -25,12 +25,12 @@ $(LIBP)$(LIB).so: $(OBJS)
ifdef VERBOSE
rm -f $(LIBP)$(LIB).so.0
cd $(LIBP) && ln -s $(LIB).so $(LIB).so.0
- $(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@
+ $(CC) -fPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@
else
@rm -f $(LIBP)$(LIB).so.0
@cd $(LIBP) && ln -s $(LIB).so $(LIB).so.0
@echo "LD $@"
- @$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@
+ @$(CC) -fPIC --shared -Wl,-soname -Wl,$(LIB).so.0 $(OBJECTS) -o $@
endif
$(LIBP)$(LIB).a: $(OBJS)
http://repo.or.cz/w/gfxprim.git/commit/5b6b8f9395af8ef7d017642a6e6ca37eaf5a…
commit 5b6b8f9395af8ef7d017642a6e6ca37eaf5abf54
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 25 18:20:56 2012 +0200
backends: Move the resize w, h check into general code.
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h
index 1f8428e..63020db 100644
--- a/include/backends/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -93,6 +93,8 @@ typedef struct GP_Backend {
*
* If w and h are zero, only caption is changed.
*
+ * If w is set and h is zero, only w is changed and vice versa.
+ *
* If caption is NULL only w and h are changed.
*
* Use the inline wrappers instead.
diff --git a/include/backends/GP_X11.h b/include/backends/GP_X11.h
index 198e252..16be681 100644
--- a/include/backends/GP_X11.h
+++ b/include/backends/GP_X11.h
@@ -28,8 +28,10 @@
/*
* Initalize X11 backend.
*
- * The display may be NULL default display. The coordinates are position and
- * geometry for newly created window.
+ * The display may be NULL for default display ($DISPLAY shell variable will
+ * be used).
+ *
+ * The coordinates are position and geometry for newly created window.
*
* Upon failure NULL is returned.
*/
diff --git a/libs/backends/GP_Backend.c b/libs/backends/GP_Backend.c
index fc37449..88b52a3 100644
--- a/libs/backends/GP_Backend.c
+++ b/libs/backends/GP_Backend.c
@@ -46,6 +46,12 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h)
{
if (backend->SetAttributes == NULL)
return 1;
+
+ if (w == 0)
+ w = backend->context->w;
+
+ if (h == 0)
+ h = backend->context->h;
if (backend->context->w == w && backend->context->h == h)
return 0;
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index 1c5dd91..aec3bce 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -152,13 +152,7 @@ static int x11_set_attributes(struct GP_Backend *self,
NULL, 0, NULL, NULL, NULL);
}
- if (w != 0 || h != 0) {
- if (w == 0)
- w = self->context->w;
-
- if (h == 0)
- h = self->context->h;
-
+ if (w != 0 && h != 0) {
GP_DEBUG(3, "Setting window size to %ux%u", w, h);
if (resize_ximage(self, w, h))
http://repo.or.cz/w/gfxprim.git/commit/0211dcc91eef550bdb079f6a2f3410bf3bda…
commit 0211dcc91eef550bdb079f6a2f3410bf3bda985a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 25 18:00:45 2012 +0200
core: Fix color conversion function parameters.
And thanks clang-3.1 for spotting this.
diff --git a/libs/core/GP_Color.c b/libs/core/GP_Color.c
index e124577..2c42d4a 100644
--- a/libs/core/GP_Color.c
+++ b/libs/core/GP_Color.c
@@ -121,7 +121,7 @@ bool GP_ColorNameToPixel(const char *color_name, GP_PixelType pixel_type,
if (color == GP_COL_INVALID)
return false;
- *pixel = GP_ColorToPixel(pixel_type, color);
+ *pixel = GP_ColorToPixel(color, pixel_type);
return true;
}
-----------------------------------------------------------------------
Summary of changes:
demos/particle/particle_demo.c | 4 +-
include/backends/GP_Backend.h | 2 +
include/backends/GP_X11.h | 17 ++++++-
lib.mk | 4 +-
libs/backends/GP_Backend.c | 6 +++
libs/backends/GP_BackendInit.c | 62 ++++++++++++++++++++++----
libs/backends/GP_X11.c | 94 +++++++++++++++++++++++++--------------
libs/core/GP_Color.c | 2 +-
8 files changed, 139 insertions(+), 52 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
[repo.or.cz] gfxprim.git branch master updated: a2551d947cc9e247126f7f6576c9b74b726484cc
by metan 22 May '12
by metan 22 May '12
22 May '12
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 a2551d947cc9e247126f7f6576c9b74b726484cc (commit)
via fb5e60ee7fa8028cadf3860bd3011d0fce562d4c (commit)
via 042f61acb0230f8fb15e50876c5be6efbbec1206 (commit)
from b4569232ecafc8e3fc6bfd877588b42ca8a21452 (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/a2551d947cc9e247126f7f6576c9b74b7264…
commit a2551d947cc9e247126f7f6576c9b74b726484cc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 19:32:41 2012 +0200
core: Fix rest of the G2_LE and G4_LE WritePixels.
diff --git a/demos/c_simple/virtual_backend_example.c b/demos/c_simple/virtual_backend_example.c
index 7976377..523a826 100644
--- a/demos/c_simple/virtual_backend_example.c
+++ b/demos/c_simple/virtual_backend_example.c
@@ -25,7 +25,7 @@
Simple virtual backend test.
Virtual backned allows you to test interactively pixel types that your
- hardware/xserverd doesn't support.
+ hardware/xserver doesn't support.
*/
diff --git a/include/core/GP_WritePixel.h b/include/core/GP_WritePixel.h
index 991782f..18a4ef6 100644
--- a/include/core/GP_WritePixel.h
+++ b/include/core/GP_WritePixel.h
@@ -30,10 +30,27 @@
#include <stdint.h>
#include <unistd.h>
+/*
+ * Writes cnt pixels starting at offset off.
+ */
void GP_WritePixels_1BPP_LE(uint8_t *start, uint8_t off,
size_t cnt, uint8_t val);
/*
+ * Writes cnt pixels starting at offset off (offset is in pixel sizes not in
+ * bits).
+ */
+void GP_WritePixels_2BPP_LE(uint8_t *start, uint8_t off,
+ size_t cnt, uint8_t val);
+
+/*
+ * Writes cnt pixels starting at offset off (offset is in pixel sizes not in
+ * bits i.e. offset could be either 0 or 1).
+ */
+void GP_WritePixels_4BPP_LE(uint8_t *start, uint8_t off,
+ size_t cnt, uint8_t val);
+
+/*
* These calls are not byte aligned, thuss needs start offset.
*/
void GP_WritePixels1bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val);
diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c
index 3b9f88a..eadfe1d 100644
--- a/libs/core/GP_Blit.c
+++ b/libs/core/GP_Blit.c
@@ -37,7 +37,7 @@ void GP_BlitXYXY_Fast(const GP_Context *src,
GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
GP_Context *dst, GP_Coord x2, GP_Coord y2);
-
+/*
void GP_BlitXYXY_Naive(const GP_Context *src,
GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
GP_Context *dst, GP_Coord x2, GP_Coord y2)
@@ -54,6 +54,7 @@ void GP_BlitXYXY_Naive(const GP_Context *src,
GP_PutPixel(dst, x2 + (x - x0), y2 + (y - y0), p);
}
}
+*/
void GP_BlitXYXY(const GP_Context *src,
GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
diff --git a/libs/core/GP_WritePixel.c b/libs/core/GP_WritePixel.c
index d255223..bc57ea1 100644
--- a/libs/core/GP_WritePixel.c
+++ b/libs/core/GP_WritePixel.c
@@ -104,6 +104,91 @@ void GP_WritePixels_1BPP_LE(uint8_t *start, uint8_t off,
}
}
+static const uint8_t bytes_2BPP[] = {0x00, 0x55, 0xaa, 0xff};
+
+void GP_WritePixels_2BPP_LE(uint8_t *start, uint8_t off,
+ size_t cnt, uint8_t val)
+{
+ int len = cnt;
+
+ /* Write start of the line */
+ switch (off) {
+ case 0:
+ break;
+ case 1:
+ GP_SET_BITS1_ALIGNED(2, 2, start, val);
+
+ if (--len == 0)
+ return;
+ case 2:
+ GP_SET_BITS1_ALIGNED(4, 2, start, val);
+
+ if (--len == 0)
+ return;
+ case 3:
+ GP_SET_BITS1_ALIGNED(6, 2, start, val);
+
+ if (--len == 0)
+ return;
+
+ start++;
+ break;
+ }
+
+ /* Write as many bytes as possible */
+ memset(start, bytes_2BPP[val & 0x03], len/4);
+
+ start+=len/4;
+
+ /* And the rest */
+ switch (len%4) {
+ case 3:
+ GP_SET_BITS1_ALIGNED(4, 2, start, val);
+ case 2:
+ GP_SET_BITS1_ALIGNED(2, 2, start, val);
+ case 1:
+ GP_SET_BITS1_ALIGNED(0, 2, start, val);
+ break;
+ }
+}
+
+static const uint8_t bytes_4BPP[] = {
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
+};
+
+void GP_WritePixels_4BPP_LE(uint8_t *start, uint8_t off,
+ size_t cnt, uint8_t val)
+{
+ int len = cnt;
+
+ /* Write start of the line */
+ switch (off) {
+ case 0:
+ break;
+ case 1:
+ GP_SET_BITS1_ALIGNED(4, 4, start, val);
+
+ if (--len == 0)
+ return;
+
+ start++;
+ break;
+ }
+
+ /* Write as many bytes as possible */
+ memset(start, bytes_4BPP[val & 0x0f], len/2);
+
+ start+=len/2;
+
+ /* And the rest */
+ switch (len%2) {
+ case 1:
+ GP_SET_BITS1_ALIGNED(0, 4, start, val);
+ break;
+ }
+}
+
static const uint8_t chunks_1bpp[8] = {
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe,
};
diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c
index b31611f..35e3e36 100644
--- a/libs/gfx/GP_HLine.c
+++ b/libs/gfx/GP_HLine.c
@@ -37,9 +37,9 @@
//TODO: BIT ENDIANESS
DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_1BPP_LE)
DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
-DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_2BPP_LE)
DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
-DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels4bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_4BPP_LE)
DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels4bpp)
DEF_HLINE_BU_FN(GP_HLine_Raw_18BPP_LE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels18bpp)
http://repo.or.cz/w/gfxprim.git/commit/fb5e60ee7fa8028cadf3860bd3011d0fce56…
commit fb5e60ee7fa8028cadf3860bd3011d0fce562d4c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 15:41:11 2012 +0200
config: Add xRGB2222 into config file.
diff --git a/gfxprim_config.py b/gfxprim_config.py
index b3eed3b..b0aafed 100644
--- a/gfxprim_config.py
+++ b/gfxprim_config.py
@@ -89,6 +89,12 @@ config = GfxPrimConfig(
('R', 6, 3),
('G', 3, 3),
('B', 0, 3)]),
+
+ PixelType(name='xRGB2222', pixelsize=PS_8BPP, chanslist=[
+ ('R', 4, 2),
+ ('G', 2, 2),
+ ('B', 0, 2)]),
+
#
# Palette types
#
http://repo.or.cz/w/gfxprim.git/commit/042f61acb0230f8fb15e50876c5be6efbbec…
commit 042f61acb0230f8fb15e50876c5be6efbbec1206
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 15:40:42 2012 +0200
examples: More work on virtual backend example.
diff --git a/demos/c_simple/virtual_backend_example.c b/demos/c_simple/virtual_backend_example.c
index 8f8858e..7976377 100644
--- a/demos/c_simple/virtual_backend_example.c
+++ b/demos/c_simple/virtual_backend_example.c
@@ -36,8 +36,8 @@ int main(int argc, char *argv[])
{
GP_Backend *backend;
GP_Context *context;
- GP_Pixel white_pixel, black_pixel;
- const char *backend_opts = "X11:400x400";
+ GP_Pixel white_pixel, black_pixel, red_pixel, blue_pixel, green_pixel;
+ const char *backend_opts = "X11:350x350";
int opt;
GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
@@ -95,18 +95,18 @@ int main(int argc, char *argv[])
GP_EventSetScreenSize(context->w, context->h);
+ /* Now draw some testing patters */
black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context);
white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context);
+ red_pixel = GP_ColorToContextPixel(GP_COL_RED, context);
+ blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, context);
+ green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, context);
GP_Fill(context, white_pixel);
-
- /* Now draw some testing patters */
- unsigned int i;
+
+ unsigned int i, j;
for (i = 0; i < 40; i++) {
GP_HLineXYW(context, 0, i, i, black_pixel);
-
- GP_HLineXYW(context, 40 + i, i, i, black_pixel);
-
GP_HLineXYW(context, 1, i + 40, i, black_pixel);
GP_HLineXYW(context, 2, i + 80, i, black_pixel);
GP_HLineXYW(context, 3, i + 120, i, black_pixel);
@@ -116,6 +116,27 @@ int main(int argc, char *argv[])
GP_HLineXYW(context, 7, i + 280, i, black_pixel);
}
+ for (i = 0; i < 256; i++) {
+ for (j = 0; j < 256; j++) {
+ uint8_t val = 1.00 * sqrt(i*i + j*j)/sqrt(2) + 0.5;
+
+ GP_Pixel pix = GP_RGBToContextPixel(i, j, val, context);
+ GP_PutPixel(context, i + 60, j + 10, pix);
+ }
+ }
+
+ GP_Text(context, NULL, 60, 270, GP_VALIGN_BELOW|GP_ALIGN_RIGHT,
+ black_pixel, white_pixel, "Lorem Ipsum dolor sit...");
+
+ GP_Text(context, NULL, 60, 290, GP_VALIGN_BELOW|GP_ALIGN_RIGHT,
+ red_pixel, white_pixel, "Lorem Ipsum dolor sit...");
+
+ GP_Text(context, NULL, 60, 310, GP_VALIGN_BELOW|GP_ALIGN_RIGHT,
+ green_pixel, white_pixel, "Lorem Ipsum dolor sit...");
+
+ GP_Text(context, NULL, 60, 330, GP_VALIGN_BELOW|GP_ALIGN_RIGHT,
+ blue_pixel, white_pixel, "Lorem Ipsum dolor sit...");
+
/* Update the backend screen */
GP_BackendFlip(backend);
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/virtual_backend_example.c | 39 +++++++++++---
gfxprim_config.py | 6 ++
include/core/GP_WritePixel.h | 17 ++++++
libs/core/GP_Blit.c | 3 +-
libs/core/GP_WritePixel.c | 85 ++++++++++++++++++++++++++++++
libs/gfx/GP_HLine.c | 4 +-
6 files changed, 142 insertions(+), 12 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
[repo.or.cz] gfxprim.git branch master updated: b4569232ecafc8e3fc6bfd877588b42ca8a21452
by metan 21 May '12
by metan 21 May '12
21 May '12
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 b4569232ecafc8e3fc6bfd877588b42ca8a21452 (commit)
via 1db9952e987f46349fe20c9d640cc7a322b2a2b0 (commit)
via 5386daff4c7167a5e5fa86b6d22964528ad6569c (commit)
via b0bc589726647eb0271d5869e354f865736a4808 (commit)
from 60acd49d53dd05fdfe61c875d1d7d09ac62a018b (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/b4569232ecafc8e3fc6bfd877588b42ca8a2…
commit b4569232ecafc8e3fc6bfd877588b42ca8a21452
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 13:19:27 2012 +0200
core: Write better 1BPP WritePixels function.
diff --git a/include/core/GP_WritePixel.h b/include/core/GP_WritePixel.h
index 26d072c..991782f 100644
--- a/include/core/GP_WritePixel.h
+++ b/include/core/GP_WritePixel.h
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -30,9 +30,8 @@
#include <stdint.h>
#include <unistd.h>
-/*
- * Calls for writing a linear block of pixels.
- */
+void GP_WritePixels_1BPP_LE(uint8_t *start, uint8_t off,
+ size_t cnt, uint8_t val);
/*
* These calls are not byte aligned, thuss needs start offset.
diff --git a/libs/core/GP_WritePixel.c b/libs/core/GP_WritePixel.c
index c35b7ec..d255223 100644
--- a/libs/core/GP_WritePixel.c
+++ b/libs/core/GP_WritePixel.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,6 +28,82 @@
#include "GP_Core.h"
#include "GP_WritePixel.h"
+static const uint8_t bytes_1BPP[] = {0x00, 0xff};
+
+void GP_WritePixels_1BPP_LE(uint8_t *start, uint8_t off,
+ size_t cnt, uint8_t val)
+{
+ int len = cnt;
+
+ /* Write start of the line */
+ switch (off) {
+ case 0:
+ break;
+ case 1:
+ GP_SET_BITS1_ALIGNED(1, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 2:
+ GP_SET_BITS1_ALIGNED(2, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 3:
+ GP_SET_BITS1_ALIGNED(3, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 4:
+ GP_SET_BITS1_ALIGNED(4, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 5:
+ GP_SET_BITS1_ALIGNED(5, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 6:
+ GP_SET_BITS1_ALIGNED(6, 1, start, val);
+
+ if (--len == 0)
+ return;
+ case 7:
+ GP_SET_BITS1_ALIGNED(7, 1, start, val);
+
+ if (--len == 0)
+ return;
+
+ start++;
+ break;
+ }
+
+ /* Write as many bytes as possible */
+ memset(start, bytes_1BPP[val & 0x01], len/8);
+
+ start+=len/8;
+
+ /* And the rest */
+ switch (len%8) {
+ case 7:
+ GP_SET_BITS1_ALIGNED(6, 1, start, val);
+ case 6:
+ GP_SET_BITS1_ALIGNED(5, 1, start, val);
+ case 5:
+ GP_SET_BITS1_ALIGNED(4, 1, start, val);
+ case 4:
+ GP_SET_BITS1_ALIGNED(3, 1, start, val);
+ case 3:
+ GP_SET_BITS1_ALIGNED(2, 1, start, val);
+ case 2:
+ GP_SET_BITS1_ALIGNED(1, 1, start, val);
+ case 1:
+ GP_SET_BITS1_ALIGNED(0, 1, start, val);
+ break;
+ }
+}
+
static const uint8_t chunks_1bpp[8] = {
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe,
};
diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c
index e9daf45..b31611f 100644
--- a/libs/gfx/GP_HLine.c
+++ b/libs/gfx/GP_HLine.c
@@ -35,7 +35,7 @@
/* Generate drawing functions for various bit depths. */
//TODO: BIT ENDIANESS
-DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_1BPP_LE)
DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
http://repo.or.cz/w/gfxprim.git/commit/1db9952e987f46349fe20c9d640cc7a322b2…
commit 1db9952e987f46349fe20c9d640cc7a322b2a2b0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 13:18:17 2012 +0200
examples: Add virtual backend example.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile
index 323ae99..eeadcf8 100644
--- a/demos/c_simple/Makefile
+++ b/demos/c_simple/Makefile
@@ -5,7 +5,8 @@ CSOURCES=$(shell echo *.c)
INCLUDE=
LDLIBS+=-lGP -lGP_backends -lSDL -L$(TOPDIR)/build/
-APPS=backend_example loaders_example loaders filters_symmetry gfx_koch
+APPS=backend_example loaders_example loaders filters_symmetry gfx_koch+ virtual_backend_example
include $(TOPDIR)/pre.mk
include $(TOPDIR)/app.mk
diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/backend_example.c
index 838726b..3f5c199 100644
--- a/demos/c_simple/backend_example.c
+++ b/demos/c_simple/backend_example.c
@@ -48,6 +48,7 @@ int main(int argc, char *argv[])
break;
default:
fprintf(stderr, "Invalid paramter '%c'n", opt);
+ return 1;
}
}
diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/virtual_backend_example.c
similarity index 61%
copy from demos/c_simple/backend_example.c
copy to demos/c_simple/virtual_backend_example.c
index 838726b..8f8858e 100644
--- a/demos/c_simple/backend_example.c
+++ b/demos/c_simple/virtual_backend_example.c
@@ -22,7 +22,10 @@
/*
- Simple backend example.
+ Simple virtual backend test.
+
+ Virtual backned allows you to test interactively pixel types that your
+ hardware/xserverd doesn't support.
*/
@@ -34,27 +37,59 @@ int main(int argc, char *argv[])
GP_Backend *backend;
GP_Context *context;
GP_Pixel white_pixel, black_pixel;
- const char *backend_opts = "X11:100x100";
+ const char *backend_opts = "X11:400x400";
int opt;
+ GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
- while ((opt = getopt(argc, argv, "b:h")) != -1) {
+ while ((opt = getopt(argc, argv, "b:h:p:")) != -1) {
switch (opt) {
case 'b':
backend_opts = optarg;
break;
+ case 'p':
+ emul_type = GP_PixelTypeByName(optarg);
+
+ if (emul_type == GP_PIXEL_UNKNOWN) {
+ fprintf(stderr, "Invalid pixel type '%s'n", optarg);
+ return 1;
+ }
+ break;
case 'h':
GP_BackendInit(NULL, NULL, stderr);
return 0;
break;
default:
fprintf(stderr, "Invalid paramter '%c'n", opt);
+ return 1;
}
}
/* Turn on debug messages */
GP_SetDebugLevel(10);
- backend = GP_BackendInit(backend_opts, "Backend Example", stderr);
+ backend = GP_BackendInit(backend_opts, "Virtual Backend Example", stderr);
+
+ if (emul_type != GP_PIXEL_UNKNOWN) {
+ GP_Backend *emul;
+
+ /*
+ * Create an emulated backend on the top of real backend.
+ *
+ * The GP_BACKEND_CALL_EXIT says that when calling exit on
+ * emulated backend, the real backend exit will be called as
+ * well.
+ */
+ emul = GP_BackendVirtualInit(backend, emul_type, GP_BACKEND_CALL_EXIT);
+
+ if (emul == NULL) {
+ fprintf(stderr, "Failed to create Virtual Backendn");
+ GP_BackendExit(backend);
+ return 1;
+ }
+
+ /* Once created virtual backend behaves exactly like a real one */
+ backend = emul;
+ }
context = backend->context;
@@ -63,9 +98,23 @@ int main(int argc, char *argv[])
black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context);
white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context);
- GP_Fill(context, black_pixel);
- GP_Line(context, 0, 0, context->w - 1, context->h - 1, white_pixel);
- GP_Line(context, 0, context->h - 1, context->w - 1, 0, white_pixel);
+ GP_Fill(context, white_pixel);
+
+ /* Now draw some testing patters */
+ unsigned int i;
+ for (i = 0; i < 40; i++) {
+ GP_HLineXYW(context, 0, i, i, black_pixel);
+
+ GP_HLineXYW(context, 40 + i, i, i, black_pixel);
+
+ GP_HLineXYW(context, 1, i + 40, i, black_pixel);
+ GP_HLineXYW(context, 2, i + 80, i, black_pixel);
+ GP_HLineXYW(context, 3, i + 120, i, black_pixel);
+ GP_HLineXYW(context, 4, i + 160, i, black_pixel);
+ GP_HLineXYW(context, 5, i + 200, i, black_pixel);
+ GP_HLineXYW(context, 6, i + 240, i, black_pixel);
+ GP_HLineXYW(context, 7, i + 280, i, black_pixel);
+ }
/* Update the backend screen */
GP_BackendFlip(backend);
http://repo.or.cz/w/gfxprim.git/commit/5386daff4c7167a5e5fa86b6d22964528ad6…
commit 5386daff4c7167a5e5fa86b6d22964528ad6569c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 13:17:28 2012 +0200
tests: Fix loaders tests compilation.
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
index e079177..98b817e 100644
--- a/tests/loaders/Makefile
+++ b/tests/loaders/Makefile
@@ -1,4 +1,5 @@
TOPDIR=../..
+include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
@@ -7,5 +8,5 @@ LDLIBS+=-lGP -L$(TOPDIR)/build/
APPS=PBM_invert PBM_test PGM_invert PGM_test
-include $(TOPDIR)/include.mk
include $(TOPDIR)/app.mk
+include $(TOPDIR)/post.mk
diff --git a/tests/loaders/PBM_test.c b/tests/loaders/PBM_test.c
index 8058b00..a33e1c8 100644
--- a/tests/loaders/PBM_test.c
+++ b/tests/loaders/PBM_test.c
@@ -46,7 +46,7 @@ int main(void)
GP_FillCircle(context, 20, 20, 9, 1);
GP_FillCircle(context, 20, 20, 7, 0);
GP_FillCircle(context, 20, 20, 4, 1);
- GP_Text(context, NULL, 10, 40, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test Test", 1);
+ GP_Text(context, NULL, 10, 40, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, 0, 1, "Test Test");
if (GP_SavePBM("test.pbm", context)) {
fprintf(stderr, "Can't save contextn");
diff --git a/tests/loaders/PGM_test.c b/tests/loaders/PGM_test.c
index 2480144..8268f4d 100644
--- a/tests/loaders/PGM_test.c
+++ b/tests/loaders/PGM_test.c
@@ -66,9 +66,9 @@ int main(void)
GP_FillCircle(context, W/2, H/2, 7, 2);
GP_FillCircle(context, W/2, H/2, 5, 1);
GP_FillCircle(context, W/2, H/2, 2, 0);
- GP_Text(context, NULL, 60, 10, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test", 3);
- GP_Text(context, NULL, 60, 20, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test", 2);
- GP_Text(context, NULL, 60, 30, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test", 1);
+ GP_Text(context, NULL, 60, 10, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, 0, 3, "Test");
+ GP_Text(context, NULL, 60, 20, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, 0, 2, "Test");
+ GP_Text(context, NULL, 60, 30, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, 0, 1, "Test");
if (GP_SavePGM("test.pgm", context)) {
fprintf(stderr, "Can't save contextn");
http://repo.or.cz/w/gfxprim.git/commit/b0bc589726647eb0271d5869e354f865736a…
commit b0bc589726647eb0271d5869e354f865736a4808
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 12:41:11 2012 +0200
backends: Add virtual backend into GP_Backends.h.
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 931c3f0..7095eef 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -34,7 +34,6 @@
#include <GP.h>
#include <backends/GP_Backends.h>
-#include <backends/GP_BackendVirtual.h>
#include <input/GP_InputDriverLinux.h>
#include "cpu_timer.h"
diff --git a/include/backends/GP_Backends.h b/include/backends/GP_Backends.h
index d9420e1..9d72fc7 100644
--- a/include/backends/GP_Backends.h
+++ b/include/backends/GP_Backends.h
@@ -40,6 +40,7 @@
#include "backends/GP_LinuxFB.h"
#include "backends/GP_SDL.h"
#include "backends/GP_X11.h"
+#include "backends/GP_BackendVirtual.h"
/*
* Simplified backend initalization.
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/Makefile | 3 +-
demos/c_simple/backend_example.c | 1 +
...backend_example.c => virtual_backend_example.c} | 63 ++++++++++++++--
demos/spiv/spiv.c | 1 -
include/backends/GP_Backends.h | 1 +
include/core/GP_WritePixel.h | 7 +-
libs/core/GP_WritePixel.c | 78 +++++++++++++++++++-
libs/gfx/GP_HLine.c | 2 +-
tests/loaders/Makefile | 3 +-
tests/loaders/PBM_test.c | 2 +-
tests/loaders/PGM_test.c | 6 +-
11 files changed, 147 insertions(+), 20 deletions(-)
copy demos/c_simple/{backend_example.c => virtual_backend_example.c} (61%)
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
[repo.or.cz] gfxprim.git branch master updated: 60acd49d53dd05fdfe61c875d1d7d09ac62a018b
by metan 21 May '12
by metan 21 May '12
21 May '12
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 60acd49d53dd05fdfe61c875d1d7d09ac62a018b (commit)
via 52f483d206017a87e76ec9541539bf7d3beb7efb (commit)
from 2bea36d5281f8683a1215177d6a162581de40521 (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/60acd49d53dd05fdfe61c875d1d7d09ac62a…
commit 60acd49d53dd05fdfe61c875d1d7d09ac62a018b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 00:51:53 2012 +0200
spiv: Add option to turn on dithering.
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 2062015..931c3f0 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -49,6 +49,7 @@ static int abort_flag = 0;
static int rotate = 0;
static int show_progress = 0;
static int resampling_method = GP_INTERP_LINEAR_LF_INT;
+static int dithering = 0;
static int image_loader_callback(GP_ProgressCallback *self)
{
@@ -278,8 +279,19 @@ static void *image_loader(void *ptr)
uint32_t cx = (context->w - ret->w)/2;
uint32_t cy = (context->h - ret->h)/2;
+ GP_Context sub_display;
+
cpu_timer_start(&timer, "Blitting");
- GP_Blit_Raw(ret, 0, 0, ret->w, ret->h, context, cx, cy);
+
+ if (dithering) {
+ callback.priv = "Dithering";
+ GP_ContextSubContext(context, &sub_display, cx, cy, ret->w, ret->h);
+ // GP_FilterFloydSteinberg_from_RGB888(ret, &sub_display, 0, NULL);
+ GP_FilterHilbertPeano_from_RGB888(ret, &sub_display, NULL);
+ } else {
+ GP_Blit_Raw(ret, 0, 0, ret->w, ret->h, context, cx, cy);
+ }
+
cpu_timer_stop(&timer);
GP_ContextFree(ret);
@@ -385,7 +397,7 @@ int main(int argc, char *argv[])
int opt, debug_level = 0;
GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
- while ((opt = getopt(argc, argv, "b:cd:e:Ii:Ps:r:")) != -1) {
+ while ((opt = getopt(argc, argv, "b:cd:e:fIi:Ps:r:")) != -1) {
switch (opt) {
case 'I':
params.show_info = 1;
@@ -396,6 +408,9 @@ int main(int argc, char *argv[])
case 'i':
input_dev = optarg;
break;
+ case 'f':
+ dithering = 1;
+ break;
case 's':
sleep_sec = atoi(optarg);
break;
http://repo.or.cz/w/gfxprim.git/commit/52f483d206017a87e76ec9541539bf7d3beb…
commit 52f483d206017a87e76ec9541539bf7d3beb7efb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 00:45:56 2012 +0200
filters: Hilbert-Peano fix curve size calculation.
diff --git a/libs/filters/GP_HilbertPeanoDithering.gen.c.t b/libs/filters/GP_HilbertPeanoDithering.gen.c.t
index a925c9c..78a9b53 100644
--- a/libs/filters/GP_HilbertPeanoDithering.gen.c.t
+++ b/libs/filters/GP_HilbertPeanoDithering.gen.c.t
@@ -21,6 +21,8 @@ static unsigned int count_bits(unsigned int n)
i++;
} while (n);
+ i--;
+
return (i + (s != (1U<<i)));
}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 19 +++++++++++++++++--
libs/filters/GP_HilbertPeanoDithering.gen.c.t | 2 ++
2 files changed, 19 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 2bea36d5281f8683a1215177d6a162581de40521
by metan 21 May '12
by metan 21 May '12
21 May '12
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 2bea36d5281f8683a1215177d6a162581de40521 (commit)
via 28e1f1872424ff83ed2eceafcbdd6b9b293b8866 (commit)
from c2f10f3f488c6f32fb2c516153689a1fcc317ff0 (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/2bea36d5281f8683a1215177d6a162581de4…
commit 2bea36d5281f8683a1215177d6a162581de40521
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 00:10:36 2012 +0200
filters: Templatized Hilbert Peano Dithering.
diff --git a/libs/filters/GP_Dither.c b/libs/filters/GP_Dither.c
index e0c6be1..d258ef4 100644
--- a/libs/filters/GP_Dither.c
+++ b/libs/filters/GP_Dither.c
@@ -133,3 +133,14 @@ GP_Context *GP_FilterFloydSteinberg_from_RGB888(const GP_Context *src,
return ret;
}
+
+int GP_FilterHilbertPeano_RGB888_to_XXX_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+int GP_FilterHilbertPeano_from_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ return GP_FilterHilbertPeano_RGB888_to_XXX_Raw(src, dst, callback);
+}
diff --git a/libs/filters/GP_Dither.gen.c.t b/libs/filters/GP_Dither.gen.c.t
index 8b9e237..c1ec2bf 100644
--- a/libs/filters/GP_Dither.gen.c.t
+++ b/libs/filters/GP_Dither.gen.c.t
@@ -1,9 +1,7 @@
%% extends "base.c.t"
-%% block descr
-Floyd Steinberg dithering RGB888 -> any pixel
-%% endblock
+{% block descr %}Floyd Steinberg dithering RGB888 -> any pixel{% endblock %}
%% block body
@@ -52,7 +50,7 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G
for (y = 0; y < (GP_Coord)src->h; y++) {
for (x = 0; x < (GP_Coord)src->w; x++) {
- GP_Pixel pix = GP_GetPixel(src, x, y);
+ GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, x, y);
%% for c in pt.chanslist
%% if pt.is_gray()
diff --git a/libs/filters/GP_HilbertPeanoDithering.c b/libs/filters/GP_HilbertPeanoDithering.c
deleted file mode 100644
index decaebf..0000000
--- a/libs/filters/GP_HilbertPeanoDithering.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include "core/GP_Debug.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_Core.h"
-
-#include "GP_HilbertCurve.h"
-#include "GP_Dither.h"
-
-/*
- * Returns closest greater square of two, used to determine the curve size.
- */
-static unsigned int count_bits(unsigned int n)
-{
- unsigned int i = 0, s = n;
-
- do {
- n>>=1;
- i++;
- } while (n);
-
- return (i + (s != (1<<i)));
-}
-
-int GP_FilterHilbertPeano_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- struct GP_CurveState state;
-
- unsigned int n = GP_MAX(count_bits(src->w), count_bits(src->h));
-
- GP_DEBUG(1, "Hilbert Peano dithering %ux%u -> n = %u", src->w, src->h, n);
-
- GP_HilbertCurveInit(&state, n);
-
- int err = 0, cnt = 0;
-
- while (GP_HilbertCurveContinues(&state)) {
-
- if (state.x < src->w && state.y < src->h) {
- int pix = GP_GetPixel_Raw(src, state.x, state.y);
-
- pix = GP_ConvertPixel(pix, src->pixel_type, GP_PIXEL_G8);
-
- pix += err;
-
- if (pix > 127) {
- err = pix - 255;
- pix = 1;
- } else {
- err = pix;
- pix = 0;
- }
-
- GP_PutPixel_Raw_1BPP_LE(dst, state.x, state.y, pix);
-
- cnt++;
-
- if (GP_ProgressCallbackReport(callback, cnt/src->h, src->w, src->h))
- return 1;
-
- /* We are done, exit */
- if (cnt == src->w * src->h - 1) {
- GP_ProgressCallbackDone(callback);
- return 0;
- }
- } else {
- err = 0;
- }
-
- GP_HilbertCurveNext(&state);
- }
-
- GP_ProgressCallbackDone(callback);
- return 0;
-}
diff --git a/libs/filters/GP_HilbertPeanoDithering.gen.c.t b/libs/filters/GP_HilbertPeanoDithering.gen.c.t
new file mode 100644
index 0000000..a925c9c
--- /dev/null
+++ b/libs/filters/GP_HilbertPeanoDithering.gen.c.t
@@ -0,0 +1,126 @@
+%% extends "base.c.t"
+
+{% block descr %}Hilbert Peano dithering RGB888 -> any pixel{% endblock %}
+
+%% block body
+
+#include "core/GP_Core.h"
+#include "core/GP_GetPutPixel.h"
+#include "GP_HilbertCurve.h"
+#include "GP_Filter.h"
+
+/*
+ * Returns closest greater square of two, used to determine the curve size.
+ */
+static unsigned int count_bits(unsigned int n)
+{
+ unsigned int i = 0, s = n;
+
+ do {
+ n>>=1;
+ i++;
+ } while (n);
+
+ return (i + (s != (1U<<i)));
+}
+
+%% for pt in pixeltypes
+%% if not pt.is_unknown() and not pt.is_alpha() and not pt.is_palette()
+/*
+ * Hilbert Peano RGB888 to {{ pt.name }}
+ */
+int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ struct GP_CurveState state;
+ unsigned int n;
+
+ n = GP_MAX(count_bits(src->w), count_bits(src->h));
+
+ GP_DEBUG(1, "Hilbert Peano dithering %ux%u -> n = %u", src->w, src->h, n);
+
+ GP_HilbertCurveInit(&state, n);
+
+ /* processed pixels counter */
+ unsigned int cnt = 0;
+
+ /* error counters */
+%% for c in pt.chanslist
+ int err_{{ c[0] }} = 0;
+%% endfor
+
+ 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);
+
+%% for c in pt.chanslist
+%% if pt.is_gray()
+ int pix_{{ c[0] }} = GP_Pixel_GET_R_RGB888(pix) +
+ GP_Pixel_GET_G_RGB888(pix) +
+ GP_Pixel_GET_B_RGB888(pix);
+%% else
+ int pix_{{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_RGB888(pix);
+%% endif
+
+ pix_{{ c[0] }} += err_{{ c[0] }};
+
+%% if pt.is_gray()
+ int res_{{ c[0] }} = ({{ 2 ** c[2] - 1}} * pix_{{ c[0] }} + 382) / {{ 3 * 255 }};
+ err_{{ c[0] }} = pix_{{ c[0] }} - {{ 3 * 255 }} * res_{{ c[0] }} / {{ 2 ** c[2] - 1 }};
+%% else
+ int res_{{ c[0] }} = ({{ 2 ** c[2] - 1}} * pix_{{ c[0] }} + 127) / 255;
+ err_{{ c[0] }} = pix_{{ c[0] }} - 255 * res_{{ c[0] }} / {{ 2 ** c[2] - 1 }};
+%% endif
+%% endfor
+
+%% if pt.is_gray()
+ GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, state.x, state.y, res_V);
+%% else
+ GP_Pixel res = GP_Pixel_CREATE_{{ pt.name }}(res_{{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, res_{{ c[0] }}{% endfor %});
+
+ GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, state.x, state.y, res);
+%% endif
+ cnt++;
+
+ if (GP_ProgressCallbackReport(callback, cnt/src->h, src->w, src->h))
+ return 1;
+
+ /* We are done, exit */
+ if (cnt == src->w * src->h - 1) {
+ GP_ProgressCallbackDone(callback);
+ return 0;
+ }
+ } else {
+%% for c in pt.chanslist
+ err_{{ c[0] }} = 0;
+%% endfor
+ }
+
+ GP_HilbertCurveNext(&state);
+ }
+
+ GP_ProgressCallbackDone(callback);
+ return 0;
+}
+
+%% endif
+%% endfor
+
+int GP_FilterHilbertPeano_RGB888_to_XXX_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ switch (dst->pixel_type) {
+%% for pt in pixeltypes
+%% if not pt.is_unknown() and not pt.is_alpha() and not pt.is_palette()
+ case GP_PIXEL_{{ pt.name }}:
+ return GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(src, dst, callback);
+%% endif
+%% endfor
+ default:
+ return 1;
+ }
+}
+
+%% endblock body
diff --git a/libs/filters/Makefile b/libs/filters/Makefile
index 216d06d..7a9a670 100644
--- a/libs/filters/Makefile
+++ b/libs/filters/Makefile
@@ -8,7 +8,7 @@ POINT_FILTERS=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c GP_Max.gen.c GP_Multiply.gen.c
-GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_Dither.gen.c+GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_Dither.gen.c GP_HilbertPeanoDithering.gen.c $(POINT_FILTERS) $(ARITHMETIC_FILTERS) $(STATS_FILTERS)
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
http://repo.or.cz/w/gfxprim.git/commit/28e1f1872424ff83ed2eceafcbdd6b9b293b…
commit 28e1f1872424ff83ed2eceafcbdd6b9b293b8866
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 20 22:00:46 2012 +0200
filters: Initial version of Hilbert Peano Dithering.
* For G1 only now.
diff --git a/include/filters/GP_Dither.h b/include/filters/GP_Dither.h
index b0b5157..07a8da2 100644
--- a/include/filters/GP_Dither.h
+++ b/include/filters/GP_Dither.h
@@ -61,4 +61,12 @@ int GP_FilterFloydSteinberg_XXX_to_G1_Raw(const GP_Context *src,
GP_ProgressCallback *callback);
+/*
+ * Hilbert-peano space filling curve based dithering.
+ */
+int GP_FilterHilbertPeano_from_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+
#endif /* FILTERS_GP_DITHER_H */
diff --git a/include/filters/GP_Dither.h b/include/filters/GP_HilbertCurve.h
similarity index 53%
copy from include/filters/GP_Dither.h
copy to include/filters/GP_HilbertCurve.h
index b0b5157..fecac22 100644
--- a/include/filters/GP_Dither.h
+++ b/include/filters/GP_HilbertCurve.h
@@ -16,49 +16,84 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
- Dithering algorithms.
+ Hilbert curve implementation.
*/
-#ifndef FILTERS_GP_DITHER_H
-#define FILTERS_GP_DITHER_H
+#ifndef FILTERS_GP_HILBERT_CURVE_H
+#define FILTERS_GP_HILBERT_CURVE_H
-#include "GP_Filter.h"
+struct GP_CurveState {
+ /* half of the number of bits of curve size */
+ unsigned int n;
+ /* coordinates */
+ unsigned int x, y;
+ /* current curve lenght */
+ unsigned int s;
+};
/*
- * Floyd Steinberg
+ * Resets curve to initial state i.e. x = 0, y = 0, (length) s = 0.
*/
-GP_Context *GP_FilterFloydSteinberg_to_G1(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+static inline void GP_HilbertCurveInit(struct GP_CurveState *state, int n)
+{
+ state->n = n;
+ state->s = 0;
+ state->x = 0;
+ state->y = 0;
+}
/*
- * Floyd Steinberg
+ * Variant of Lam and Shapiro
*/
-GP_Context *GP_FilterFloydSteinberg_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_PixelType dst_pixel_type,
- GP_ProgressCallback *callback);
+static inline void GP_HilbertCurveGetXY(struct GP_CurveState *state)
+{
+ int sa, sb;
+ unsigned int i, temp, x, y;
+
+ for (i = 0; i < 2 * state->n; i += 2) {
+ sa = (state->s >> (i+1)) & 0x01;
+ sb = (state->s >> i) & 0x01;
+
+ if ((sa ^ sb) == 0) {
+ temp = x;
+ x = y ^ (-sa);
+ y = temp ^ (-sa);
+ }
+
+ x = (x >> 1) | (sa << 31);
+ y = (y >> 1) | ((sa ^ sb) << 31);
+ }
+
+ state->x = x >> (32 - state->n);
+ state->y = y >> (32 - state->n);
+}
+
/*
- * Converts RGB888 to RGB or Grayscale bitmap.
+ * Finds next X and Y
*/
-int GP_FilterFloydSteinberg_RGB888_to_XXX_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+static inline void GP_HilbertCurveNext(struct GP_CurveState *state)
+{
+
+ /* increment length */
+ state->s++;
+ /* get X and Y */
+ GP_HilbertCurveGetXY(state);
+}
/*
- * Converts any bitmap to 1-bit Grayscale.
+ * Returns true if we are not at curve endpoint
*/
-int GP_FilterFloydSteinberg_XXX_to_G1_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
-
+static inline int GP_HilbertCurveContinues(struct GP_CurveState *state)
+{
+ return state->s < (1U<<(2*state->n));
+}
-#endif /* FILTERS_GP_DITHER_H */
+#endif /* FILTERS_GP_HILBERT_CURVE_H */
diff --git a/include/filters/GP_Dither.h b/libs/filters/GP_HilbertPeanoDithering.c
similarity index 51%
copy from include/filters/GP_Dither.h
copy to libs/filters/GP_HilbertPeanoDithering.c
index b0b5157..decaebf 100644
--- a/include/filters/GP_Dither.h
+++ b/libs/filters/GP_HilbertPeanoDithering.c
@@ -16,49 +16,82 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-/*
+#include "core/GP_Debug.h"
+#include "core/GP_GetPutPixel.h"
+#include "core/GP_Core.h"
- Dithering algorithms.
+#include "GP_HilbertCurve.h"
+#include "GP_Dither.h"
+/*
+ * Returns closest greater square of two, used to determine the curve size.
*/
+static unsigned int count_bits(unsigned int n)
+{
+ unsigned int i = 0, s = n;
-#ifndef FILTERS_GP_DITHER_H
-#define FILTERS_GP_DITHER_H
+ do {
+ n>>=1;
+ i++;
+ } while (n);
-#include "GP_Filter.h"
+ return (i + (s != (1<<i)));
+}
-/*
- * Floyd Steinberg
- */
-GP_Context *GP_FilterFloydSteinberg_to_G1(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterHilbertPeano_from_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ struct GP_CurveState state;
-/*
- * Floyd Steinberg
- */
-GP_Context *GP_FilterFloydSteinberg_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_PixelType dst_pixel_type,
- GP_ProgressCallback *callback);
+ unsigned int n = GP_MAX(count_bits(src->w), count_bits(src->h));
-/*
- * Converts RGB888 to RGB or Grayscale bitmap.
- */
-int GP_FilterFloydSteinberg_RGB888_to_XXX_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+ GP_DEBUG(1, "Hilbert Peano dithering %ux%u -> n = %u", src->w, src->h, n);
-/*
- * Converts any bitmap to 1-bit Grayscale.
- */
-int GP_FilterFloydSteinberg_XXX_to_G1_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+ GP_HilbertCurveInit(&state, n);
+
+ int err = 0, cnt = 0;
+
+ while (GP_HilbertCurveContinues(&state)) {
+
+ if (state.x < src->w && state.y < src->h) {
+ int pix = GP_GetPixel_Raw(src, state.x, state.y);
+
+ pix = GP_ConvertPixel(pix, src->pixel_type, GP_PIXEL_G8);
+
+ pix += err;
+
+ if (pix > 127) {
+ err = pix - 255;
+ pix = 1;
+ } else {
+ err = pix;
+ pix = 0;
+ }
+
+ GP_PutPixel_Raw_1BPP_LE(dst, state.x, state.y, pix);
+
+ cnt++;
+
+ if (GP_ProgressCallbackReport(callback, cnt/src->h, src->w, src->h))
+ return 1;
+
+ /* We are done, exit */
+ if (cnt == src->w * src->h - 1) {
+ GP_ProgressCallbackDone(callback);
+ return 0;
+ }
+ } else {
+ err = 0;
+ }
+ GP_HilbertCurveNext(&state);
+ }
-#endif /* FILTERS_GP_DITHER_H */
+ GP_ProgressCallbackDone(callback);
+ return 0;
+}
-----------------------------------------------------------------------
Summary of changes:
include/filters/GP_Dither.h | 8 ++
.../GP_GIF.h => filters/GP_HilbertCurve.h} | 84 ++++++++++----
libs/filters/GP_Dither.c | 11 ++
libs/filters/GP_Dither.gen.c.t | 6 +-
libs/filters/GP_HilbertPeanoDithering.gen.c.t | 126 ++++++++++++++++++++
libs/filters/Makefile | 2 +-
6 files changed, 209 insertions(+), 28 deletions(-)
copy include/{loaders/GP_GIF.h => filters/GP_HilbertCurve.h} (55%)
create mode 100644 libs/filters/GP_HilbertPeanoDithering.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
[repo.or.cz] gfxprim.git branch master updated: c2f10f3f488c6f32fb2c516153689a1fcc317ff0
by metan 18 May '12
by metan 18 May '12
18 May '12
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 c2f10f3f488c6f32fb2c516153689a1fcc317ff0 (commit)
via 76df7a3b73ab206fcb98801c38c0d5507af80c9e (commit)
via 0aef2153ab52e46219ddb032d5c0920903d4f7ee (commit)
via bef941cfec1236983582823bf2d0b45b7c5a2d10 (commit)
from cfc171705f4af25d48d768ed3b5e89e1ef668393 (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/c2f10f3f488c6f32fb2c516153689a1fcc31…
commit c2f10f3f488c6f32fb2c516153689a1fcc317ff0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 18 20:16:07 2012 +0200
spiv: Add option to use pixel type emulation for backend.
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 5d0dcab..2062015 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -34,6 +34,7 @@
#include <GP.h>
#include <backends/GP_Backends.h>
+#include <backends/GP_BackendVirtual.h>
#include <input/GP_InputDriverLinux.h>
#include "cpu_timer.h"
@@ -382,8 +383,9 @@ int main(int argc, char *argv[])
int sleep_sec = -1;
struct loader_params params = {NULL, 0, 0, 0, .img = NULL};
int opt, debug_level = 0;
+ GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
- while ((opt = getopt(argc, argv, "b:cd:Ii:Ps:r:")) != -1) {
+ while ((opt = getopt(argc, argv, "b:cd:e:Ii:Ps:r:")) != -1) {
switch (opt) {
case 'I':
params.show_info = 1;
@@ -403,6 +405,14 @@ int main(int argc, char *argv[])
case 'd':
debug_level = atoi(optarg);
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"))
rotate = 90;
@@ -437,6 +447,9 @@ int main(int argc, char *argv[])
init_backend(backend_opts);
+ if (emul_type != GP_PIXEL_UNKNOWN)
+ backend = GP_BackendVirtualInit(backend, emul_type, GP_BACKEND_CALL_EXIT);
+
context = backend->context;
GP_EventSetScreenSize(context->w, context->h);
http://repo.or.cz/w/gfxprim.git/commit/76df7a3b73ab206fcb98801c38c0d5507af8…
commit 76df7a3b73ab206fcb98801c38c0d5507af80c9e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 18 20:13:16 2012 +0200
core: Add GP_PixelTypeByName().
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index c8d82e4..8fb84a2 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -19,7 +19,7 @@
* 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
* Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
* *
@@ -159,6 +159,11 @@ static inline void GP_PixelPrint(GP_Pixel pixel, GP_PixelType type)
}
/*
+ * Returns pixel type for passed human-readable name (e.g. RGB888).
+ */
+GP_PixelType GP_PixelTypeByName(const char *name);
+
+/*
* Match pixel type to known pixel types.
*
* Returns either valid PixelType or GP_PIXEL_UNKNOWN
diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c
index bedaf14..b14d5b0 100644
--- a/libs/core/GP_Pixel.c
+++ b/libs/core/GP_Pixel.c
@@ -19,7 +19,7 @@
* 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -56,6 +56,17 @@ static int match(const GP_PixelTypeChannel *channel, GP_Pixel mask)
return (chmask == mask);
}
+GP_PixelType GP_PixelTypeByName(const char *name)
+{
+ unsigned int i;
+
+ for (i = 0; i < GP_PIXEL_MAX; i++)
+ if (!strcasecmp(name, GP_PixelTypes[i].name))
+ return i;
+
+ return GP_PIXEL_UNKNOWN;
+}
+
GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
GP_Pixel bmask, GP_Pixel amask,
uint8_t bits_per_pixel)
http://repo.or.cz/w/gfxprim.git/commit/0aef2153ab52e46219ddb032d5c0920903d4…
commit 0aef2153ab52e46219ddb032d5c0920903d4f7ee
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 18 20:00:26 2012 +0200
backends: Add virtual emulation backend for testing.
diff --git a/include/backends/GP_BackendVirtual.h b/include/backends/GP_BackendVirtual.h
new file mode 100644
index 0000000..a050dc3
--- /dev/null
+++ b/include/backends/GP_BackendVirtual.h
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ Virtual backend, could emulate backed with any pixel type on the top of
+ initalized backend. Useful for testing.
+
+ */
+
+#ifndef BACKENDS_GP_BACKEND_VIRTUAL_H
+#define BACKENDS_GP_BACKEND_VIRTUAL_H
+
+#include "GP_Backend.h"
+
+enum GP_BackendVirtFlags {
+ /*
+ * If set virtual backend exit calls 'parent' Exit as well.
+ */
+ GP_BACKEND_CALL_EXIT = 0x01,
+};
+
+/*
+ * Create an virtual backend on the top of the existing backend.
+ */
+GP_Backend *GP_BackendVirtualInit(GP_Backend *backend,
+ GP_PixelType pixel_type, int flags);
+
+#endif /* BACKENDS_GP_BACKEND_VIRTUAL_H */
diff --git a/libs/backends/GP_BackendVirtual.c b/libs/backends/GP_BackendVirtual.c
new file mode 100644
index 0000000..b28c3cb
--- /dev/null
+++ b/libs/backends/GP_BackendVirtual.c
@@ -0,0 +1,145 @@
+/*****************************************************************************
+ * 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+
+#include "core/GP_Context.h"
+#include "core/GP_Blit.h"
+#include "core/GP_Debug.h"
+
+#include "GP_BackendVirtual.h"
+
+struct virt_priv {
+ /* Original backend */
+ GP_Backend *backend;
+
+ int flags;
+};
+
+static void virt_flip(GP_Backend *self)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+
+ /* Convert and copy the buffer */
+ GP_Blit(self->context, 0, 0, self->context->w, self->context->h,
+ virt->backend->context, 0, 0);
+
+ /* Call blit on original backend */
+ virt->backend->Flip(virt->backend);
+}
+
+static void virt_update_rect(GP_Backend *self, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+
+ /* Convert and copy the buffer */
+ GP_BlitXYXY(self->context, x0, y0, x1, y1,
+ virt->backend->context, x0, y0);
+
+ /* Call blit on original backend */
+ virt->backend->UpdateRect(virt->backend, x0, y0, x1, y1);
+}
+
+static int virt_set_attributes(struct GP_Backend *self,
+ uint32_t w, uint32_t h,
+ const char *caption)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+ int ret;
+
+ ret = virt->backend->SetAttributes(virt->backend, w, h, caption);
+
+ if (ret)
+ return ret;
+
+ /* If backend was resized, update our buffer as well */
+ if (h != 0 && w != 0)
+ GP_ContextResize(self->context, w, h);
+
+ return 0;
+}
+
+static void virt_poll(GP_Backend *self)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+
+ virt->backend->Poll(virt->backend);
+}
+
+static void virt_exit(GP_Backend *self)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+
+ GP_ContextFree(self->context);
+
+ if (virt->flags & GP_BACKEND_CALL_EXIT)
+ virt->backend->Exit(virt->backend);
+
+ free(self);
+}
+
+GP_Backend *GP_BackendVirtualInit(GP_Backend *backend,
+ GP_PixelType pixel_type, int flags)
+{
+ GP_Backend *self;
+ struct virt_priv *virt;
+
+ self = malloc(sizeof(GP_Backend) +
+ sizeof(struct virt_priv));
+
+ if (self == NULL) {
+ GP_DEBUG(1, "Malloc failed :(");
+ return NULL;
+ }
+
+ memset(self, 0, sizeof(GP_Backend));
+
+ /* Create new buffer with different context type */
+ self->context = GP_ContextAlloc(backend->context->w, backend->context->h,
+ pixel_type);
+
+ if (self->context == NULL)
+ goto err0;
+
+ virt = GP_BACKEND_PRIV(self);
+ virt->backend = backend;
+ virt->flags = flags;
+
+ /* Initalize new backend */
+ self->name = "Virtual Backend";
+ self->Flip = virt_flip;
+ self->UpdateRect = virt_update_rect;
+ self->Exit = virt_exit;
+
+ if (backend->Poll)
+ self->Poll = virt_poll;
+
+ if (backend->SetAttributes)
+ self->SetAttributes = virt_set_attributes;
+
+ return self;
+
+err0:
+ free(self);
+ return NULL;
+}
http://repo.or.cz/w/gfxprim.git/commit/bef941cfec1236983582823bf2d0b45b7c5a…
commit bef941cfec1236983582823bf2d0b45b7c5a2d10
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 18 18:51:31 2012 +0200
backends: X11: More error checking and pixel matching.
The XImage interface is _strange_ I did best effort
to match reasonable pixel type. Still not sure if this
will actually work on unexpected xserver configurations.
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index af98a67..1c5dd91 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -34,23 +34,28 @@
struct x11_priv {
Display *dpy;
int scr;
+ Screen *scr_ptr;
+ int scr_depth;
Window win;
Visual *vis;
+
XImage *img;
int resized_flag;
};
+static void destroy_ximage(GP_Backend *self);
+
+static int resize_ximage(GP_Backend *self, int w, int h);
+
static void x11_exit(GP_Backend *self)
{
struct x11_priv *x11 = GP_BACKEND_PRIV(self);
XLockDisplay(x11->dpy);
-
- GP_ContextFree(self->context);
- x11->img->data = NULL;
- XDestroyImage(x11->img);
+ destroy_ximage(self);
+
XDestroyWindow(x11->dpy, x11->win);
/* I wonder if this is right sequence... */
XUnlockDisplay(x11->dpy);
@@ -148,8 +153,6 @@ static int x11_set_attributes(struct GP_Backend *self,
}
if (w != 0 || h != 0) {
- XImage *img;
-
if (w == 0)
w = self->context->w;
@@ -157,30 +160,14 @@ static int x11_set_attributes(struct GP_Backend *self,
h = self->context->h;
GP_DEBUG(3, "Setting window size to %ux%u", w, h);
-
- /* Create new X image */
- img = XCreateImage(x11->dpy, x11->vis, 24, ZPixmap, 0, NULL,
- w, h, 32, 0);
-
- /* Allocate new context */
-
- if (GP_ContextResize(self->context, w, h)) {
- XDestroyImage(img);
+
+ if (resize_ximage(self, w, h))
return 1;
- }
-
- /* Free old image */
- x11->img->data = NULL;
- XDestroyImage(x11->img);
-
- /* Swap the pointers */
- img->data = (char*)self->context->pixels;
- x11->img = img;
/* Resize X11 window */
XResizeWindow(x11->dpy, x11->win, w, h);
XFlush(x11->dpy);
-
+
x11->resized_flag = 1;
}
@@ -189,6 +176,90 @@ static int x11_set_attributes(struct GP_Backend *self,
return 0;
}
+static int create_ximage(GP_Backend *self, GP_Size w, GP_Size h)
+{
+ struct x11_priv *x11 = GP_BACKEND_PRIV(self);
+ int depth;
+ enum GP_PixelType pixel_type;
+
+ /*
+ * Eh, the XImage supports either 8, 16 or 32 bit pixels
+ *
+ * Do best effor on selecting appropriate pixel type
+ */
+ for (depth = 8; depth <= 32; depth<<=1) {
+ pixel_type = GP_PixelRGBMatch(x11->vis->red_mask,
+ x11->vis->green_mask,
+ x11->vis->blue_mask,
+ 0x0, depth);
+
+ if (pixel_type != GP_PIXEL_UNKNOWN)
+ break;
+ }
+
+ if (pixel_type == GP_PIXEL_UNKNOWN) {
+ GP_DEBUG(1, "Unknown pixel type");
+ return 1;
+ }
+
+ self->context = GP_ContextAlloc(w, h, pixel_type);
+
+ if (self->context == NULL)
+ return 1;
+
+ x11->img = XCreateImage(x11->dpy, x11->vis, x11->scr_depth, ZPixmap, 0,
+ NULL, w, h, depth, 0);
+
+ if (x11->img == NULL) {
+ GP_DEBUG(1, "Failed to create XImage");
+ GP_ContextFree(self->context);
+ return 1;
+ }
+
+ x11->img->data = (char*)self->context->pixels;
+ return 0;
+}
+
+static void destroy_ximage(GP_Backend *self)
+{
+ struct x11_priv *x11 = GP_BACKEND_PRIV(self);
+
+ GP_ContextFree(self->context);
+ x11->img->data = NULL;
+ XDestroyImage(x11->img);
+}
+
+static int resize_ximage(GP_Backend *self, int w, int h)
+{
+ struct x11_priv *x11 = GP_BACKEND_PRIV(self);
+ XImage *img;
+
+ /* Create new X image */
+ img = XCreateImage(x11->dpy, x11->vis, x11->scr_depth, ZPixmap, 0, NULL,
+ w, h, x11->img->bitmap_pad, 0);
+
+ if (img == NULL) {
+ GP_DEBUG(2, "XCreateImage failed");
+ return 1;
+ }
+
+ /* Resize context */
+ if (GP_ContextResize(self->context, w, h)) {
+ XDestroyImage(img);
+ return 1;
+ }
+
+ /* Free old image */
+ x11->img->data = NULL;
+ XDestroyImage(x11->img);
+
+ /* Swap the pointers */
+ img->data = (char*)self->context->pixels;
+ x11->img = img;
+
+ return 0;
+}
+
GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
unsigned int w, unsigned int h,
const char *caption)
@@ -197,6 +268,11 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
struct x11_priv *x11;
GP_DEBUG(1, "Initalizing X11 display '%s'", display);
+
+ if (!XInitThreads()) {
+ GP_DEBUG(2, "XInitThreads failed");
+ return NULL;
+ }
backend = malloc(sizeof(GP_Backend) +
sizeof(struct x11_priv));
@@ -206,30 +282,24 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
x11 = GP_BACKEND_PRIV(backend);
- backend->context = GP_ContextAlloc(w, h, GP_PIXEL_xRGB8888);
-
- if (backend->context == NULL)
- goto err0;
-
- //TODO: Error checking
- XInitThreads();
-
x11->dpy = XOpenDisplay(display);
if (x11->dpy == NULL)
- goto err1;
+ goto err0;
x11->scr = DefaultScreen(x11->dpy);
x11->vis = DefaultVisual(x11->dpy, x11->scr);
+ x11->scr_ptr = DefaultScreenOfDisplay(x11->dpy);
+ x11->scr_depth = DefaultDepthOfScreen(x11->scr_ptr);
+
+ GP_DEBUG(2, "Have Visual id %i, depth %u", (int)x11->vis->visualid, x11->scr_depth);
+
+ if (create_ximage(backend, w, h))
+ goto err1;
GP_DEBUG(2, "Opening window '%s' %ix%i-%ux%u",
caption, x, y, w, h);
- x11->img = XCreateImage(x11->dpy, x11->vis, 24, ZPixmap, 0, NULL,
- w, h, 32, 0);
-
- x11->img->data = (char*)backend->context->pixels;
-
x11->win = XCreateWindow(x11->dpy, DefaultRootWindow(x11->dpy),
x, y, w, h, 0, CopyFromParent,
InputOutput, CopyFromParent, 0, NULL);
@@ -257,22 +327,6 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
x11->resized_flag = 0;
-/*
- enum GP_PixelType pixel_type;
- pixel_type = GP_PixelRGBLookup(vscri.red.length, vscri.red.offset,
- vscri.green.length, vscri.green.offset,
- vscri.blue.length, vscri.blue.offset,
- vscri.transp.length, vscri.transp.offset,
- vscri.bits_per_pixel);
-
- if (pixel_type == GP_PIXEL_UNKNOWN) {
- GP_DEBUG(1, "Unknown pixel typen");
- goto err3;
- }
-
-
-*/
-
backend->name = "X11";
backend->Flip = x11_flip;
backend->UpdateRect = x11_update_rect;
@@ -281,14 +335,11 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
backend->Poll = x11_poll;
backend->SetAttributes = x11_set_attributes;
-
return backend;
-//err3:
-// XDestroyWindow(x11->dpy, x11->win);
err2:
- XCloseDisplay(x11->dpy);
+ destroy_ximage(backend);
err1:
- GP_ContextFree(backend->context);
+ XCloseDisplay(x11->dpy);
err0:
free(backend);
return NULL;
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 15 ++-
include/backends/{GP_X11.h => GP_BackendVirtual.h} | 32 +++--
include/core/GP_Pixel.h | 7 +-
libs/backends/GP_BackendVirtual.c | 145 +++++++++++++++++
libs/backends/GP_X11.c | 171 +++++++++++++-------
libs/core/GP_Pixel.c | 13 ++-
6 files changed, 308 insertions(+), 75 deletions(-)
copy include/backends/{GP_X11.h => GP_BackendVirtual.h} (74%)
create mode 100644 libs/backends/GP_BackendVirtual.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0