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/ce280e141cd211cffe37af58fe420428740ae...
commit ce280e141cd211cffe37af58fe420428740ae7ba Author: Cyril Hrubis metan@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/e927ca0d6dbde34dc5ac7beda7a8665f8e4f1...
commit e927ca0d6dbde34dc5ac7beda7a8665f8e4f1bdd Author: Cyril Hrubis metan@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/1b8274d61463a47398e4100fc554ed8fa9b03...
commit 1b8274d61463a47398e4100fc554ed8fa9b0366b Author: Cyril Hrubis metan@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@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@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@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@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/648c8a5e14dc4159ed1cb65199b9ec7fb4711...
commit 648c8a5e14dc4159ed1cb65199b9ec7fb47116c6 Author: Cyril Hrubis metan@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@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.