Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 929 discussions
[repo.or.cz] gfxprim.git branch master updated: 965a9237db419f83183eb4a59fc9bc741782093e
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 965a9237db419f83183eb4a59fc9bc741782093e (commit)
from e403e7ee1b9adba8f821a623d862a03ac7afc941 (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/965a9237db419f83183eb4a59fc9bc741782…
commit 965a9237db419f83183eb4a59fc9bc741782093e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 27 15:26:29 2012 +0200
loaders: Use png_set_packswap() (to reduce size of code).
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 2afb072..742cf46 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -200,7 +200,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
}
if (color_type == PNG_COLOR_TYPE_GRAY)
- res->bit_endian = 1;
+ png_set_packswap(png);
uint32_t y;
@@ -305,48 +305,23 @@ static int prepare_png_header(const GP_Context *src, png_structp png,
return 0;
}
-static int write_png_data_g_swap(const GP_Context *src, png_structp png,
- GP_ProgressCallback *callback)
+static int write_png_data(const GP_Context *src, png_structp png,
+ GP_ProgressCallback *callback, int bit_endian_flag)
{
- unsigned int y;
- uint8_t row[src->bytes_per_row];
-
- for (y = 0; y < src->h; y++) {
- memcpy(row, GP_PIXEL_ADDR(src, 0, y), src->bytes_per_row);
-
+ /* Look if we need to swap data when writing */
+ if (bit_endian_flag) {
switch (src->pixel_type) {
case GP_PIXEL_G1:
- GP_BitSwapRow_B1(row, src->bytes_per_row);
- break;
case GP_PIXEL_G2:
- GP_BitSwapRow_B4(row, src->bytes_per_row);
- break;
case GP_PIXEL_G4:
- GP_BitSwapRow_B4(row, src->bytes_per_row);
+ png_set_packswap(png);
break;
default:
return ENOSYS;
break;
}
-
- png_write_row(png, row);
-
- if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) {
- GP_DEBUG(1, "Operation aborted");
- return ECANCELED;
- }
}
- return 0;
-}
-
-static int write_png_data(const GP_Context *src, png_structp png,
- GP_ProgressCallback *callback, int bit_endian_flag)
-{
- /* Look if we need to swap data when writing */
- if (bit_endian_flag)
- return write_png_data_g_swap(src, png, callback);
-
unsigned int y;
for (y = 0; y < src->h; y++) {
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_PNG.c | 37 ++++++-------------------------------
1 files changed, 6 insertions(+), 31 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: e403e7ee1b9adba8f821a623d862a03ac7afc941
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 e403e7ee1b9adba8f821a623d862a03ac7afc941 (commit)
from adef520463dc58869ba1570a8d5cd05b7691091a (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/e403e7ee1b9adba8f821a623d862a03ac7af…
commit e403e7ee1b9adba8f821a623d862a03ac7afc941
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 27 14:51:17 2012 +0200
loaders: Set bit endian flag on grayscale PNG load.
* The 1BPP_BE 2BPP_BE and 4BPP_BE blits doesn't work yet, ugh :(
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 3e8d6de..2afb072 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -199,6 +199,9 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
goto err2;
}
+ if (color_type == PNG_COLOR_TYPE_GRAY)
+ res->bit_endian = 1;
+
uint32_t y;
/* start the actuall reading */
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_PNG.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: adef520463dc58869ba1570a8d5cd05b7691091a
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 adef520463dc58869ba1570a8d5cd05b7691091a (commit)
from f278f7d7683d97876757877353550e431700d180 (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/adef520463dc58869ba1570a8d5cd05b7691…
commit adef520463dc58869ba1570a8d5cd05b7691091a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 27 14:40:52 2012 +0200
spiv: Move the resampling workaround to a correct place.
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 77c3bc4..91b9f35 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -152,6 +152,14 @@ int load_image(struct loader_params *params)
GP_BackendFlip(backend);
return 1;
}
+
+ /* Workaround */
+ if (img->pixel_type != GP_PIXEL_RGB888) {
+ GP_Context *tmp = GP_ContextConvert(img, GP_PIXEL_RGB888);
+ GP_ContextFree(img);
+ img = tmp;
+ }
+
cpu_timer_stop(&timer);
params->img = img;
@@ -221,13 +229,6 @@ static void *image_loader(void *ptr)
w = img->w;
h = img->h;
- /* Workaround */
- if (img->pixel_type != GP_PIXEL_RGB888) {
- GP_Context *tmp = GP_ContextConvert(img, GP_PIXEL_RGB888);
- GP_ContextFree(img);
- img = tmp;
- }
-
GP_Context *ret;
/* Do low pass filter */
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: f278f7d7683d97876757877353550e431700d180
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 f278f7d7683d97876757877353550e431700d180 (commit)
via fae0a3810bc628f5e72e5e3147ccbb5b24f010e6 (commit)
via 0fca9291826bed0f81d3583c7785260ef051eb25 (commit)
from c404e7e68b3d6567519cb2fcb45ea5fc652add35 (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/f278f7d7683d97876757877353550e431700…
commit f278f7d7683d97876757877353550e431700d180
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 27 14:32:55 2012 +0200
examples: Add simple python dithering example
diff --git a/demos/py_simple/dither.py b/demos/py_simple/dither.py
new file mode 100755
index 0000000..dae8838
--- /dev/null
+++ b/demos/py_simple/dither.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+import sys
+
+import gfxprim.core as core
+import gfxprim.loaders as loaders
+import gfxprim.filters as filters
+
+def main():
+ if len(sys.argv) != 2:
+ print("usage: dither.py image")
+ sys.exit(1)
+
+ # Load Image
+ img = loaders.LoadImage(sys.argv[1], None)
+ # Use Floyd-Steinberg dithering
+ res = filters.FilterFloydSteinberg_RGB888_Alloc(img, core.C.PIXEL_G1, None)
+ # Save result into grayscale png
+ loaders.SavePNG(res, "out.png", None)
+
+if __name__ == '__main__':
+ main()
http://repo.or.cz/w/gfxprim.git/commit/fae0a3810bc628f5e72e5e3147ccbb5b24f0…
commit fae0a3810bc628f5e72e5e3147ccbb5b24f010e6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 27 14:31:25 2012 +0200
loaders: Add support for sawing Grayscale PNGs.
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 381039c..3e8d6de 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -41,6 +41,8 @@
#include <png.h>
+#include "core/GP_BitSwap.h"
+
int GP_OpenPNG(const char *src_path, FILE **f)
{
uint8_t sig[8];
@@ -235,6 +237,128 @@ GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback)
return GP_ReadPNG(f, callback);
}
+/*
+ * Maps gfxprim Pixel Type to the PNG format
+ */
+static int prepare_png_header(const GP_Context *src, png_structp png,
+ png_infop png_info, int *bit_endian_flag)
+{
+ int bit_depth, color_type;
+
+ switch (src->pixel_type) {
+ case GP_PIXEL_BGR888:
+ case GP_PIXEL_RGB888:
+ bit_depth = 8;
+ color_type = PNG_COLOR_TYPE_RGB;
+ break;
+ case GP_PIXEL_G1:
+ bit_depth = 1;
+ color_type = PNG_COLOR_TYPE_GRAY;
+ break;
+ case GP_PIXEL_G2:
+ bit_depth = 2;
+ color_type = PNG_COLOR_TYPE_GRAY;
+ break;
+ case GP_PIXEL_G4:
+ bit_depth = 4;
+ color_type = PNG_COLOR_TYPE_GRAY;
+ break;
+ case GP_PIXEL_G8:
+ bit_depth = 8;
+ color_type = PNG_COLOR_TYPE_GRAY;
+ break;
+ default:
+ return 1;
+ break;
+ }
+
+ /* If pointers weren't passed, just return it is okay */
+ if (png == NULL || png_info == NULL)
+ return 0;
+
+ png_set_IHDR(png, png_info, src->w, src->h, bit_depth, color_type,
+ PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
+ PNG_FILTER_TYPE_DEFAULT);
+
+ /* start the actuall writing */
+ png_write_info(png, png_info);
+
+ //png_set_packing(png);
+
+ /* prepare for format conversion */
+ switch (src->pixel_type) {
+ case GP_PIXEL_RGB888:
+ png_set_bgr(png);
+ break;
+ case GP_PIXEL_G1:
+ case GP_PIXEL_G2:
+ case GP_PIXEL_G4:
+ *bit_endian_flag = !src->bit_endian;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static int write_png_data_g_swap(const GP_Context *src, png_structp png,
+ GP_ProgressCallback *callback)
+{
+ unsigned int y;
+ uint8_t row[src->bytes_per_row];
+
+ for (y = 0; y < src->h; y++) {
+ memcpy(row, GP_PIXEL_ADDR(src, 0, y), src->bytes_per_row);
+
+ switch (src->pixel_type) {
+ case GP_PIXEL_G1:
+ GP_BitSwapRow_B1(row, src->bytes_per_row);
+ break;
+ case GP_PIXEL_G2:
+ GP_BitSwapRow_B4(row, src->bytes_per_row);
+ break;
+ case GP_PIXEL_G4:
+ GP_BitSwapRow_B4(row, src->bytes_per_row);
+ break;
+ default:
+ return ENOSYS;
+ break;
+ }
+
+ png_write_row(png, row);
+
+ if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) {
+ GP_DEBUG(1, "Operation aborted");
+ return ECANCELED;
+ }
+ }
+
+ return 0;
+}
+
+static int write_png_data(const GP_Context *src, png_structp png,
+ GP_ProgressCallback *callback, int bit_endian_flag)
+{
+ /* Look if we need to swap data when writing */
+ if (bit_endian_flag)
+ return write_png_data_g_swap(src, png, callback);
+
+ unsigned int y;
+
+ for (y = 0; y < src->h; y++) {
+ png_bytep row = GP_PIXEL_ADDR(src, 0, y);
+ png_write_row(png, row);
+
+ if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) {
+ GP_DEBUG(1, "Operation aborted");
+ return ECANCELED;
+ }
+ }
+
+ return 0;
+}
+
int GP_SavePNG(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
@@ -245,8 +369,8 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path,
GP_DEBUG(1, "Saving PNG Image '%s'", dst_path);
- if (src->pixel_type != GP_PIXEL_RGB888) {
- GP_DEBUG(1, "Can't save png with pixel type %s",
+ if (prepare_png_header(src, NULL, NULL, NULL)) {
+ GP_DEBUG(1, "Can't save png with %s pixel type",
GP_PixelTypeName(src->pixel_type));
return ENOSYS;
}
@@ -284,27 +408,14 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path,
}
png_init_io(png, f);
- png_set_IHDR(png, png_info, src->w, src->h, 8, PNG_COLOR_TYPE_RGB,
- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
- PNG_FILTER_TYPE_DEFAULT);
-
- /* start the actuall writing */
- png_write_info(png, png_info);
- png_set_bgr(png);
-
- uint32_t y;
-
- for (y = 0; y < src->h; y++) {
- png_bytep row = GP_PIXEL_ADDR(src, 0, y);
- png_write_row(png, row);
+
+ int bit_endian_flag = 0;
+ /* Fill png header and prepare for data */
+ prepare_png_header(src, png, png_info, &bit_endian_flag);
- if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) {
- GP_DEBUG(1, "Operation aborted");
- err = ECANCELED;
- goto err3;
- }
-
- }
+ /* Write bitmap buffer */
+ if ((err = write_png_data(src, png, callback, bit_endian_flag)))
+ goto err3;
png_write_end(png, png_info);
png_destroy_write_struct(&png, &png_info);
http://repo.or.cz/w/gfxprim.git/commit/0fca9291826bed0f81d3583c7785260ef051…
commit 0fca9291826bed0f81d3583c7785260ef051eb25
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 27 14:29:35 2012 +0200
core: Add bit swap helpers.
diff --git a/include/core/GP_BitSwap.h b/include/core/GP_BitSwap.h
new file mode 100644
index 0000000..5ad76ad
--- /dev/null
+++ b/include/core/GP_BitSwap.h
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * 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) 2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+ /*
+
+ Inline functions for swapping bits inside of the byte
+
+ */
+
+#ifndef CORE_GP_BIT_SWAP_H
+#define CORE_GP_BIT_SWAP_H
+
+/*
+ * Reverse 1 bit blocks in the byte.
+ *
+ * Example:
+ *
+ * IN 10101110
+ * OUT 01110101
+ */
+static inline uint8_t GP_BIT_SWAP_B1(uint8_t byte)
+{
+ return ((byte * 0x0802LU & 0x22110LU) |
+ (byte * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
+}
+
+static inline void GP_BitSwapRow_B1(uint8_t *row, unsigned int len)
+{
+ unsigned int i;
+
+ for (i = 0; i < len; i++)
+ row[i] = GP_BIT_SWAP_B1(row[i]);
+}
+
+/*
+ * Reverse 2 bit blocks in the byte.
+ *
+ * Example:
+ *
+ * IN 10 11 01 00
+ * OUT 00 01 11 10
+ */
+static inline uint8_t GP_BIT_SWAP_B2(uint8_t byte)
+{
+ return ((byte & 0xC0) >> 6) | ((byte & 0x30) >> 2) |
+ ((byte & 0x0C) << 2) | ((byte & 0x03) << 6);
+}
+
+static inline void GP_BitSwapRow_B2(uint8_t *row, unsigned int len)
+{
+ unsigned int i;
+
+ for (i = 0; i < len; i++)
+ row[i] = GP_BIT_SWAP_B2(row[i]);
+}
+
+/*
+ * Reverse 4 bit blocks in the byte.
+ *
+ * Example:
+ *
+ * IN 1011 0100
+ * OUT 0100 1011
+ */
+static inline uint8_t GP_BIT_SWAP_B4(uint8_t byte)
+{
+ return ((byte & 0xf0) >> 4) | ((byte & 0x0f) << 4);
+}
+
+static inline void GP_BitSwapRow_B4(uint8_t *row, unsigned int len)
+{
+ unsigned int i;
+
+ for (i = 0; i < len; i++)
+ row[i] = GP_BIT_SWAP_B4(row[i]);
+}
+
+#endif /* CORE_GP_BIT_SWAP_H */
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/dither.py | 21 +++
.../GP_GetPutPixel.c => include/core/GP_BitSwap.h | 80 ++++++++--
libs/loaders/GP_PNG.c | 155 +++++++++++++++++---
3 files changed, 219 insertions(+), 37 deletions(-)
create mode 100755 demos/py_simple/dither.py
copy libs/core/GP_GetPutPixel.c => include/core/GP_BitSwap.h (55%)
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: 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