ucw.cz
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
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
List overview
Download
Gfxprim
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
gfxprim@ucw.cz
929 discussions
Start a n
N
ew thread
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc0-201-gec015ac
by metan
27 Sep '13
27 Sep '13
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git. The branch, master has been updated via ec015ac1774ec0b833b2c9206f924361f897e20d (commit) from 0bd5967d27831f240bd4e401332ef494d94f60c5 (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/ec015ac1774ec0b833b2c9206f924361f897…
commit ec015ac1774ec0b833b2c9206f924361f897e20d Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 23:52:23 2013 +0200 doc: filters: regen.py: Add names to the filter params. Now the example images description includes id= for each filter parameter value. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/doc/images/blur/images.txt b/doc/images/blur/images.txt index 74697da..2c0d697 100644 --- a/doc/images/blur/images.txt +++ b/doc/images/blur/images.txt @@ -1,4 +1,4 @@ -.Example Images: Original Image; Gaussian Blur 2 2, 0 4, 4 0, 4 4, 10 10 +.Original Image; Gaussian Blur xsig=2 ysig=2, xsig=0 ysig=4, xsig=4 ysig=0, xsig=4 ysig=4, xsig=10 ysig=10 image:images/orig/lenna_small.png[ "Original Image", link="images/orig/lenna.png"] diff --git a/doc/images/edge_sharpening/images.txt b/doc/images/edge_sharpening/images.txt index 8066f2e..58c3636 100644 --- a/doc/images/edge_sharpening/images.txt +++ b/doc/images/edge_sharpening/images.txt @@ -1,4 +1,4 @@ -.Example Images: Original Image; Edge Sharpening 0.1, 0.3, 0.5, 0.8, 1.0 +.Original Image; Edge Sharpening w=0.1, w=0.3, w=0.5, w=0.8, w=1.0 image:images/orig/lenna_small.png[ "Original Image", link="images/orig/lenna.png"] diff --git a/doc/images/gaussian_noise/images.txt b/doc/images/gaussian_noise/images.txt index 6304c7a..a173f04 100644 --- a/doc/images/gaussian_noise/images.txt +++ b/doc/images/gaussian_noise/images.txt @@ -1,4 +1,4 @@ -.Example Images: Original Image; Gaussian Additive Noise 0.03 0, 0.05 0, 0.05 -0.1, 0.05 0.1, 0.07 0.0 +.Original Image; Gaussian Additive Noise s=0.03 m=0, s=0.05 m=0, s=0.05 m=-0.1, s=0.05 m=0.1, s=0.07 m=0.0 image:images/orig/lenna_small.png[ "Original Image", link="images/orig/lenna.png"] diff --git a/doc/images/median/images.txt b/doc/images/median/images.txt index 968ef8a..f656ca8 100644 --- a/doc/images/median/images.txt +++ b/doc/images/median/images.txt @@ -1,4 +1,4 @@ -.Example Images: Original Image; Median 3 3, 5 5, 7 7, 9 9, 12 12 +.Original Image; Median xr=3 yr=3, xr=5 yr=5, xr=7 yr=7, xr=9 yr=9, xr=12 yr=12 image:images/orig/lenna_small.png[ "Original Image", link="images/orig/lenna.png"] diff --git a/doc/images/regen.py b/doc/images/regen.py index b1a8788..8a705f7 100755 --- a/doc/images/regen.py +++ b/doc/images/regen.py @@ -16,7 +16,7 @@ class ImgGen: def write_asciidoc_head(self, dst_path, heading): self.f = open('../' + dst_path + 'images.txt', 'w') f = self.f - f.write('.Example Images: Original Image; ' + heading + 'n') + f.write('.Original Image; ' + heading + 'n') f.write('image:' + self.orig_path + 'lenna_small.png[n') f.write('t"Original Image",n') f.write('tlink="' + self.orig_path + 'lenna.png"]n') @@ -31,12 +31,13 @@ class ImgGen: self.f.write('n') self.f.close() - def gen(self, func, func_params_arr, dst_path, func_name): + def gen(self, func, func_param_desc, func_params_arr, dst_path, func_name): print("Generating " + func_name) self.write_asciidoc_head(dst_path, func_name + ' ' + - ', '.join(map(lambda x: ' '.join([str(i) for i in x]), func_params_arr))) + ', '.join(map(lambda x: ' '.join([func_param_desc[i] + '=' + + str(x[i]) for i in range(0, len(x))]), func_params_arr))) for i in func_params_arr: str_i = [str(x) for x in i] @@ -60,19 +61,19 @@ class ImgGen: def main(): imggen = ImgGen('images/orig/') - imggen.gen(filters.GaussianBlurAlloc, + imggen.gen(filters.GaussianBlurAlloc, ['xsig', 'ysig'], [[2, 2], [0, 4], [4, 0], [4, 4], [10, 10]], 'images/blur/', 'Gaussian Blur') - imggen.gen(filters.MedianAlloc, + imggen.gen(filters.MedianAlloc, ['xr', 'yr'], [[3, 3], [5, 5], [7, 7], [9, 9], [12, 12]], 'images/median/', 'Median') - imggen.gen(filters.EdgeSharpeningAlloc, + imggen.gen(filters.EdgeSharpeningAlloc, ['w'], [[0.1], [0.3], [0.5], [0.8], [1.0]], 'images/edge_sharpening/', 'Edge Sharpening') - imggen.gen(filters.GaussianNoiseAddAlloc, + imggen.gen(filters.GaussianNoiseAddAlloc, ['s', 'm'], [[0.03, 0], [0.05, 0], [0.05, -0.1], [0.05, 0.1], [0.07, 0.0]], 'images/gaussian_noise/', 'Gaussian Additive Noise') ----------------------------------------------------------------------- Summary of changes: doc/images/blur/images.txt | 2 +- doc/images/edge_sharpening/images.txt | 2 +- doc/images/gaussian_noise/images.txt | 2 +- doc/images/median/images.txt | 2 +- doc/images/regen.py | 15 ++++++++------- 5 files changed, 12 insertions(+), 11 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
0
0
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc0-200-g0bd5967
by metan
27 Sep '13
27 Sep '13
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git. The branch, master has been updated via 0bd5967d27831f240bd4e401332ef494d94f60c5 (commit) from b0ae037dbd8678fe2eade3de055b7d120b6dc8d9 (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/0bd5967d27831f240bd4e401332ef494d94f…
commit 0bd5967d27831f240bd4e401332ef494d94f60c5 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 23:38:33 2013 +0200 doc: filters: Generate Gaussian noise example imgs * Generate gaussian noise example images * Update filters and python filters docs accordingly Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/doc/Makefile b/doc/Makefile index 8c2aca6..c07d94a 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -32,7 +32,7 @@ $(PAGES): asciidoc.conf # Dependencies # IMG_INCLUDES=images/blur/images.txt images/median/images.txt- images/edge_sharpening/images.txt + images/edge_sharpening/images.txt images/gaussian_noise/images.txt filters_python.html: $(IMG_INCLUDES) filters.html: $(IMG_INCLUDES) @@ -61,8 +61,6 @@ $(PAGES): %.html: %.txt examples.html: examples.txt ../demos/c_simple/*.c ../demos/py_simple/*.py asciidoc.conf asciidoc $(ASCIIDOC_PARAMS) -a toc examples.txt -filters.html: filter_additive_gaussian_noise.txt - # # Clean up generated images # diff --git a/doc/filter_additive_gaussian_noise.txt b/doc/filter_additive_gaussian_noise.txt deleted file mode 100644 index 8acba98..0000000 --- a/doc/filter_additive_gaussian_noise.txt +++ /dev/null @@ -1,66 +0,0 @@ -Gaussian additive noise filter -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -[source,c] -------------------------------------------------------------------------------- -#include <GP_Filters.h> -/* or */ -#include <filters/GP_GaussianNoise.h> - -int GP_FilterGaussianNoiseAddEx(const GP_Context *src, - GP_Coord x_src, GP_Coord y_src, - GP_Size w_src, GP_Size h_src, - GP_Context *dst, - GP_Coord x_dst, GP_Coord y_dst, - float sigma, float mu, - GP_ProgressCallback *callback); - -GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src, - GP_Coord x_src, GP_Coord y_src, - GP_Size w_src, GP_Size h_src, - float sigma, float mu, - GP_ProgressCallback *callback); - -static inline int GP_FilterGaussianNoiseAdd(const GP_Context *src, - GP_Context *dst, - float sigma, float mu, - GP_ProgressCallback *callback); - -static inline GP_Context * -GP_FilterGaussianNoiseAddAlloc(const GP_Context *src, - float sigma, float mu, - GP_ProgressCallback *callback); -------------------------------------------------------------------------------- - -Gaussian additive noise filter adds gaussian distributed noise to an image -with a defined sigma and mu. Both sigma and mu are from [0,1] interval. - -TIP: See the link:example_gaussian_noise.html[source code] used to generate - following images. - -.Original Image; Gaussian Additive Noise s=0.01, s=0.02, s=0.05, s=0.7, s=0.1, s=0.05 m=0.1, s=0.05 m=-0.1 -image:images/dither/lenna_small.png[ - "Original Image", - link="images/dither/lenna.png"] -image:images/gaussian_noise/lenna_small_noise_s_0_01_m_0.png[ - "Additive Noise sigma = 0.01 mu = 0.0", - link="images/gaussian_noise/lenna_noise_s_0_01_m_0.png"] -image:images/gaussian_noise/lenna_small_noise_s_0_02_m_0.png[ - "Additive Noise sigma = 0.02 mu = 0.0", - link="images/gaussian_noise/lenna_noise_s_0_02_m_0.png"] -image:images/gaussian_noise/lenna_small_noise_s_0_05_m_0.png[ - "Additive Noise sigma = 0.05 mu = 0.0", - link="images/gaussian_noise/lenna_noise_s_0_05_m_0.png"] -image:images/gaussian_noise/lenna_small_noise_s_0_07_m_0.png[ - "Additive Noise sigma = 0.07 mu = 0.0", - link="images/gaussian_noise/lenna_noise_s_0_07_m_0.png"] -image:images/gaussian_noise/lenna_small_noise_s_0_1_m_0.png[ - "Additive Noise sigma = 0.1 mu = 0.0", - link="images/gaussian_noise/lenna_noise_s_0_1_m_0.png"] -image:images/gaussian_noise/lenna_small_noise_s_0_05_m_0_1.png[ - "Additive Noise sigma = 0.1 mu = 0.1", - link="images/gaussian_noise/lenna_noise_s_0_05_m_0_1.png"] -image:images/gaussian_noise/lenna_small_noise_s_0_05_m_-0_1.png[ - "Additive Noise sigma = 0.1 mu = -0.1", - link="images/gaussian_noise/lenna_noise_s_0_05_m_-0_1.png"] - diff --git a/doc/filters.txt b/doc/filters.txt index c7ed191..ed39486 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -253,7 +253,47 @@ GP_Context *GP_FilterInvert(const GP_Context *src, GP_Context *dst, Inverts the image, for each channel the result value is computed as "chan_max - val". -include::filter_additive_gaussian_noise.txt[] +Gaussian additive noise filter +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +[source,c] +------------------------------------------------------------------------------- +#include <GP_Filters.h> +/* or */ +#include <filters/GP_GaussianNoise.h> + +int GP_FilterGaussianNoiseAddEx(const GP_Context *src, + GP_Coord x_src, GP_Coord y_src, + GP_Size w_src, GP_Size h_src, + GP_Context *dst, + GP_Coord x_dst, GP_Coord y_dst, + float sigma, float mu, + GP_ProgressCallback *callback); + +GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src, + GP_Coord x_src, GP_Coord y_src, + GP_Size w_src, GP_Size h_src, + float sigma, float mu, + GP_ProgressCallback *callback); + +static inline int GP_FilterGaussianNoiseAdd(const GP_Context *src, + GP_Context *dst, + float sigma, float mu, + GP_ProgressCallback *callback); + +static inline GP_Context * +GP_FilterGaussianNoiseAddAlloc(const GP_Context *src, + float sigma, float mu, + GP_ProgressCallback *callback); +------------------------------------------------------------------------------- + +Gaussian additive noise filter adds gaussian distributed noise to an image +with a defined sigma and mu. Both sigma and mu weights mapped to [0,1] +interval. + +TIP: See the link:example_gaussian_noise.html[gaussian noise example]. + +include::images/gaussian_noise/images.txt[] Arithmetic filters ~~~~~~~~~~~~~~~~~~ diff --git a/doc/filters_python.txt b/doc/filters_python.txt index f29cb44..db7eb9d 100644 --- a/doc/filters_python.txt +++ b/doc/filters_python.txt @@ -11,6 +11,27 @@ image is passed automatically as a first parameter. If filter has been aborted from callback 'OSError' with 'errno' set to 'ECANCELED' is raised. +Gaussian Additive Noise +~~~~~~~~~~~~~~~~~~~~~~~ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Adds Gaussian noise in-place with sigma=0.2 mu=0.0 + filters.GaussianNoiseAdd(img, img, 0.2, 0.0, callback=None) + + # Returns newly allocated noisy image + res = img.filters.GaussianNoiseAddAlloc(0.2, 0.0, callback=None) + +------------------------------------------------------------------------------- + +Gaussian additive noise filter adds gaussian distributed noise to an image +with a defined sigma and mu. Both sigma and mu weights mapped to '[0,1]' +interval. + +include::images/gaussian_noise/images.txt[] Laplacian Edge Sharpening ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/images/Makefile b/doc/images/Makefile index adc0fe2..76c4501 100644 --- a/doc/images/Makefile +++ b/doc/images/Makefile @@ -1,4 +1,4 @@ -SUBDIRS=blur median edge_sharpening +SUBDIRS=blur median edge_sharpening gaussian_noise TARGETS=$(addsuffix /images.txt,$(SUBDIRS)) IMGS=$(addsuffix /*.png,$(SUBDIRS)) diff --git a/doc/images/gaussian_noise/images.txt b/doc/images/gaussian_noise/images.txt new file mode 100644 index 0000000..6304c7a --- /dev/null +++ b/doc/images/gaussian_noise/images.txt @@ -0,0 +1,20 @@ +.Example Images: Original Image; Gaussian Additive Noise 0.03 0, 0.05 0, 0.05 -0.1, 0.05 0.1, 0.07 0.0 +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/gaussian_noise/lenna_small_0.03_0.png[ + "Gaussian Additive Noise 0.03 0", + link="images/gaussian_noise/lenna_0.03_0.png"] +image:images/gaussian_noise/lenna_small_0.05_0.png[ + "Gaussian Additive Noise 0.05 0", + link="images/gaussian_noise/lenna_0.05_0.png"] +image:images/gaussian_noise/lenna_small_0.05_-0.1.png[ + "Gaussian Additive Noise 0.05 -0.1", + link="images/gaussian_noise/lenna_0.05_-0.1.png"] +image:images/gaussian_noise/lenna_small_0.05_0.1.png[ + "Gaussian Additive Noise 0.05 0.1", + link="images/gaussian_noise/lenna_0.05_0.1.png"] +image:images/gaussian_noise/lenna_small_0.07_0.0.png[ + "Gaussian Additive Noise 0.07 0.0", + link="images/gaussian_noise/lenna_0.07_0.0.png"] + diff --git a/doc/images/gaussian_noise/lenna_0.03_0.png b/doc/images/gaussian_noise/lenna_0.03_0.png new file mode 100644 index 0000000..37cc9f1 Binary files /dev/null and b/doc/images/gaussian_noise/lenna_0.03_0.png differ diff --git a/doc/images/gaussian_noise/lenna_0.05_-0.1.png b/doc/images/gaussian_noise/lenna_0.05_-0.1.png new file mode 100644 index 0000000..94c3474 Binary files /dev/null and b/doc/images/gaussian_noise/lenna_0.05_-0.1.png differ diff --git a/doc/images/gaussian_noise/lenna_0.05_0.1.png b/doc/images/gaussian_noise/lenna_0.05_0.1.png new file mode 100644 index 0000000..8b65db7 Binary files /dev/null and b/doc/images/gaussian_noise/lenna_0.05_0.1.png differ diff --git a/doc/images/gaussian_noise/lenna_0.05_0.png b/doc/images/gaussian_noise/lenna_0.05_0.png new file mode 100644 index 0000000..3564844 Binary files /dev/null and b/doc/images/gaussian_noise/lenna_0.05_0.png differ diff --git a/doc/images/gaussian_noise/lenna_0.07_0.0.png b/doc/images/gaussian_noise/lenna_0.07_0.0.png new file mode 100644 index 0000000..9fce1bf Binary files /dev/null and b/doc/images/gaussian_noise/lenna_0.07_0.0.png differ diff --git a/doc/images/gaussian_noise/lenna_noise_s_0_01_m_0.png b/doc/images/gaussian_noise/lenna_noise_s_0_01_m_0.png deleted file mode 100644 index bc12a44..0000000 Binary files a/doc/images/gaussian_noise/lenna_noise_s_0_01_m_0.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_noise_s_0_05_m_-0_1.png b/doc/images/gaussian_noise/lenna_noise_s_0_05_m_-0_1.png deleted file mode 100644 index ae7fa9d..0000000 Binary files a/doc/images/gaussian_noise/lenna_noise_s_0_05_m_-0_1.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_noise_s_0_05_m_0.png b/doc/images/gaussian_noise/lenna_noise_s_0_05_m_0.png deleted file mode 100644 index e62bfa1..0000000 Binary files a/doc/images/gaussian_noise/lenna_noise_s_0_05_m_0.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_noise_s_0_05_m_0_1.png b/doc/images/gaussian_noise/lenna_noise_s_0_05_m_0_1.png deleted file mode 100644 index 61cc142..0000000 Binary files a/doc/images/gaussian_noise/lenna_noise_s_0_05_m_0_1.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_noise_s_0_07_m_0.png b/doc/images/gaussian_noise/lenna_noise_s_0_07_m_0.png deleted file mode 100644 index bc33cbe..0000000 Binary files a/doc/images/gaussian_noise/lenna_noise_s_0_07_m_0.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_noise_s_0_1_m_0.png b/doc/images/gaussian_noise/lenna_noise_s_0_1_m_0.png deleted file mode 100644 index abbb1d3..0000000 Binary files a/doc/images/gaussian_noise/lenna_noise_s_0_1_m_0.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_small_0.02_0.png b/doc/images/gaussian_noise/lenna_small_0.02_0.png new file mode 100644 index 0000000..c658937 Binary files /dev/null and b/doc/images/gaussian_noise/lenna_small_0.02_0.png differ diff --git a/doc/images/gaussian_noise/lenna_small_0.03_0.png b/doc/images/gaussian_noise/lenna_small_0.03_0.png new file mode 100644 index 0000000..067c46d Binary files /dev/null and b/doc/images/gaussian_noise/lenna_small_0.03_0.png differ diff --git a/doc/images/gaussian_noise/lenna_small_0.05_-0.1.png b/doc/images/gaussian_noise/lenna_small_0.05_-0.1.png new file mode 100644 index 0000000..38f796c Binary files /dev/null and b/doc/images/gaussian_noise/lenna_small_0.05_-0.1.png differ diff --git a/doc/images/gaussian_noise/lenna_small_0.05_0.1.png b/doc/images/gaussian_noise/lenna_small_0.05_0.1.png new file mode 100644 index 0000000..2980d39 Binary files /dev/null and b/doc/images/gaussian_noise/lenna_small_0.05_0.1.png differ diff --git a/doc/images/gaussian_noise/lenna_small_0.05_0.png b/doc/images/gaussian_noise/lenna_small_0.05_0.png new file mode 100644 index 0000000..e2a7cbb Binary files /dev/null and b/doc/images/gaussian_noise/lenna_small_0.05_0.png differ diff --git a/doc/images/gaussian_noise/lenna_small_0.07_0.0.png b/doc/images/gaussian_noise/lenna_small_0.07_0.0.png new file mode 100644 index 0000000..3498915 Binary files /dev/null and b/doc/images/gaussian_noise/lenna_small_0.07_0.0.png differ diff --git a/doc/images/gaussian_noise/lenna_small_noise_s_0_01_m_0.png b/doc/images/gaussian_noise/lenna_small_noise_s_0_01_m_0.png deleted file mode 100644 index 6ea5246..0000000 Binary files a/doc/images/gaussian_noise/lenna_small_noise_s_0_01_m_0.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_small_noise_s_0_02_m_0.png b/doc/images/gaussian_noise/lenna_small_noise_s_0_02_m_0.png deleted file mode 100644 index a1e89c1..0000000 Binary files a/doc/images/gaussian_noise/lenna_small_noise_s_0_02_m_0.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_-0_1.png b/doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_-0_1.png deleted file mode 100644 index 55f5165..0000000 Binary files a/doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_-0_1.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_0.png b/doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_0.png deleted file mode 100644 index 745431a..0000000 Binary files a/doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_0.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_0_1.png b/doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_0_1.png deleted file mode 100644 index d70c7d6..0000000 Binary files a/doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_0_1.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_small_noise_s_0_07_m_0.png b/doc/images/gaussian_noise/lenna_small_noise_s_0_07_m_0.png deleted file mode 100644 index cb773b6..0000000 Binary files a/doc/images/gaussian_noise/lenna_small_noise_s_0_07_m_0.png and /dev/null differ diff --git a/doc/images/gaussian_noise/lenna_small_noise_s_0_1_m_0.png b/doc/images/gaussian_noise/lenna_small_noise_s_0_1_m_0.png deleted file mode 100644 index 82ffaad..0000000 Binary files a/doc/images/gaussian_noise/lenna_small_noise_s_0_1_m_0.png and /dev/null differ diff --git a/doc/images/regen.py b/doc/images/regen.py index cc0e944..b1a8788 100755 --- a/doc/images/regen.py +++ b/doc/images/regen.py @@ -72,5 +72,9 @@ def main(): [[0.1], [0.3], [0.5], [0.8], [1.0]], 'images/edge_sharpening/', 'Edge Sharpening') + imggen.gen(filters.GaussianNoiseAddAlloc, + [[0.03, 0], [0.05, 0], [0.05, -0.1], [0.05, 0.1], [0.07, 0.0]], + 'images/gaussian_noise/', 'Gaussian Additive Noise') + if __name__ == '__main__': main() ----------------------------------------------------------------------- Summary of changes: doc/Makefile | 4 +- doc/filter_additive_gaussian_noise.txt | 66 -------------------- doc/filters.txt | 42 ++++++++++++- doc/filters_python.txt | 21 ++++++ doc/images/Makefile | 2 +- doc/images/gaussian_noise/images.txt | 20 ++++++ ...lenna_noise_s_0_02_m_0.png => lenna_0.02_0.png} | Bin 499974 -> 499974 bytes doc/images/gaussian_noise/lenna_0.03_0.png | Bin 0 -> 534481 bytes doc/images/gaussian_noise/lenna_0.05_-0.1.png | Bin 0 -> 595526 bytes doc/images/gaussian_noise/lenna_0.05_0.1.png | Bin 0 -> 600660 bytes doc/images/gaussian_noise/lenna_0.05_0.png | Bin 0 -> 597194 bytes doc/images/gaussian_noise/lenna_0.07_0.0.png | Bin 0 -> 640739 bytes .../gaussian_noise/lenna_noise_s_0_01_m_0.png | Bin 437216 -> 0 bytes .../gaussian_noise/lenna_noise_s_0_05_m_-0_1.png | Bin 595580 -> 0 bytes .../gaussian_noise/lenna_noise_s_0_05_m_0.png | Bin 597207 -> 0 bytes .../gaussian_noise/lenna_noise_s_0_05_m_0_1.png | Bin 600729 -> 0 bytes .../gaussian_noise/lenna_noise_s_0_07_m_0.png | Bin 640843 -> 0 bytes .../gaussian_noise/lenna_noise_s_0_1_m_0.png | Bin 692490 -> 0 bytes doc/images/gaussian_noise/lenna_small_0.02_0.png | Bin 0 -> 35601 bytes doc/images/gaussian_noise/lenna_small_0.03_0.png | Bin 0 -> 36875 bytes .../gaussian_noise/lenna_small_0.05_-0.1.png | Bin 0 -> 39579 bytes doc/images/gaussian_noise/lenna_small_0.05_0.1.png | Bin 0 -> 39898 bytes doc/images/gaussian_noise/lenna_small_0.05_0.png | Bin 0 -> 39680 bytes doc/images/gaussian_noise/lenna_small_0.07_0.0.png | Bin 0 -> 41654 bytes .../lenna_small_noise_s_0_01_m_0.png | Bin 121712 -> 0 bytes .../lenna_small_noise_s_0_02_m_0.png | Bin 133915 -> 0 bytes .../lenna_small_noise_s_0_05_m_-0_1.png | Bin 152935 -> 0 bytes .../lenna_small_noise_s_0_05_m_0.png | Bin 153507 -> 0 bytes .../lenna_small_noise_s_0_05_m_0_1.png | Bin 154283 -> 0 bytes .../lenna_small_noise_s_0_07_m_0.png | Bin 162795 -> 0 bytes .../gaussian_noise/lenna_small_noise_s_0_1_m_0.png | Bin 174738 -> 0 bytes doc/images/regen.py | 4 + 32 files changed, 88 insertions(+), 71 deletions(-) delete mode 100644 doc/filter_additive_gaussian_noise.txt create mode 100644 doc/images/gaussian_noise/images.txt rename doc/images/gaussian_noise/{lenna_noise_s_0_02_m_0.png => lenna_0.02_0.png} (100%) create mode 100644 doc/images/gaussian_noise/lenna_0.03_0.png create mode 100644 doc/images/gaussian_noise/lenna_0.05_-0.1.png create mode 100644 doc/images/gaussian_noise/lenna_0.05_0.1.png create mode 100644 doc/images/gaussian_noise/lenna_0.05_0.png create mode 100644 doc/images/gaussian_noise/lenna_0.07_0.0.png delete mode 100644 doc/images/gaussian_noise/lenna_noise_s_0_01_m_0.png delete mode 100644 doc/images/gaussian_noise/lenna_noise_s_0_05_m_-0_1.png delete mode 100644 doc/images/gaussian_noise/lenna_noise_s_0_05_m_0.png delete mode 100644 doc/images/gaussian_noise/lenna_noise_s_0_05_m_0_1.png delete mode 100644 doc/images/gaussian_noise/lenna_noise_s_0_07_m_0.png delete mode 100644 doc/images/gaussian_noise/lenna_noise_s_0_1_m_0.png create mode 100644 doc/images/gaussian_noise/lenna_small_0.02_0.png create mode 100644 doc/images/gaussian_noise/lenna_small_0.03_0.png create mode 100644 doc/images/gaussian_noise/lenna_small_0.05_-0.1.png create mode 100644 doc/images/gaussian_noise/lenna_small_0.05_0.1.png create mode 100644 doc/images/gaussian_noise/lenna_small_0.05_0.png create mode 100644 doc/images/gaussian_noise/lenna_small_0.07_0.0.png delete mode 100644 doc/images/gaussian_noise/lenna_small_noise_s_0_01_m_0.png delete mode 100644 doc/images/gaussian_noise/lenna_small_noise_s_0_02_m_0.png delete mode 100644 doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_-0_1.png delete mode 100644 doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_0.png delete mode 100644 doc/images/gaussian_noise/lenna_small_noise_s_0_05_m_0_1.png delete mode 100644 doc/images/gaussian_noise/lenna_small_noise_s_0_07_m_0.png delete mode 100644 doc/images/gaussian_noise/lenna_small_noise_s_0_1_m_0.png 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
0
0
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc0-199-gb0ae037
by metan
27 Sep '13
27 Sep '13
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git. The branch, master has been updated via b0ae037dbd8678fe2eade3de055b7d120b6dc8d9 (commit) via 6983b8143445758e54e41dfa0ae8c779324aa1ed (commit) from 4da03cd71c2d22bc18b3d33e8a804de206beb57a (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/b0ae037dbd8678fe2eade3de055b7d120b6d…
commit b0ae037dbd8678fe2eade3de055b7d120b6dc8d9 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 23:16:20 2013 +0200 doc: filters: Further example generator changes * Apply filter function on small image directly (do not use resized big image) * Add edge_sharpening filter * change filters and python filters docs accordingly Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/doc/Makefile b/doc/Makefile index 3f3ebd5..8c2aca6 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -31,8 +31,11 @@ $(PAGES): asciidoc.conf # # Dependencies # -filters_python.html: images/blur/images.txt images/median/images.txt -filters.html: images/median/images.txt +IMG_INCLUDES=images/blur/images.txt images/median/images.txt+ images/edge_sharpening/images.txt + +filters_python.html: $(IMG_INCLUDES) +filters.html: $(IMG_INCLUDES) # # Check if we have all the needed tools diff --git a/doc/filters.txt b/doc/filters.txt index 9c8f681..c7ed191 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -813,6 +813,9 @@ GP_Context *GP_FilterEdgeSharpeningAlloc(const GP_Context *src, float w, Laplace based edge sharpening filter, subtracts weighted second derivative from the original image. +The w paramerter is multiplicative weight applied on the second derivative. +Reasonable results are when the parameter is between '0.1' and '1'. + [latex, laplacian_edge_sharpening.png, 140] ------------------------------------------------------------------------------- [ @@ -820,19 +823,7 @@ O(x,y) = I(x,y) - w * I''(x,y) ] ------------------------------------------------------------------------------- -.Original Image; Edge Sharpening w=0.1, w=0.3, w=0.5 -image:images/dither/lenna_small.png[ - "Original Image", - link="images/dither/lenna.png"] -image:images/edge_sharpening/lenna_small_w_0_1.png[ - "Edge Sharpening w=0.1", - link="images/edge_sharpening/lenna_w_0_1.png"] -image:images/edge_sharpening/lenna_small_w_0_3.png[ - "Edge Sharpening w=0.5", - link="images/edge_sharpening/lenna_w_0_3.png"] -image:images/edge_sharpening/lenna_small_w_0_5.png[ - "Edge Sharpening w=0.5", - link="images/edge_sharpening/lenna_w_0_5.png"] +include::images/edge_sharpening/images.txt[] Gaussian Blur ^^^^^^^^^^^^^ @@ -876,6 +867,8 @@ The sigma values can be set for vertical and horizontal direction independently which may be useful when Gaussian blur is used as a low pass filter before image is resampled non proportionally. +include::images/blur/images.txt[] + Interpolation filters ~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/filters_python.txt b/doc/filters_python.txt index 7de21f2..f29cb44 100644 --- a/doc/filters_python.txt +++ b/doc/filters_python.txt @@ -11,6 +11,38 @@ image is passed automatically as a first parameter. If filter has been aborted from callback 'OSError' with 'errno' set to 'ECANCELED' is raised. + +Laplacian Edge Sharpening +~~~~~~~~~~~~~~~~~~~~~~~~~ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Does in-place Edge Sharpening + filters.EdgeSharpening(img, img, 0.2, callback=None) + + # Returns newly allocated sharpened image + res = img.filters.EdgeSharpening(0.2, callback=None) + +------------------------------------------------------------------------------- + +Laplace based edge sharpening filter, subtracts weighted second derivative +from the original image. + +The float paramerter is multiplicative weight applied on the second +derivative. Reasonable results are when the parameter is between '0.1' and +'1'. + +//// +Generated in filters.txt +//// +image:laplacian_edge_sharpening.png["Laplacian Edge Sharpening"] + +include::images/edge_sharpening/images.txt[] + + Blurs ~~~~~ diff --git a/doc/images/Makefile b/doc/images/Makefile index 419e864..adc0fe2 100644 --- a/doc/images/Makefile +++ b/doc/images/Makefile @@ -1,11 +1,11 @@ -SUBDIRS=blur median +SUBDIRS=blur median edge_sharpening TARGETS=$(addsuffix /images.txt,$(SUBDIRS)) IMGS=$(addsuffix /*.png,$(SUBDIRS)) all: $(TARGETS) -$(TARGETS): +$(TARGETS): ./regen.py @./regen.py clean: diff --git a/doc/images/blur/lenna_small_0_4.png b/doc/images/blur/lenna_small_0_4.png index ad3e5a2..942601b 100644 Binary files a/doc/images/blur/lenna_small_0_4.png and b/doc/images/blur/lenna_small_0_4.png differ diff --git a/doc/images/blur/lenna_small_10_10.png b/doc/images/blur/lenna_small_10_10.png index 63493dd..6c899cf 100644 Binary files a/doc/images/blur/lenna_small_10_10.png and b/doc/images/blur/lenna_small_10_10.png differ diff --git a/doc/images/blur/lenna_small_2_2.png b/doc/images/blur/lenna_small_2_2.png index ad82e72..8a00c0c 100644 Binary files a/doc/images/blur/lenna_small_2_2.png and b/doc/images/blur/lenna_small_2_2.png differ diff --git a/doc/images/blur/lenna_small_4_0.png b/doc/images/blur/lenna_small_4_0.png index 9fe4a10..fbfd683 100644 Binary files a/doc/images/blur/lenna_small_4_0.png and b/doc/images/blur/lenna_small_4_0.png differ diff --git a/doc/images/blur/lenna_small_4_4.png b/doc/images/blur/lenna_small_4_4.png index 49c0140..1da3e30 100644 Binary files a/doc/images/blur/lenna_small_4_4.png and b/doc/images/blur/lenna_small_4_4.png differ diff --git a/doc/images/edge_sharpening/images.txt b/doc/images/edge_sharpening/images.txt new file mode 100644 index 0000000..8066f2e --- /dev/null +++ b/doc/images/edge_sharpening/images.txt @@ -0,0 +1,20 @@ +.Example Images: Original Image; Edge Sharpening 0.1, 0.3, 0.5, 0.8, 1.0 +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/edge_sharpening/lenna_small_0.1.png[ + "Edge Sharpening 0.1", + link="images/edge_sharpening/lenna_0.1.png"] +image:images/edge_sharpening/lenna_small_0.3.png[ + "Edge Sharpening 0.3", + link="images/edge_sharpening/lenna_0.3.png"] +image:images/edge_sharpening/lenna_small_0.5.png[ + "Edge Sharpening 0.5", + link="images/edge_sharpening/lenna_0.5.png"] +image:images/edge_sharpening/lenna_small_0.8.png[ + "Edge Sharpening 0.8", + link="images/edge_sharpening/lenna_0.8.png"] +image:images/edge_sharpening/lenna_small_1.0.png[ + "Edge Sharpening 1.0", + link="images/edge_sharpening/lenna_1.0.png"] + diff --git a/doc/images/edge_sharpening/lenna_0.1.png b/doc/images/edge_sharpening/lenna_0.1.png new file mode 100644 index 0000000..bc7a3d0 Binary files /dev/null and b/doc/images/edge_sharpening/lenna_0.1.png differ diff --git a/doc/images/edge_sharpening/lenna_0.3.png b/doc/images/edge_sharpening/lenna_0.3.png new file mode 100644 index 0000000..29dd3ae Binary files /dev/null and b/doc/images/edge_sharpening/lenna_0.3.png differ diff --git a/doc/images/edge_sharpening/lenna_0.5.png b/doc/images/edge_sharpening/lenna_0.5.png new file mode 100644 index 0000000..0d2167f Binary files /dev/null and b/doc/images/edge_sharpening/lenna_0.5.png differ diff --git a/doc/images/edge_sharpening/lenna_0.8.png b/doc/images/edge_sharpening/lenna_0.8.png new file mode 100644 index 0000000..aeb4f57 Binary files /dev/null and b/doc/images/edge_sharpening/lenna_0.8.png differ diff --git a/doc/images/edge_sharpening/lenna_1.0.png b/doc/images/edge_sharpening/lenna_1.0.png new file mode 100644 index 0000000..bc03132 Binary files /dev/null and b/doc/images/edge_sharpening/lenna_1.0.png differ diff --git a/doc/images/edge_sharpening/lenna_small_0.1.png b/doc/images/edge_sharpening/lenna_small_0.1.png new file mode 100644 index 0000000..38516e9 Binary files /dev/null and b/doc/images/edge_sharpening/lenna_small_0.1.png differ diff --git a/doc/images/edge_sharpening/lenna_small_0.3.png b/doc/images/edge_sharpening/lenna_small_0.3.png new file mode 100644 index 0000000..8752f59 Binary files /dev/null and b/doc/images/edge_sharpening/lenna_small_0.3.png differ diff --git a/doc/images/edge_sharpening/lenna_small_0.5.png b/doc/images/edge_sharpening/lenna_small_0.5.png new file mode 100644 index 0000000..82b2804 Binary files /dev/null and b/doc/images/edge_sharpening/lenna_small_0.5.png differ diff --git a/doc/images/edge_sharpening/lenna_small_0.8.png b/doc/images/edge_sharpening/lenna_small_0.8.png new file mode 100644 index 0000000..0c6908b Binary files /dev/null and b/doc/images/edge_sharpening/lenna_small_0.8.png differ diff --git a/doc/images/edge_sharpening/lenna_small_1.0.png b/doc/images/edge_sharpening/lenna_small_1.0.png new file mode 100644 index 0000000..de57fcf Binary files /dev/null and b/doc/images/edge_sharpening/lenna_small_1.0.png differ diff --git a/doc/images/edge_sharpening/lenna_small_w_0_1.png b/doc/images/edge_sharpening/lenna_small_w_0_1.png deleted file mode 100644 index 848ccea..0000000 Binary files a/doc/images/edge_sharpening/lenna_small_w_0_1.png and /dev/null differ diff --git a/doc/images/edge_sharpening/lenna_small_w_0_3.png b/doc/images/edge_sharpening/lenna_small_w_0_3.png deleted file mode 100644 index a311e36..0000000 Binary files a/doc/images/edge_sharpening/lenna_small_w_0_3.png and /dev/null differ diff --git a/doc/images/edge_sharpening/lenna_small_w_0_5.png b/doc/images/edge_sharpening/lenna_small_w_0_5.png deleted file mode 100644 index 46891b2..0000000 Binary files a/doc/images/edge_sharpening/lenna_small_w_0_5.png and /dev/null differ diff --git a/doc/images/edge_sharpening/lenna_w_0_1.png b/doc/images/edge_sharpening/lenna_w_0_1.png deleted file mode 100644 index 405291f..0000000 Binary files a/doc/images/edge_sharpening/lenna_w_0_1.png and /dev/null differ diff --git a/doc/images/edge_sharpening/lenna_w_0_3.png b/doc/images/edge_sharpening/lenna_w_0_3.png deleted file mode 100644 index 4417327..0000000 Binary files a/doc/images/edge_sharpening/lenna_w_0_3.png and /dev/null differ diff --git a/doc/images/edge_sharpening/lenna_w_0_5.png b/doc/images/edge_sharpening/lenna_w_0_5.png deleted file mode 100644 index 0a9e7c9..0000000 Binary files a/doc/images/edge_sharpening/lenna_w_0_5.png and /dev/null differ diff --git a/doc/images/median/lenna_small_12_12.png b/doc/images/median/lenna_small_12_12.png index 5663569..a727df5 100644 Binary files a/doc/images/median/lenna_small_12_12.png and b/doc/images/median/lenna_small_12_12.png differ diff --git a/doc/images/median/lenna_small_3_3.png b/doc/images/median/lenna_small_3_3.png index 1849e60..6ce9247 100644 Binary files a/doc/images/median/lenna_small_3_3.png and b/doc/images/median/lenna_small_3_3.png differ diff --git a/doc/images/median/lenna_small_5_5.png b/doc/images/median/lenna_small_5_5.png index 992dbe9..8b7a30f 100644 Binary files a/doc/images/median/lenna_small_5_5.png and b/doc/images/median/lenna_small_5_5.png differ diff --git a/doc/images/median/lenna_small_7_7.png b/doc/images/median/lenna_small_7_7.png index 1b92359..8c23717 100644 Binary files a/doc/images/median/lenna_small_7_7.png and b/doc/images/median/lenna_small_7_7.png differ diff --git a/doc/images/median/lenna_small_9_9.png b/doc/images/median/lenna_small_9_9.png index af39ba1..b749a8c 100644 Binary files a/doc/images/median/lenna_small_9_9.png and b/doc/images/median/lenna_small_9_9.png differ diff --git a/doc/images/regen.py b/doc/images/regen.py index 21cfd70..cc0e944 100755 --- a/doc/images/regen.py +++ b/doc/images/regen.py @@ -52,7 +52,7 @@ class ImgGen: res = func(self.img, *i) res.loaders.Save('../' + fname) - res = res.filters.ResizeAlloc(self.img_small.w, self.img_small.h, 2) + res = func(self.img_small, *i) res.loaders.Save('../' + fname_small) self.write_asciidoc_tail() @@ -68,5 +68,9 @@ def main(): [[3, 3], [5, 5], [7, 7], [9, 9], [12, 12]], 'images/median/', 'Median') + imggen.gen(filters.EdgeSharpeningAlloc, + [[0.1], [0.3], [0.5], [0.8], [1.0]], + 'images/edge_sharpening/', 'Edge Sharpening') + if __name__ == '__main__': main()
http://repo.or.cz/w/gfxprim.git/commit/6983b8143445758e54e41dfa0ae8c779324a…
commit 6983b8143445758e54e41dfa0ae8c779324aa1ed Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 22:56:08 2013 +0200 doc: filters: Rewrite the example image generator The example image generator is now generic, yay! * generate median images automatically * update the parent asciidoc docs accordingly * update python filters docs Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/doc/Makefile b/doc/Makefile index dee519e..3f3ebd5 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -31,8 +31,8 @@ $(PAGES): asciidoc.conf # # Dependencies # -filters_python.html: images/blur/images.txt - +filters_python.html: images/blur/images.txt images/median/images.txt +filters.html: images/median/images.txt # # Check if we have all the needed tools diff --git a/doc/filters.txt b/doc/filters.txt index ef6b123..9c8f681 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -946,27 +946,11 @@ GP_Context *GP_FilterMedianAlloc(const GP_Context *src, GP_ProgressCallback *callback); ------------------------------------------------------------------------------- -Constant time median filters (the computational complexity is independent of +Constant time median filter (the computational complexity is independent of radius size). The xmed and ymed are radius values for x and y. The algorithm uses xmed respectively ymed pixel neighbors from each side so the result is median of rectangle of 2 * xmed + 1 x 2 * ymed + 1 pixels. -.Original Image; Median 3x3, 5x5, 7x7, 9x9 -image:images/dither/lenna_small.png[ - "Original Image", - link="images/dither/lenna.png"] -image:images/median/lenna_small_med_3_3.png[ - "Median 3x3", - link="images/median/lenna_med_3_3.png"] -image:images/median/lenna_small_med_5_5.png[ - "Median 5x5", - link="images/median/lenna_med_5_5.png"] -image:images/median/lenna_small_med_7_7.png[ - "Median 7x7", - link="images/median/lenna_med_7_7.png"] -image:images/median/lenna_small_med_9_9.png[ - "Median 9x9", - link="images/median/lenna_med_9_9.png"] - +include::images/median/images.txt[] diff --git a/doc/filters_python.txt b/doc/filters_python.txt index 324f160..7de21f2 100644 --- a/doc/filters_python.txt +++ b/doc/filters_python.txt @@ -8,6 +8,9 @@ The filter functions could be called directly as +filters.Foo(img, ..)+ or from submodule as +img.filters.Foo(..)+. Note that in the second case the image is passed automatically as a first parameter. +If filter has been aborted from callback 'OSError' with 'errno' set to +'ECANCELED' is raised. + Blurs ~~~~~ @@ -56,3 +59,27 @@ For more information and example images see link:filters_dithering.html[C dithering documentation]. TIP: See link:example_py_dithering.html[dithering example]. + +Median +~~~~~~ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Returns result of median filter over a rectangle of a side 2 * 3 + 1 pixels + res = img.filters.MedianAlloc(3, 3, callback=None) + + # Applies median filter in-place + img.filters.Median(3, 3, callback=None) +------------------------------------------------------------------------------- + +Constant time median filter (the computational complexity is independent of +radius size). + +The parameters are radius values for x and y. The algorithm uses x +respectively y pixel neighbors from each side so the result is median of +rectangle of +2 * x + 1+ x +2 * y + 1+ pixels. + +include::images/median/images.txt[] diff --git a/doc/images/Makefile b/doc/images/Makefile new file mode 100644 index 0000000..419e864 --- /dev/null +++ b/doc/images/Makefile @@ -0,0 +1,12 @@ +SUBDIRS=blur median + +TARGETS=$(addsuffix /images.txt,$(SUBDIRS)) +IMGS=$(addsuffix /*.png,$(SUBDIRS)) + +all: $(TARGETS) + +$(TARGETS): + @./regen.py + +clean: + rm -f $(TARGETS) $(IMGS) diff --git a/doc/images/blur/Makefile b/doc/images/blur/Makefile deleted file mode 100644 index 4c642ec..0000000 --- a/doc/images/blur/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: images.txt - -images.txt: regen.py - @./regen.py - -clean: - rm -f *.png images.txt diff --git a/doc/images/blur/images.txt b/doc/images/blur/images.txt index b9d7434..74697da 100644 --- a/doc/images/blur/images.txt +++ b/doc/images/blur/images.txt @@ -1,17 +1,20 @@ -.Example Images: Original Image; Gaussian Blur 2 2, 0 4, 4 0, 10 10 +.Example Images: Original Image; Gaussian Blur 2 2, 0 4, 4 0, 4 4, 10 10 image:images/orig/lenna_small.png[ "Original Image", link="images/orig/lenna.png"] image:images/blur/lenna_small_2_2.png[ - "Gaussian Blur x_sig=2 y_sig=2", + "Gaussian Blur 2 2", link="images/blur/lenna_2_2.png"] image:images/blur/lenna_small_0_4.png[ - "Gaussian Blur x_sig=4 y_sig=4", + "Gaussian Blur 0 4", link="images/blur/lenna_0_4.png"] image:images/blur/lenna_small_4_0.png[ - "Gaussian Blur x_sig=0 y_sig=0", + "Gaussian Blur 4 0", link="images/blur/lenna_4_0.png"] +image:images/blur/lenna_small_4_4.png[ + "Gaussian Blur 4 4", + link="images/blur/lenna_4_4.png"] image:images/blur/lenna_small_10_10.png[ - "Gaussian Blur x_sig=10 y_sig=10", + "Gaussian Blur 10 10", link="images/blur/lenna_10_10.png"] diff --git a/doc/images/blur/lenna_4_4.png b/doc/images/blur/lenna_4_4.png new file mode 100644 index 0000000..581e749 Binary files /dev/null and b/doc/images/blur/lenna_4_4.png differ diff --git a/doc/images/blur/lenna_small_4_4.png b/doc/images/blur/lenna_small_4_4.png new file mode 100644 index 0000000..49c0140 Binary files /dev/null and b/doc/images/blur/lenna_small_4_4.png differ diff --git a/doc/images/blur/regen.py b/doc/images/blur/regen.py deleted file mode 100755 index 13e9d39..0000000 --- a/doc/images/blur/regen.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python - -import sys - -import gfxprim.core as core -import gfxprim.loaders as loaders -import gfxprim.filters as filters - -orig_path='images/orig/' -self_path='images/blur/' - -def write_asciidoc_head(f): - f.write('.Example Images: Original Image; Gaussian Blur 2 2, 0 4, 4 0, 10 10n') - f.write('image:' + orig_path + 'lenna_small.png[n') - f.write('t"Original Image",n') - f.write('tlink="' + orig_path + 'lenna.png"]n') - -def write_img_asciidoc(f, name, fname): - f.write('image:' + self_path + 'lenna_small_' + fname + '.png[n') - f.write('t"' + name + '",n') - f.write('tlink="' + self_path + 'lenna_' + fname + '.png"]n') - -def write_asciidoc_tail(f): - f.write('n') - -def gen_blur(f, img, img_small, x_sigma, y_sigma): - print("Generating Blur %s %s" % (x_sigma, y_sigma)) - name = '%s_%s' % (x_sigma, y_sigma) - res = img.filters.GaussianBlurAlloc(x_sigma, y_sigma); - res.loaders.Save('lenna_' + name + '.png') - res = res.filters.ResizeAlloc(img_small.w, img_small.h, 2) - res.loaders.Save('lenna_small_' + name + '.png') - write_img_asciidoc(f, 'Gaussian Blur x_sig=%s y_sig=%s' % (y_sigma, y_sigma), name) - -def main(): - lenna = loaders.Load('../../' + orig_path + 'lenna.png') - lenna_small = loaders.Load('../../' + orig_path + 'lenna_small.png') - - f = open('images.txt', 'w') - - write_asciidoc_head(f) - - gen_blur(f, lenna, lenna_small, 2, 2) - gen_blur(f, lenna, lenna_small, 0, 4) - gen_blur(f, lenna, lenna_small, 4, 0) - gen_blur(f, lenna, lenna_small, 10, 10) - - write_asciidoc_tail(f) - - f.close() - -if __name__ == '__main__': - main() diff --git a/doc/images/median/images.txt b/doc/images/median/images.txt new file mode 100644 index 0000000..968ef8a --- /dev/null +++ b/doc/images/median/images.txt @@ -0,0 +1,20 @@ +.Example Images: Original Image; Median 3 3, 5 5, 7 7, 9 9, 12 12 +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/median/lenna_small_3_3.png[ + "Median 3 3", + link="images/median/lenna_3_3.png"] +image:images/median/lenna_small_5_5.png[ + "Median 5 5", + link="images/median/lenna_5_5.png"] +image:images/median/lenna_small_7_7.png[ + "Median 7 7", + link="images/median/lenna_7_7.png"] +image:images/median/lenna_small_9_9.png[ + "Median 9 9", + link="images/median/lenna_9_9.png"] +image:images/median/lenna_small_12_12.png[ + "Median 12 12", + link="images/median/lenna_12_12.png"] + diff --git a/doc/images/median/lenna_12_12.png b/doc/images/median/lenna_12_12.png new file mode 100644 index 0000000..550b8fd Binary files /dev/null and b/doc/images/median/lenna_12_12.png differ diff --git a/doc/images/median/lenna_5_5.png b/doc/images/median/lenna_5_5.png new file mode 100644 index 0000000..ae5830a Binary files /dev/null and b/doc/images/median/lenna_5_5.png differ diff --git a/doc/images/median/lenna_7_7.png b/doc/images/median/lenna_7_7.png new file mode 100644 index 0000000..37e7d3e Binary files /dev/null and b/doc/images/median/lenna_7_7.png differ diff --git a/doc/images/median/lenna_9_9.png b/doc/images/median/lenna_9_9.png new file mode 100644 index 0000000..ce90ae1 Binary files /dev/null and b/doc/images/median/lenna_9_9.png differ diff --git a/doc/images/median/lenna_med_3_3.png b/doc/images/median/lenna_med_3_3.png deleted file mode 100644 index b1263d7..0000000 Binary files a/doc/images/median/lenna_med_3_3.png and /dev/null differ diff --git a/doc/images/median/lenna_med_5_5.png b/doc/images/median/lenna_med_5_5.png deleted file mode 100644 index 3a70498..0000000 Binary files a/doc/images/median/lenna_med_5_5.png and /dev/null differ diff --git a/doc/images/median/lenna_med_9_9.png b/doc/images/median/lenna_med_9_9.png deleted file mode 100644 index 94a62f1..0000000 Binary files a/doc/images/median/lenna_med_9_9.png and /dev/null differ diff --git a/doc/images/median/lenna_small_12_12.png b/doc/images/median/lenna_small_12_12.png new file mode 100644 index 0000000..5663569 Binary files /dev/null and b/doc/images/median/lenna_small_12_12.png differ diff --git a/doc/images/median/lenna_small_3_3.png b/doc/images/median/lenna_small_3_3.png new file mode 100644 index 0000000..1849e60 Binary files /dev/null and b/doc/images/median/lenna_small_3_3.png differ diff --git a/doc/images/median/lenna_small_5_5.png b/doc/images/median/lenna_small_5_5.png new file mode 100644 index 0000000..992dbe9 Binary files /dev/null and b/doc/images/median/lenna_small_5_5.png differ diff --git a/doc/images/median/lenna_small_7_7.png b/doc/images/median/lenna_small_7_7.png new file mode 100644 index 0000000..1b92359 Binary files /dev/null and b/doc/images/median/lenna_small_7_7.png differ diff --git a/doc/images/median/lenna_small_9_9.png b/doc/images/median/lenna_small_9_9.png new file mode 100644 index 0000000..af39ba1 Binary files /dev/null and b/doc/images/median/lenna_small_9_9.png differ diff --git a/doc/images/median/lenna_small_med_3_3.png b/doc/images/median/lenna_small_med_3_3.png deleted file mode 100644 index c8703bc..0000000 Binary files a/doc/images/median/lenna_small_med_3_3.png and /dev/null differ diff --git a/doc/images/median/lenna_small_med_5_5.png b/doc/images/median/lenna_small_med_5_5.png deleted file mode 100644 index 8dbb616..0000000 Binary files a/doc/images/median/lenna_small_med_5_5.png and /dev/null differ diff --git a/doc/images/median/lenna_small_med_7_7.png b/doc/images/median/lenna_small_med_7_7.png deleted file mode 100644 index e06ddf5..0000000 Binary files a/doc/images/median/lenna_small_med_7_7.png and /dev/null differ diff --git a/doc/images/median/lenna_small_med_9_9.png b/doc/images/median/lenna_small_med_9_9.png deleted file mode 100644 index 2fa7997..0000000 Binary files a/doc/images/median/lenna_small_med_9_9.png and /dev/null differ diff --git a/doc/images/regen.py b/doc/images/regen.py new file mode 100755 index 0000000..21cfd70 --- /dev/null +++ b/doc/images/regen.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python + +import sys + +import gfxprim.core as core +import gfxprim.loaders as loaders +import gfxprim.filters as filters + +class ImgGen: + def __init__(self, orig_path): + self.orig_path = orig_path + self.img = loaders.Load('../' + orig_path + 'lenna.png') + self.img_small = loaders.Load('../' + orig_path + 'lenna_small.png') + + + def write_asciidoc_head(self, dst_path, heading): + self.f = open('../' + dst_path + 'images.txt', 'w') + f = self.f + f.write('.Example Images: Original Image; ' + heading + 'n') + f.write('image:' + self.orig_path + 'lenna_small.png[n') + f.write('t"Original Image",n') + f.write('tlink="' + self.orig_path + 'lenna.png"]n') + + def write_img_asciidoc(self, desc, fname, fname_small): + f = self.f + f.write('image:' + fname_small + '[n') + f.write('t"' + desc + '",n') + f.write('tlink="' + fname + '"]n') + + def write_asciidoc_tail(self): + self.f.write('n') + self.f.close() + + def gen(self, func, func_params_arr, dst_path, func_name): + + print("Generating " + func_name) + + self.write_asciidoc_head(dst_path, func_name + ' ' + + ', '.join(map(lambda x: ' '.join([str(i) for i in x]), func_params_arr))) + + for i in func_params_arr: + str_i = [str(x) for x in i] + desc = func_name + ' ' + ' '.join(str_i) + + print(' > ' + desc) + + fname = dst_path + 'lenna_' + '_'.join(str_i) + '.png' + fname_small = dst_path + 'lenna_small_' + '_'.join(str_i) + '.png' + + self.write_img_asciidoc(desc, fname, fname_small) + + res = func(self.img, *i) + res.loaders.Save('../' + fname) + + res = res.filters.ResizeAlloc(self.img_small.w, self.img_small.h, 2) + res.loaders.Save('../' + fname_small) + + self.write_asciidoc_tail() + +def main(): + imggen = ImgGen('images/orig/') + + imggen.gen(filters.GaussianBlurAlloc, + [[2, 2], [0, 4], [4, 0], [4, 4], [10, 10]], + 'images/blur/', 'Gaussian Blur') + + imggen.gen(filters.MedianAlloc, + [[3, 3], [5, 5], [7, 7], [9, 9], [12, 12]], + 'images/median/', 'Median') + +if __name__ == '__main__': + main() ----------------------------------------------------------------------- Summary of changes: doc/Makefile | 5 +- doc/filters.txt | 39 ++-------- doc/filters_python.txt | 59 +++++++++++++++ doc/images/Makefile | 12 +++ doc/images/blur/Makefile | 7 -- doc/images/blur/images.txt | 13 ++-- doc/images/blur/lenna_4_4.png | Bin 0 -> 178703 bytes doc/images/blur/lenna_small_0_4.png | Bin 25526 -> 19492 bytes doc/images/blur/lenna_small_10_10.png | Bin 17520 -> 10638 bytes doc/images/blur/lenna_small_2_2.png | Bin 26436 -> 18849 bytes doc/images/blur/lenna_small_4_0.png | Bin 25437 -> 18565 bytes doc/images/blur/lenna_small_4_4.png | Bin 0 -> 14816 bytes doc/images/blur/regen.py | 53 -------------- doc/images/edge_sharpening/images.txt | 20 +++++ doc/images/edge_sharpening/lenna_0.1.png | Bin 0 -> 429050 bytes doc/images/edge_sharpening/lenna_0.3.png | Bin 0 -> 475903 bytes doc/images/edge_sharpening/lenna_0.5.png | Bin 0 -> 512405 bytes doc/images/edge_sharpening/lenna_0.8.png | Bin 0 -> 555001 bytes doc/images/edge_sharpening/lenna_1.0.png | Bin 0 -> 576361 bytes doc/images/edge_sharpening/lenna_small_0.1.png | Bin 0 -> 34905 bytes doc/images/edge_sharpening/lenna_small_0.3.png | Bin 0 -> 38697 bytes doc/images/edge_sharpening/lenna_small_0.5.png | Bin 0 -> 40867 bytes doc/images/edge_sharpening/lenna_small_0.8.png | Bin 0 -> 42885 bytes doc/images/edge_sharpening/lenna_small_1.0.png | Bin 0 -> 43692 bytes doc/images/edge_sharpening/lenna_small_w_0_1.png | Bin 127188 -> 0 bytes doc/images/edge_sharpening/lenna_small_w_0_3.png | Bin 143643 -> 0 bytes doc/images/edge_sharpening/lenna_small_w_0_5.png | Bin 156274 -> 0 bytes doc/images/edge_sharpening/lenna_w_0_1.png | Bin 429215 -> 0 bytes doc/images/edge_sharpening/lenna_w_0_3.png | Bin 476119 -> 0 bytes doc/images/edge_sharpening/lenna_w_0_5.png | Bin 514664 -> 0 bytes doc/images/median/images.txt | 20 +++++ doc/images/median/lenna_12_12.png | Bin 0 -> 174531 bytes .../median/{lenna_med_7_7.png => lenna_3_3.png} | Bin 259580 -> 259580 bytes doc/images/median/lenna_5_5.png | Bin 0 -> 224934 bytes doc/images/median/lenna_7_7.png | Bin 0 -> 204463 bytes doc/images/median/lenna_9_9.png | Bin 0 -> 190419 bytes doc/images/median/lenna_med_3_3.png | Bin 337110 -> 0 bytes doc/images/median/lenna_med_5_5.png | Bin 289966 -> 0 bytes doc/images/median/lenna_med_9_9.png | Bin 239185 -> 0 bytes doc/images/median/lenna_small_12_12.png | Bin 0 -> 15174 bytes doc/images/median/lenna_small_3_3.png | Bin 0 -> 20584 bytes doc/images/median/lenna_small_5_5.png | Bin 0 -> 18652 bytes doc/images/median/lenna_small_7_7.png | Bin 0 -> 17299 bytes doc/images/median/lenna_small_9_9.png | Bin 0 -> 16276 bytes doc/images/median/lenna_small_med_3_3.png | Bin 90434 -> 0 bytes doc/images/median/lenna_small_med_5_5.png | Bin 78931 -> 0 bytes doc/images/median/lenna_small_med_7_7.png | Bin 72126 -> 0 bytes doc/images/median/lenna_small_med_9_9.png | Bin 67725 -> 0 bytes doc/images/regen.py | 76 ++++++++++++++++++++ 49 files changed, 207 insertions(+), 97 deletions(-) create mode 100644 doc/images/Makefile delete mode 100644 doc/images/blur/Makefile create mode 100644 doc/images/blur/lenna_4_4.png create mode 100644 doc/images/blur/lenna_small_4_4.png delete mode 100755 doc/images/blur/regen.py create mode 100644 doc/images/edge_sharpening/images.txt create mode 100644 doc/images/edge_sharpening/lenna_0.1.png create mode 100644 doc/images/edge_sharpening/lenna_0.3.png create mode 100644 doc/images/edge_sharpening/lenna_0.5.png create mode 100644 doc/images/edge_sharpening/lenna_0.8.png create mode 100644 doc/images/edge_sharpening/lenna_1.0.png create mode 100644 doc/images/edge_sharpening/lenna_small_0.1.png create mode 100644 doc/images/edge_sharpening/lenna_small_0.3.png create mode 100644 doc/images/edge_sharpening/lenna_small_0.5.png create mode 100644 doc/images/edge_sharpening/lenna_small_0.8.png create mode 100644 doc/images/edge_sharpening/lenna_small_1.0.png delete mode 100644 doc/images/edge_sharpening/lenna_small_w_0_1.png delete mode 100644 doc/images/edge_sharpening/lenna_small_w_0_3.png delete mode 100644 doc/images/edge_sharpening/lenna_small_w_0_5.png delete mode 100644 doc/images/edge_sharpening/lenna_w_0_1.png delete mode 100644 doc/images/edge_sharpening/lenna_w_0_3.png delete mode 100644 doc/images/edge_sharpening/lenna_w_0_5.png create mode 100644 doc/images/median/images.txt create mode 100644 doc/images/median/lenna_12_12.png rename doc/images/median/{lenna_med_7_7.png => lenna_3_3.png} (100%) create mode 100644 doc/images/median/lenna_5_5.png create mode 100644 doc/images/median/lenna_7_7.png create mode 100644 doc/images/median/lenna_9_9.png delete mode 100644 doc/images/median/lenna_med_3_3.png delete mode 100644 doc/images/median/lenna_med_5_5.png delete mode 100644 doc/images/median/lenna_med_9_9.png create mode 100644 doc/images/median/lenna_small_12_12.png create mode 100644 doc/images/median/lenna_small_3_3.png create mode 100644 doc/images/median/lenna_small_5_5.png create mode 100644 doc/images/median/lenna_small_7_7.png create mode 100644 doc/images/median/lenna_small_9_9.png delete mode 100644 doc/images/median/lenna_small_med_3_3.png delete mode 100644 doc/images/median/lenna_small_med_5_5.png delete mode 100644 doc/images/median/lenna_small_med_7_7.png delete mode 100644 doc/images/median/lenna_small_med_9_9.png create mode 100755 doc/images/regen.py 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
0
0
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc0-197-g4da03cd
by metan
27 Sep '13
27 Sep '13
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git. The branch, master has been updated via 4da03cd71c2d22bc18b3d33e8a804de206beb57a (commit) via f4da24627bdbc2c598e29a04db851d0fc0d8ef7d (commit) via 92b4a111042c16733e2c23b1ed41e7a56ac52023 (commit) via 2212fd623e8e09bf468d3b72e4468a604511a9c9 (commit) via 8114cdf5bd54ace1d44cbe94e8b980d924fd4d20 (commit) via 73403e601211315ce51c3e41ddfec233cb8415ee (commit) via 069c44a2fb6118fbcfabcf0cf5bac8f1f93c7108 (commit) from 5c9dc009be46441c7144aeed9461616baeb931a2 (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/4da03cd71c2d22bc18b3d33e8a804de206be…
commit 4da03cd71c2d22bc18b3d33e8a804de206beb57a Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 21:08:01 2013 +0200 doc: Work on python filter docs (add GaussianBlur) * Add Gaussian blur example images generator (gfxprim must be installed to regenerate the images) * Add Gaussian blur python example + docs Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/doc/Makefile b/doc/Makefile index 3aec846..dee519e 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -24,12 +24,17 @@ PAGES+=$(subst .txt,.html,$(EXAMPLE_SOURCES)) .PHONY: toolcheck clean - all: toolcheck examples.html $(PAGES) api.html $(PAGES): asciidoc.conf # +# Dependencies +# +filters_python.html: images/blur/images.txt + + +# # Check if we have all the needed tools # toolcheck: diff --git a/doc/example_py_blur.txt b/doc/example_py_blur.txt new file mode 100644 index 0000000..cfe5577 --- /dev/null +++ b/doc/example_py_blur.txt @@ -0,0 +1,8 @@ +Gaussian Blur Example +--------------------- +.A simple program that loads image, blurs it and saves result + +[source,python] +------------------------------------------------------------------ +include::../demos/py_simple/blur.py[] +------------------------------------------------------------------ diff --git a/doc/filters_python.txt b/doc/filters_python.txt index a7c1ae4..324f160 100644 --- a/doc/filters_python.txt +++ b/doc/filters_python.txt @@ -8,6 +8,29 @@ The filter functions could be called directly as +filters.Foo(img, ..)+ or from submodule as +img.filters.Foo(..)+. Note that in the second case the image is passed automatically as a first parameter. +Blurs +~~~~~ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Does in-place Gaussian blur, the image is modified in-place + filters.GaussianBlur(img, img, x_sigma, y_sigma, callback=None) + + # Returns newly alocated blurred image + res = img.filters.GaussianBlur(x_sigma, y_sigma, callback=None) + +------------------------------------------------------------------------------- + +Gaussian blur (low pass) filters implemented as bilinear separable +convolution. + +TIP: See link:example_py_blur.html[blur example]. + +include::images/blur/images.txt[] + Ditherings ~~~~~~~~~~ @@ -17,10 +40,10 @@ import gfxprim.core as core import gfxprim.filters as filters # Returns img dithered to 1-bit Grayscale as a new image - res = img.filters.FloydSteinbergAlloc(core.C.PIXEL_G1, None) + res = img.filters.FloydSteinbergAlloc(core.C.PIXEL_G1, callback=None) # Returns img dithered to 1-bit Grayscale as a new image - res = img.filters.HilbertPeanoAlloc(core.C.PIXEL_G1, None) + res = img.filters.HilbertPeanoAlloc(core.C.PIXEL_G1, callback=None) ------------------------------------------------------------------------------- @@ -32,4 +55,4 @@ The first parameter is pixel type, the second is progress callback. For more information and example images see link:filters_dithering.html[C dithering documentation]. -TIP: See complete link:example_py_dithering.html[example]. +TIP: See link:example_py_dithering.html[dithering example]. diff --git a/doc/images/blur/Makefile b/doc/images/blur/Makefile new file mode 100644 index 0000000..4c642ec --- /dev/null +++ b/doc/images/blur/Makefile @@ -0,0 +1,7 @@ +all: images.txt + +images.txt: regen.py + @./regen.py + +clean: + rm -f *.png images.txt diff --git a/doc/images/blur/images.txt b/doc/images/blur/images.txt new file mode 100644 index 0000000..b9d7434 --- /dev/null +++ b/doc/images/blur/images.txt @@ -0,0 +1,17 @@ +.Example Images: Original Image; Gaussian Blur 2 2, 0 4, 4 0, 10 10 +image:images/orig/lenna_small.png[ + "Original Image", + link="images/orig/lenna.png"] +image:images/blur/lenna_small_2_2.png[ + "Gaussian Blur x_sig=2 y_sig=2", + link="images/blur/lenna_2_2.png"] +image:images/blur/lenna_small_0_4.png[ + "Gaussian Blur x_sig=4 y_sig=4", + link="images/blur/lenna_0_4.png"] +image:images/blur/lenna_small_4_0.png[ + "Gaussian Blur x_sig=0 y_sig=0", + link="images/blur/lenna_4_0.png"] +image:images/blur/lenna_small_10_10.png[ + "Gaussian Blur x_sig=10 y_sig=10", + link="images/blur/lenna_10_10.png"] + diff --git a/doc/images/blur/lenna_0_4.png b/doc/images/blur/lenna_0_4.png new file mode 100644 index 0000000..05e3814 Binary files /dev/null and b/doc/images/blur/lenna_0_4.png differ diff --git a/doc/images/blur/lenna_10_10.png b/doc/images/blur/lenna_10_10.png new file mode 100644 index 0000000..396fc7e Binary files /dev/null and b/doc/images/blur/lenna_10_10.png differ diff --git a/doc/images/blur/lenna_2_2.png b/doc/images/blur/lenna_2_2.png new file mode 100644 index 0000000..fa8bf6f Binary files /dev/null and b/doc/images/blur/lenna_2_2.png differ diff --git a/doc/images/blur/lenna_4_0.png b/doc/images/blur/lenna_4_0.png new file mode 100644 index 0000000..dc8bc7e Binary files /dev/null and b/doc/images/blur/lenna_4_0.png differ diff --git a/doc/images/blur/lenna_small_0_4.png b/doc/images/blur/lenna_small_0_4.png new file mode 100644 index 0000000..ad3e5a2 Binary files /dev/null and b/doc/images/blur/lenna_small_0_4.png differ diff --git a/doc/images/blur/lenna_small_10_10.png b/doc/images/blur/lenna_small_10_10.png new file mode 100644 index 0000000..63493dd Binary files /dev/null and b/doc/images/blur/lenna_small_10_10.png differ diff --git a/doc/images/blur/lenna_small_2_2.png b/doc/images/blur/lenna_small_2_2.png new file mode 100644 index 0000000..ad82e72 Binary files /dev/null and b/doc/images/blur/lenna_small_2_2.png differ diff --git a/doc/images/blur/lenna_small_4_0.png b/doc/images/blur/lenna_small_4_0.png new file mode 100644 index 0000000..9fe4a10 Binary files /dev/null and b/doc/images/blur/lenna_small_4_0.png differ diff --git a/doc/images/blur/regen.py b/doc/images/blur/regen.py new file mode 100755 index 0000000..13e9d39 --- /dev/null +++ b/doc/images/blur/regen.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +import sys + +import gfxprim.core as core +import gfxprim.loaders as loaders +import gfxprim.filters as filters + +orig_path='images/orig/' +self_path='images/blur/' + +def write_asciidoc_head(f): + f.write('.Example Images: Original Image; Gaussian Blur 2 2, 0 4, 4 0, 10 10n') + f.write('image:' + orig_path + 'lenna_small.png[n') + f.write('t"Original Image",n') + f.write('tlink="' + orig_path + 'lenna.png"]n') + +def write_img_asciidoc(f, name, fname): + f.write('image:' + self_path + 'lenna_small_' + fname + '.png[n') + f.write('t"' + name + '",n') + f.write('tlink="' + self_path + 'lenna_' + fname + '.png"]n') + +def write_asciidoc_tail(f): + f.write('n') + +def gen_blur(f, img, img_small, x_sigma, y_sigma): + print("Generating Blur %s %s" % (x_sigma, y_sigma)) + name = '%s_%s' % (x_sigma, y_sigma) + res = img.filters.GaussianBlurAlloc(x_sigma, y_sigma); + res.loaders.Save('lenna_' + name + '.png') + res = res.filters.ResizeAlloc(img_small.w, img_small.h, 2) + res.loaders.Save('lenna_small_' + name + '.png') + write_img_asciidoc(f, 'Gaussian Blur x_sig=%s y_sig=%s' % (y_sigma, y_sigma), name) + +def main(): + lenna = loaders.Load('../../' + orig_path + 'lenna.png') + lenna_small = loaders.Load('../../' + orig_path + 'lenna_small.png') + + f = open('images.txt', 'w') + + write_asciidoc_head(f) + + gen_blur(f, lenna, lenna_small, 2, 2) + gen_blur(f, lenna, lenna_small, 0, 4) + gen_blur(f, lenna, lenna_small, 4, 0) + gen_blur(f, lenna, lenna_small, 10, 10) + + write_asciidoc_tail(f) + + f.close() + +if __name__ == '__main__': + main() diff --git a/doc/images/orig/lenna.png b/doc/images/orig/lenna.png new file mode 100644 index 0000000..475bc7a Binary files /dev/null and b/doc/images/orig/lenna.png differ diff --git a/doc/images/orig/lenna_small.png b/doc/images/orig/lenna_small.png new file mode 100644 index 0000000..018ad48 Binary files /dev/null and b/doc/images/orig/lenna_small.png differ
http://repo.or.cz/w/gfxprim.git/commit/f4da24627bdbc2c598e29a04db851d0fc0d8…
commit f4da24627bdbc2c598e29a04db851d0fc0d8ef7d Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 20:35:31 2013 +0200 filters: Blur: Hotfix the GaussianBlurAlloc() case The code wrongly passed src as src and dst as dst to both vertical and horizontal convolution, which is wrong in case src != dst because the result from the first convolution is always lost. Workaround this by passing dst as both src and dst to the second one. The drawback is that the second convolution would not run in multiple threads but at least it yields correct result. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/filters/GP_Blur.c b/libs/filters/GP_Blur.c index 2069484..51155cf 100644 --- a/libs/filters/GP_Blur.c +++ b/libs/filters/GP_Blur.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> * + * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> * * * *****************************************************************************/ @@ -79,6 +79,7 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, { unsigned int size_x = gaussian_kernel_size(x_sigma); unsigned int size_y = gaussian_kernel_size(y_sigma); + GP_Context *tmp = dst; GP_DEBUG(1, "Gaussian blur x_sigma=%2.3f y_sigma=%2.3f kernel %ix%i image %ux%u", x_sigma, y_sigma, size_x, size_y, w_src, h_src); @@ -116,18 +117,26 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, if (GP_FilterHConvolutionMP_Raw(¶ms)) return 1; + } else { + tmp = src; } if (new_callback != NULL) new_callback->callback = gaussian_callback_vert; + /* + * TODO: This part runs always in-place, which is wrong if + * we run in multiple threads as this part would run + * only singlethreaded. We need temp buffer for the + * first part in this case. + */ /* compute kernel and apply in vertical direction */ if (y_sigma > 0) { float kernel_y[size_y]; float sum = gaussian_kernel_init(y_sigma, kernel_y); GP_ConvolutionParams params = { - .src = src, + .src = tmp, .x_src = x_src, .y_src = y_src, .w_src = w_src,
http://repo.or.cz/w/gfxprim.git/commit/92b4a111042c16733e2c23b1ed41e7a56ac5…
commit 92b4a111042c16733e2c23b1ed41e7a56ac52023 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 20:24:55 2013 +0200 filters: Convolution; Minor cleanup. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/filters/GP_Blur.c b/libs/filters/GP_Blur.c index bd66c9c..2069484 100644 --- a/libs/filters/GP_Blur.c +++ b/libs/filters/GP_Blur.c @@ -74,14 +74,14 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, GP_Size w_src, GP_Size h_src, GP_Context *dst, GP_Coord x_dst, GP_Coord y_dst, - float sigma_x, float sigma_y, + float x_sigma, float y_sigma, GP_ProgressCallback *callback) { - unsigned int size_x = gaussian_kernel_size(sigma_x); - unsigned int size_y = gaussian_kernel_size(sigma_y); + unsigned int size_x = gaussian_kernel_size(x_sigma); + unsigned int size_y = gaussian_kernel_size(y_sigma); - GP_DEBUG(1, "Gaussian blur sigma_x=%2.3f sigma_y=%2.3f kernel %ix%i image %ux%u", - sigma_x, sigma_y, size_x, size_y, w_src, h_src); + GP_DEBUG(1, "Gaussian blur x_sigma=%2.3f y_sigma=%2.3f kernel %ix%i image %ux%u", + x_sigma, y_sigma, size_x, size_y, w_src, h_src); GP_ProgressCallback *new_callback = NULL; @@ -94,9 +94,9 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, new_callback = &gaussian_callback; /* compute kernel and apply in horizontal direction */ - if (sigma_x > 0) { + if (x_sigma > 0) { float kernel_x[size_x]; - float sum = gaussian_kernel_init(sigma_x, kernel_x); + float sum = gaussian_kernel_init(x_sigma, kernel_x); GP_ConvolutionParams params = { .src = src, @@ -122,9 +122,9 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src, new_callback->callback = gaussian_callback_vert; /* compute kernel and apply in vertical direction */ - if (sigma_y > 0) { + if (y_sigma > 0) { float kernel_y[size_y]; - float sum = gaussian_kernel_init(sigma_y, kernel_y); + float sum = gaussian_kernel_init(y_sigma, kernel_y); GP_ConvolutionParams params = { .src = src, @@ -155,7 +155,7 @@ int GP_FilterGaussianBlurEx(const GP_Context *src, GP_Size w_src, GP_Size h_src, GP_Context *dst, GP_Coord x_dst, GP_Coord y_dst, - float sigma_x, float sigma_y, + float x_sigma, float y_sigma, GP_ProgressCallback *callback) { GP_CHECK(src->pixel_type == dst->pixel_type); @@ -166,13 +166,13 @@ int GP_FilterGaussianBlurEx(const GP_Context *src, return GP_FilterGaussianBlur_Raw(src, x_src, y_src, w_src, h_src, dst, x_dst, y_dst, - sigma_x, sigma_y, callback); + x_sigma, y_sigma, callback); } GP_Context *GP_FilterGaussianBlurExAlloc(const GP_Context *src, GP_Coord x_src, GP_Coord y_src, GP_Size w_src, GP_Size h_src, - float sigma_x, float sigma_y, + float x_sigma, float y_sigma, GP_ProgressCallback *callback) { GP_Context *dst = GP_ContextAlloc(w_src, h_src, src->pixel_type); @@ -181,7 +181,7 @@ GP_Context *GP_FilterGaussianBlurExAlloc(const GP_Context *src, return NULL; if (GP_FilterGaussianBlur_Raw(src, x_src, y_src, w_src, h_src, dst, - 0, 0, sigma_x, sigma_y, callback)) { + 0, 0, x_sigma, y_sigma, callback)) { GP_ContextFree(dst); return NULL; } diff --git a/libs/filters/GP_LinearConvolution.gen.c.t b/libs/filters/GP_LinearConvolution.gen.c.t index 2a7337c..70fe090 100644 --- a/libs/filters/GP_LinearConvolution.gen.c.t +++ b/libs/filters/GP_LinearConvolution.gen.c.t @@ -54,10 +54,6 @@ static int h_lin_conv_{{ pt.name }}(const GP_Context *src, int ikernel[kw], ikern_div; uint32_t size = w_src + kw - 1; - GP_DEBUG(1, "Horizontal linear convolution kernel width %u " - "offset %ix%i rectangle %ux%u", - kw, x_src, y_src, w_src, h_src); - for (i = 0; i < kw; i++) ikernel[i] = kernel[i] * MUL + 0.5; @@ -163,6 +159,10 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, float kernel[], uint32_t kw, float kern_div, GP_ProgressCallback *callback) { + GP_DEBUG(1, "Horizontal linear convolution kernel width %u " + "offset %ix%i rectangle %ux%u", + kw, x_src, y_src, w_src, h_src); + switch (src->pixel_type) { %% for pt in pixeltypes %% if not pt.is_unknown() and not pt.is_palette()
http://repo.or.cz/w/gfxprim.git/commit/2212fd623e8e09bf468d3b72e4468a604511…
commit 2212fd623e8e09bf468d3b72e4468a604511a9c9 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 20:04:19 2013 +0200 filters: Linear: Run one thread on in-place filter If filter is run in-place (src == dst) the filter cannot run in more than one thread (as threads would override values read by other threads). This patch changes the Linear Convolution filters to default to one thread if in-place usage is detected instead of the ASSERTS() Also update linear convolution docs. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/doc/filters.txt b/doc/filters.txt index c69ccdd..ef6b123 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -714,6 +714,11 @@ and array of kernel values. The last function prints convolution kernel in human-readable format into the stdout. +WARNING: If filter is executed in-place the work cannot be distributed between + threads (as some of the threads will overwrite values read by other + threads). In this case convolution filters runs in one thread + regardless of if threads are eanbled or not. + [source,c] ------------------------------------------------------------------------------- #include <GP.h> diff --git a/libs/filters/GP_LinearThreads.c b/libs/filters/GP_LinearThreads.c index 218110b..da55ce9 100644 --- a/libs/filters/GP_LinearThreads.c +++ b/libs/filters/GP_LinearThreads.c @@ -65,8 +65,10 @@ int GP_FilterHConvolutionMP_Raw(const GP_ConvolutionParams *params) if (t == 1) return GP_FilterHConvolution_Raw(params); - GP_ASSERT(params->src != params->dst, - "Multithreaded convolution can't work in-place"); + if (params->src == params->dst) { + GP_DEBUG(1, "In-place filter detected, running in one thread."); + return GP_FilterHConvolution_Raw(params); + } GP_PROGRESS_CALLBACK_MP(callback_mp, params->callback); @@ -113,8 +115,10 @@ int GP_FilterVConvolutionMP_Raw(const GP_ConvolutionParams *params) if (t == 1) return GP_FilterVConvolution_Raw(params); - GP_ASSERT(params->src != params->dst, - "Multithreaded convolution can't work in-place"); + if (params->src == params->dst) { + GP_DEBUG(1, "In-place filter detected, running in one thread."); + return GP_FilterVConvolution_Raw(params); + } GP_PROGRESS_CALLBACK_MP(callback_mp, params->callback); @@ -160,8 +164,10 @@ int GP_FilterConvolutionMP_Raw(const GP_ConvolutionParams *params) if (t == 1) return GP_FilterConvolution_Raw(params); - GP_ASSERT(params->src != params->dst, - "Multithreaded convolution can't work in-place"); + if (params->src == params->dst) { + GP_DEBUG(1, "In-place filter detected, running in one thread."); + return GP_FilterConvolution_Raw(params); + } GP_PROGRESS_CALLBACK_MP(callback_mp, params->callback);
http://repo.or.cz/w/gfxprim.git/commit/8114cdf5bd54ace1d44cbe94e8b980d924fd…
commit 8114cdf5bd54ace1d44cbe94e8b980d924fd4d20 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 18:36:26 2013 +0200 demos: py_simple: Drop None callback parameters. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/demos/py_simple/blur.py b/demos/py_simple/blur.py index 3735346..70e9da5 100755 --- a/demos/py_simple/blur.py +++ b/demos/py_simple/blur.py @@ -15,9 +15,9 @@ def main(): # Load Image img = loaders.Load(sys.argv[2]) # Do in-place gaussian blur - filters.GaussianBlur(img, img, radii, radii, None) + filters.GaussianBlur(img, img, radii, radii) # Save result - loaders.SaveJPG(img, "out.jpg", None) + img.loaders.SaveJPG("out.jpg") if __name__ == '__main__': main() diff --git a/demos/py_simple/dither.py b/demos/py_simple/dither.py index 0437931..d2b9e04 100755 --- a/demos/py_simple/dither.py +++ b/demos/py_simple/dither.py @@ -13,7 +13,7 @@ def main(): # Load Image img = loaders.Load(sys.argv[1]) # Use Floyd-Steinberg dithering - res = img.filters.FloydSteinbergAlloc(core.C.PIXEL_G1, None) + res = img.filters.FloydSteinbergAlloc(core.C.PIXEL_G1) # Save result into grayscale png res.loaders.SavePNG("out.png") diff --git a/demos/py_simple/pygtk_example.py b/demos/py_simple/pygtk_example.py index e7b1643..0c220b3 100755 --- a/demos/py_simple/pygtk_example.py +++ b/demos/py_simple/pygtk_example.py @@ -30,7 +30,7 @@ class HelloWorld: self.window.show() self.image.show() - img = loaders.LoadImage(sys.argv[2], None) + img = loaders.LoadImage(sys.argv[2]) self.pixmap = gtk.gdk.Pixmap(None, img.w, img.h, 24) self.gc = gtk.gdk.Drawable.new_gc(self.pixmap) diff --git a/demos/py_simple/resize.py b/demos/py_simple/resize.py index b9e65c1..38a5b78 100755 --- a/demos/py_simple/resize.py +++ b/demos/py_simple/resize.py @@ -16,7 +16,7 @@ def main(): # Load Image src = loaders.Load(sys.argv[1]) # Resize image to the half of the original - res = src.filters.ResizeAlloc(src.w//2, src.h//2, 2, None) + res = src.filters.ResizeAlloc(src.w//2, src.h//2, 2) # Save Image res.loaders.Save(sys.argv[2]) diff --git a/demos/py_simple/rotate90.py b/demos/py_simple/rotate90.py index 2dcb3f5..3a49af1 100755 --- a/demos/py_simple/rotate90.py +++ b/demos/py_simple/rotate90.py @@ -16,7 +16,7 @@ def main(): # Load Image src = loaders.Load(sys.argv[1]) # Rotate by 90 degrees - res = src.filters.Rotate90Alloc(None) + res = src.filters.Rotate90Alloc() # Save Image res.loaders.Save(sys.argv[2])
http://repo.or.cz/w/gfxprim.git/commit/73403e601211315ce51c3e41ddfec233cb84…
commit 73403e601211315ce51c3e41ddfec233cb8415ee Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 18:26:14 2013 +0200 pywrap: Add default typemap for callback=NULL Now all callback args have default NULL value. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/pylib/gfxprim/common.i b/pylib/gfxprim/common.i index e9242d7..47ae8f0 100644 --- a/pylib/gfxprim/common.i +++ b/pylib/gfxprim/common.i @@ -12,6 +12,13 @@ %nodefaultctor; /* + * All progress callbacks have default NULL value + */ +%typemap(default) GP_ProgressCallback *callback { + $1 = NULL; +} + +/* * Error handling declarations */
http://repo.or.cz/w/gfxprim.git/commit/069c44a2fb6118fbcfabcf0cf5bac8f1f93c…
commit 069c44a2fb6118fbcfabcf0cf5bac8f1f93c7108 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 27 18:25:15 2013 +0200 build: pywrap: Add deps on common.i into pywrap.mk Now all wrappers are rebuild when common.i is changed. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/pylib/gfxprim/core/Makefile b/pylib/gfxprim/core/Makefile index 476d623..d478c16 100644 --- a/pylib/gfxprim/core/Makefile +++ b/pylib/gfxprim/core/Makefile @@ -4,8 +4,6 @@ LIBNAME=core include $(TOPDIR)/pre.mk include $(TOPDIR)/pywrap.mk -$(SWIG_C): ../common.i - INSTALL_FILES+=C.py include $(TOPDIR)/post.mk diff --git a/pylib/gfxprim/loaders/Makefile b/pylib/gfxprim/loaders/Makefile index 600d233..5daaf56 100644 --- a/pylib/gfxprim/loaders/Makefile +++ b/pylib/gfxprim/loaders/Makefile @@ -7,7 +7,4 @@ include $(TOPDIR)/pre.mk LDLIBS+=$(LDLIBS_LOADERS) include $(TOPDIR)/pywrap.mk - -$(SWIG_C): ../common.i - include $(TOPDIR)/post.mk diff --git a/pywrap.mk b/pywrap.mk index 0df0f10..15b78c4 100644 --- a/pywrap.mk +++ b/pywrap.mk @@ -30,6 +30,9 @@ else # VERBOSE @$(SWIG) $(SWIGOPTS) -python $(INCLUDES) $< endif # VERBOSE +# All swig sources depend on common.i +$(SWIG_C): ../common.i + $(SWIG_LIB): $(SWIG_C) ifdef VERBOSE $(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) $(PYTHON_INCLUDE) --shared $(LDLIBS) $(LDLIBS_GP) -L$(TOPDIR)/build/ -o $@ ----------------------------------------------------------------------- Summary of changes: demos/py_simple/blur.py | 4 +- demos/py_simple/dither.py | 2 +- demos/py_simple/pygtk_example.py | 2 +- demos/py_simple/resize.py | 2 +- demos/py_simple/rotate90.py | 2 +- doc/Makefile | 7 ++- ...example_py_backends.txt => example_py_blur.txt} | 8 ++-- doc/filters.txt | 5 ++ doc/filters_python.txt | 29 ++++++++++- doc/images/blur/Makefile | 7 +++ doc/images/blur/images.txt | 17 ++++++ doc/images/blur/lenna_0_4.png | Bin 0 -> 236705 bytes doc/images/blur/lenna_10_10.png | Bin 0 -> 143058 bytes doc/images/blur/lenna_2_2.png | Bin 0 -> 229699 bytes doc/images/blur/lenna_4_0.png | Bin 0 -> 231739 bytes doc/images/blur/lenna_small_0_4.png | Bin 0 -> 25526 bytes doc/images/blur/lenna_small_10_10.png | Bin 0 -> 17520 bytes doc/images/blur/lenna_small_2_2.png | Bin 0 -> 26436 bytes doc/images/blur/lenna_small_4_0.png | Bin 0 -> 25437 bytes doc/images/blur/regen.py | 53 ++++++++++++++++++++ doc/images/{dither => orig}/lenna.png | Bin 394244 -> 394244 bytes doc/images/orig/lenna_small.png | Bin 0 -> 32066 bytes libs/filters/GP_Blur.c | 39 +++++++++------ libs/filters/GP_LinearConvolution.gen.c.t | 8 ++-- libs/filters/GP_LinearThreads.c | 18 +++++-- pylib/gfxprim/common.i | 7 +++ pylib/gfxprim/core/Makefile | 2 - pylib/gfxprim/loaders/Makefile | 3 - pywrap.mk | 3 + 29 files changed, 174 insertions(+), 44 deletions(-) copy doc/{example_py_backends.txt => example_py_blur.txt} (51%) create mode 100644 doc/images/blur/Makefile create mode 100644 doc/images/blur/images.txt create mode 100644 doc/images/blur/lenna_0_4.png create mode 100644 doc/images/blur/lenna_10_10.png create mode 100644 doc/images/blur/lenna_2_2.png create mode 100644 doc/images/blur/lenna_4_0.png create mode 100644 doc/images/blur/lenna_small_0_4.png create mode 100644 doc/images/blur/lenna_small_10_10.png create mode 100644 doc/images/blur/lenna_small_2_2.png create mode 100644 doc/images/blur/lenna_small_4_0.png create mode 100755 doc/images/blur/regen.py copy doc/images/{dither => orig}/lenna.png (100%) create mode 100644 doc/images/orig/lenna_small.png 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
0
0
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc0-190-g5c9dc00
by metan
26 Sep '13
26 Sep '13
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git. The branch, master has been updated via 5c9dc009be46441c7144aeed9461616baeb931a2 (commit) via cdfa30d0778d9c858b177df70de3eeda298d1614 (commit) via b3f1272a01421ef58f93055ef540b4da7f2e8a9b (commit) from 65def9162f29b2c9e8b4d49192289cc5fa95c3e1 (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/5c9dc009be46441c7144aeed9461616baeb9…
commit 5c9dc009be46441c7144aeed9461616baeb931a2 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 26 23:15:29 2013 +0200 loaders: BMP, PNM, TIFF: Fix abort path. * Unlink file if GP_Save{BMP, PNM, TIFF}() was aborted. * Fix memleak if GP_SaveTIFF() was aborted. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c index 3a56413..d7ea61f 100644 --- a/libs/loaders/GP_BMP.c +++ b/libs/loaders/GP_BMP.c @@ -883,6 +883,7 @@ int GP_SaveBMP(const GP_Context *src, const char *dst_path, err1: fclose(f); err0: + unlink(dst_path); errno = err; return 1; } diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c index 027dae2..09018fe 100644 --- a/libs/loaders/GP_PNM.c +++ b/libs/loaders/GP_PNM.c @@ -659,6 +659,7 @@ int GP_SavePBM(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback) { FILE *f; + int err; GP_DEBUG(1, "Saving context %ux%u %s to '%s'", src->w, src->h, GP_PixelTypeName(src->pixel_type), dst_path); @@ -676,19 +677,22 @@ int GP_SavePBM(const GP_Context *src, const char *dst_path, return 1; if (fprintf(f, "P1n%u %un", - (unsigned int) src->w, (unsigned int) src->h) < 0) - goto err; + (unsigned int) src->w, (unsigned int) src->h) < 0) { + err = EIO; + goto err0; + } - if (save_ascii(f, src, callback, 1)) - goto err; + if ((err = save_ascii(f, src, callback, 1))) + goto err0; if (fclose(f)) - return 1; + goto err0; return 0; -err: +err0: fclose(f); - errno = EIO; + unlink(dst_path); + errno = err; return 1; } @@ -866,6 +870,7 @@ int GP_SavePGM(const GP_Context *src, const char *dst_path, err1: fclose(f); err0: + unlink(dst_path); errno = err; return 1; } @@ -1048,9 +1053,8 @@ err1: fclose(f); err0: errno = err; + unlink(dst_path); return 1; - errno = ENOSYS; - return -1; } GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback) diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c index 3a7b422..4443127 100644 --- a/libs/loaders/GP_TIFF.c +++ b/libs/loaders/GP_TIFF.c @@ -543,20 +543,15 @@ static int save_grayscale(TIFF *tiff, const GP_Context *src, if (ret == -1) { //TODO TIFF ERROR GP_DEBUG(1, "TIFFWriteEncodedStrip failed"); - errno = EIO; - return 1; + return EIO; } if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) { GP_DEBUG(1, "Operation aborted"); - errno = ECANCELED; - return 1; + return ECANCELED; } } - TIFFClose(tiff); - - GP_ProgressCallbackDone(callback); return 0; } @@ -598,14 +593,10 @@ static int save_rgb(TIFF *tiff, const GP_Context *src, if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) { GP_DEBUG(1, "Operation aborted"); - errno = ECANCELED; - return 1; + return ECANCELED; } } - TIFFClose(tiff); - - GP_ProgressCallbackDone(callback); return 0; } @@ -613,6 +604,7 @@ int GP_SaveTIFF(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback) { TIFF *tiff; + int err = 0; if (GP_PixelHasFlags(src->pixel_type, GP_PIXEL_HAS_ALPHA)) { GP_DEBUG(1, "Alpha channel not supported yet"); @@ -642,6 +634,7 @@ int GP_SaveTIFF(const GP_Context *src, const char *dst_path, if (tiff == NULL) { GP_DEBUG(1, "Failed to open tiff '%s'", dst_path); + //ERRNO? return 1; } @@ -651,20 +644,32 @@ int GP_SaveTIFF(const GP_Context *src, const char *dst_path, TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - /* Save grayscale */ - if (GP_PixelHasFlags(src->pixel_type, GP_PIXEL_IS_GRAYSCALE)) - return save_grayscale(tiff, src, callback); - switch (src->pixel_type) { case GP_PIXEL_RGB888: case GP_PIXEL_BGR888: case GP_PIXEL_xRGB8888: - return save_rgb(tiff, src, callback); + err = save_rgb(tiff, src, callback); + break; + case GP_PIXEL_G1: + case GP_PIXEL_G2: + case GP_PIXEL_G4: + case GP_PIXEL_G8: + err = save_grayscale(tiff, src, callback); + break; default: + GP_BUG("Wrong pixel type"); break; } - GP_BUG("Should not be reached"); + if (err) { + TIFFClose(tiff); + unlink(dst_path); + errno = err; + return 1; + } + + TIFFClose(tiff); + GP_ProgressCallbackDone(callback); return 0; }
http://repo.or.cz/w/gfxprim.git/commit/cdfa30d0778d9c858b177df70de3eeda298d…
commit cdfa30d0778d9c858b177df70de3eeda298d1614 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 26 22:47:46 2013 +0200 tests: loaders: New SaveAbort test. New test that aborts file saving and checks that file was removed and memory freed. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile index 24cd1e4..66edb90 100644 --- a/tests/loaders/Makefile +++ b/tests/loaders/Makefile @@ -2,9 +2,9 @@ TOPDIR=../.. include $(TOPDIR)/pre.mk CSOURCES=loaders_suite.c PNG.c PBM.c PGM.c PPM.c -GENSOURCES=SaveLoad.gen.c +GENSOURCES=SaveLoad.gen.c SaveAbort.gen.c -APPS=loaders_suite PNG PBM PGM PPM SaveLoad.gen +APPS=loaders_suite PNG PBM PGM PPM SaveLoad.gen SaveAbort.gen include ../tests.mk diff --git a/tests/loaders/SaveLoad.gen.c.t b/tests/loaders/SaveAbort.gen.c.t similarity index 73% copy from tests/loaders/SaveLoad.gen.c.t copy to tests/loaders/SaveAbort.gen.c.t index df2767f..eb0796c 100644 --- a/tests/loaders/SaveLoad.gen.c.t +++ b/tests/loaders/SaveAbort.gen.c.t @@ -23,7 +23,7 @@ %% extends "base.test.c.t" %% block descr -Iterate over all pixel types, try to save and load back context. +Iterate over all pixel types, try to save context but abort it from callback. %% endblock descr %% block body @@ -33,21 +33,24 @@ Iterate over all pixel types, try to save and load back context. #include <stdlib.h> #include <core/GP_Context.h> -#include <core/GP_GetPutPixel.h> #include <loaders/GP_Loaders.h> #include "tst_test.h" -%% set fmts = ['PNG', 'JPG', 'TIFF', 'BMP', 'PBM', 'PGM', 'PPM', 'PNM'] +%% import "savers.t" as savers typedef int (*Save)(const GP_Context *src, const char *path, GP_ProgressCallback *callback); -typedef GP_Context *(*Load)(const char *path, GP_ProgressCallback *callback); -static int test(Save Saver, Load Loader, GP_PixelType pixel_type) +static int progress_callback(GP_ProgressCallback *self) +{ + (void) self; + return 1; +} + +static int test(Save Saver, GP_PixelType pixel_type) { GP_Context *src; - GP_Context *res; - unsigned int x, y; + GP_ProgressCallback callback ={.callback = progress_callback}; int ret = TST_SUCCESS; src = GP_ContextAlloc(100, 100, pixel_type); @@ -57,11 +60,7 @@ static int test(Save Saver, Load Loader, GP_PixelType pixel_type) return TST_UNTESTED; } - for (x = 0; x < src->w; x++) - for (y = 0; y < src->w; y++) - GP_PutPixel(src, x, y, 0); - - if (Saver(src, "testfile", NULL)) { + if (Saver(src, "testfile", &callback)) { if (errno == ENOSYS) { tst_msg("Unimplemented pixel value"); ret = TST_SKIPPED; @@ -74,43 +73,35 @@ static int test(Save Saver, Load Loader, GP_PixelType pixel_type) goto err; } - tst_msg("Saver failed with %s", strerror(errno)); - ret = TST_FAILED; - goto err; - } - - res = Loader("testfile", NULL); + if (errno == ECANCELED) { + if (access("testfile", F_OK) == 0) { + tst_msg("Operation canceled but file exists"); + ret = TST_FAILED; + goto err; + } else { + goto err; + } + } - if (!res) { - tst_msg("Failed to load saved image"); + tst_msg("Saver failed with %s", strerror(errno)); ret = TST_FAILED; goto err; - } - - tst_msg("Loaded back as %s", GP_PixelTypeName(res->pixel_type)); - - if (res->w != src->w || res->h != src->h) { - tst_msg("Invalid loaded image size %ux%u", res->w, res->h); - ret = TST_FAILED; - } - - if (GP_GetPixel(res, 0, 0) != 0) { - tst_msg("Pixel value is wrong %x", GP_GetPixel(res, 0, 0)); + } else { + tst_msg("Succedded unexpectedly"); ret = TST_FAILED; } - GP_ContextFree(res); err: GP_ContextFree(src); return ret; } -%% for fmt in fmts +%% for fmt in savers.fmts %% for pt in pixeltypes %% if not pt.is_unknown() static int test_{{ fmt }}_{{ pt.name }}(void) { - return test(GP_Save{{ fmt }}, GP_Load{{ fmt }}, GP_PIXEL_{{ pt.name }}); + return test(GP_Save{{ fmt }}, GP_PIXEL_{{ pt.name }}); } %% endif @@ -118,9 +109,9 @@ static int test_{{ fmt }}_{{ pt.name }}(void) %% endfor const struct tst_suite tst_suite = { - .suite_name = "SaveLoad", + .suite_name = "SaveAbort", .tests = { -%% for fmt in fmts +%% for fmt in savers.fmts %% for pt in pixeltypes %% if not pt.is_unknown() {.name = "{{ fmt }} {{ pt.name }}", diff --git a/tests/loaders/SaveLoad.gen.c.t b/tests/loaders/SaveLoad.gen.c.t index df2767f..81478c0 100644 --- a/tests/loaders/SaveLoad.gen.c.t +++ b/tests/loaders/SaveLoad.gen.c.t @@ -38,7 +38,7 @@ Iterate over all pixel types, try to save and load back context. #include "tst_test.h" -%% set fmts = ['PNG', 'JPG', 'TIFF', 'BMP', 'PBM', 'PGM', 'PPM', 'PNM'] +%% import "savers.t" as savers typedef int (*Save)(const GP_Context *src, const char *path, GP_ProgressCallback *callback); typedef GP_Context *(*Load)(const char *path, GP_ProgressCallback *callback); @@ -105,7 +105,7 @@ err: return ret; } -%% for fmt in fmts +%% for fmt in savers.fmts %% for pt in pixeltypes %% if not pt.is_unknown() static int test_{{ fmt }}_{{ pt.name }}(void) @@ -120,7 +120,7 @@ static int test_{{ fmt }}_{{ pt.name }}(void) const struct tst_suite tst_suite = { .suite_name = "SaveLoad", .tests = { -%% for fmt in fmts +%% for fmt in savers.fmts %% for pt in pixeltypes %% if not pt.is_unknown() {.name = "{{ fmt }} {{ pt.name }}", diff --git a/tests/loaders/savers.t b/tests/loaders/savers.t new file mode 100644 index 0000000..2403cfe --- /dev/null +++ b/tests/loaders/savers.t @@ -0,0 +1,2 @@ +{# Formats for which save is implemented #} +%% set fmts = ['PNG', 'JPG', 'TIFF', 'BMP', 'PBM', 'PGM', 'PPM', 'PNM'] diff --git a/tests/loaders/test_list.txt b/tests/loaders/test_list.txt index e9fdf3d..162943e 100644 --- a/tests/loaders/test_list.txt +++ b/tests/loaders/test_list.txt @@ -5,3 +5,4 @@ PBM PGM PPM SaveLoad.gen +SaveAbort.gen
http://repo.or.cz/w/gfxprim.git/commit/b3f1272a01421ef58f93055ef540b4da7f2e…
commit b3f1272a01421ef58f93055ef540b4da7f2e8a9b Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 26 22:35:15 2013 +0200 render_utils.py: Add ./ to jinja2 template paths. This allows us to import and include files located in current directory. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/pylib/gp_codegen/render_utils.py b/pylib/gp_codegen/render_utils.py index c5433ea..c0177db 100644 --- a/pylib/gp_codegen/render_utils.py +++ b/pylib/gp_codegen/render_utils.py @@ -40,7 +40,7 @@ def create_environment(config, template_dir): env = jinja2.Environment( line_statement_prefix = "%%", undefined = jinja2.StrictUndefined, - loader = jinja2.FileSystemLoader(template_dir)) + loader = jinja2.FileSystemLoader([template_dir,"./"])) env.globals['undefined'] = jinja2.StrictUndefined() env.globals['pixelsizes'] = config.pixelsizes env.globals['pixelsizes_by_bpp'] = config.pixelsizes_by_bpp ----------------------------------------------------------------------- Summary of changes: libs/loaders/GP_BMP.c | 1 + libs/loaders/GP_PNM.c | 22 ++++--- libs/loaders/GP_TIFF.c | 41 +++++++------ pylib/gp_codegen/render_utils.py | 2 +- tests/loaders/Makefile | 4 +- .../{SaveLoad.gen.c.t => SaveAbort.gen.c.t} | 63 ++++++++----------- tests/loaders/SaveLoad.gen.c.t | 6 +- tests/loaders/savers.t | 2 + tests/loaders/test_list.txt | 1 + 9 files changed, 73 insertions(+), 69 deletions(-) copy tests/loaders/{SaveLoad.gen.c.t => SaveAbort.gen.c.t} (73%) create mode 100644 tests/loaders/savers.t repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive no reply. -- gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
0
0
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc0-187-g65def91
by metan
24 Sep '13
24 Sep '13
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git. The branch, master has been updated via 65def9162f29b2c9e8b4d49192289cc5fa95c3e1 (commit) via 70a17f43a0900e703f5bcd2eeafb55721000eb8d (commit) via ba3c107efd52870c43fe8cd2255c5c6f2bec0379 (commit) via 84bb1080f66c943353a9e3aac213f0837a2ca583 (commit) from 07fc6dce72522e9b86d09dffb4c61be6db3a127c (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/65def9162f29b2c9e8b4d49192289cc5fa95…
commit 65def9162f29b2c9e8b4d49192289cc5fa95c3e1 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Tue Sep 24 18:48:56 2013 +0200 build: Cleanup check_symbols.sh, add Gamma syms. Now check_symbols.sh prints ALL CAPS warning and instructions how to fix the problem. Also add the Gamma table symbols for now, so that the output from the script is clean. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/build/Makefile b/build/Makefile index 075c19d..36c797a 100644 --- a/build/Makefile +++ b/build/Makefile @@ -13,7 +13,7 @@ DYNAMIC_LIB=$(LIB_NAME).so.$(LIB_VERSION).$(LIB_RELEASE) SONAME=$(LIB_NAME).so.$(LIB_MAJOR) SYMLINKS=$(LIB_NAME).so.$(LIB_MAJOR) $(LIB_NAME).so -all: $(STATIC_LIB) $(DYNAMIC_LIB) $(SYMLINKS) +all: $(STATIC_LIB) $(DYNAMIC_LIB) $(SYMLINKS) rebuild: all @@ -24,7 +24,7 @@ ifdef VERBOSE rm -rf $(STATIC_LIB) $(DYNAMIC_LIB) $(SYMLINKS) else @echo "RM $(STATIC_LIB) $(DYNAMIC_LIB) $(SYMLINKS)" - @rm -rf $(STATIC_LIB) $(DYNAMIC_LIB) $(SYMLINKS) + @rm -rf $(STATIC_LIB) $(DYNAMIC_LIB) $(SYMLINKS) endif $(STATIC_LIB): $(LIB_OBJECTS) diff --git a/build/check_symbols.sh b/build/check_symbols.sh index 7f8ff8d..245b324 100755 --- a/build/check_symbols.sh +++ b/build/check_symbols.sh @@ -3,6 +3,9 @@ # Purpose of this script is to check library exported symbols # +FOUND="" +WARN="WARNING : WARNING : WARNING : WARNING : WARNING : WARNING : WARNING : WARNING" + SYMTMPFILE=symbols.txt function grep_sym @@ -38,7 +41,14 @@ function check_symbols for i in `cat $symfile`; do if ! grep "^$i$" $@ 2>&1 > /dev/null; then + if [ -z "$FOUND" ]; then + echo "$WARN" + echo + echo "Following new API symbols found:" + echo + fi find_symbol "$i" + FOUND="yes" fi done } @@ -60,3 +70,10 @@ do_check libGP_backends.so syms/Backend_symbols.txt do_check libGP_grabbers.so syms/Grabbers_symbols.txt do_check libGP_loaders.so syms/Loaders_symbols.txt + +if [ -n "$FOUND" ]; then + echo + echo "Set them static or update lists of exported functions in syms/Foo_symbols.txt" + echo + echo "$WARN" +fi diff --git a/build/syms/Core_symbols.txt b/build/syms/Core_symbols.txt index 10f0e5d..1235998 100644 --- a/build/syms/Core_symbols.txt +++ b/build/syms/Core_symbols.txt @@ -73,3 +73,6 @@ GP_NrThreadsSet GP_ProgressCallbackMP SWIG_exception + +GP_Gamma8_Linear10 +GP_Linear10_Gamma8
http://repo.or.cz/w/gfxprim.git/commit/70a17f43a0900e703f5bcd2eeafb55721000…
commit 70a17f43a0900e703f5bcd2eeafb55721000eb8d Author: Cyril Hrubis <metan(a)ucw.cz> Date: Tue Sep 24 18:30:01 2013 +0200 build: Update list of Text symbols. Add GP_FontC64. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/build/syms/Text_symbols.txt b/build/syms/Text_symbols.txt index 4aa0fe3..1b371e6 100644 --- a/build/syms/Text_symbols.txt +++ b/build/syms/Text_symbols.txt @@ -18,7 +18,8 @@ GP_Print GP_DefaultStyle -GP_FontTiny -GP_FontTinyMono GP_DefaultProportionalFont GP_DefaultConsoleFont +GP_FontTiny +GP_FontTinyMono +GP_FontC64
http://repo.or.cz/w/gfxprim.git/commit/ba3c107efd52870c43fe8cd2255c5c6f2bec…
commit ba3c107efd52870c43fe8cd2255c5c6f2bec0379 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Tue Sep 24 18:25:39 2013 +0200 doc: Update dithering docs. * Update filters C API pages * Start python filter docs Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/doc/Makefile b/doc/Makefile index 9ec16a1..3aec846 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -4,6 +4,7 @@ SOURCES=general.txt context.txt loaders.txt filters.txt basic_types.txt gen.txt pixels.txt coordinate_system.txt coding_style.txt get_put_pixel.txt blits.txt progress_callback.txt text_api.txt event_queue.txt compilation.txt filters_resize.txt + filters_dithering.txt filters_python.txt SOURCES+=core_python.txt gfx_python.txt loaders_python.txt backends_python.txt diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf index 4829c02..4f58bfc 100644 --- a/doc/asciidoc.conf +++ b/doc/asciidoc.conf @@ -44,7 +44,6 @@ endif::disable-javascript[] <li><a href="general.html">Home</a></li> <li><a href="compilation.html">Compilation</a></li> </ul> - <h4>API Pages</h4> <ul> <li><a href="drawing_api.html">Gfx</a></li> @@ -54,12 +53,12 @@ endif::disable-javascript[] <li><a href="backends.html">Backends</a></li> <li><a href="input.html">Input</a></li> </ul> - <h4>Python bindings</h4> <ul> <li><a href="core_python.html">Core</a></li> - <li><a href="gfx_python.html">Gfx</a></li> <li><a href="loaders_python.html">Loaders</a></li> + <li><a href="filters_python.html">Filters</a></li> + <li><a href="gfx_python.html">Gfx</a></li> <li><a href="backends_python.html">Backends</a></li> </ul> </div> diff --git a/doc/example_py_dithering.txt b/doc/example_py_dithering.txt new file mode 100644 index 0000000..d187c7d --- /dev/null +++ b/doc/example_py_dithering.txt @@ -0,0 +1,8 @@ +Dithering Example +----------------- +.A simple program that loads image, dithers it and saves result + +[source,python] +------------------------------------------------------------------ +include::../demos/py_simple/dither.py[] +------------------------------------------------------------------ diff --git a/doc/filters.txt b/doc/filters.txt index c456bf5..c69ccdd 100644 --- a/doc/filters.txt +++ b/doc/filters.txt @@ -904,144 +904,9 @@ finally downscale it to desired size. Dithering ~~~~~~~~~ -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 -^^^^^^^^^^^^^^^ - -Classical Floyd-Steinberg. Produces good results and is a little faster than -the Hilbert-Peano dithering. - -The error is distributed to neighbor pixels as follows: - -[width="10%"] -|=================== -| | X | 7/16 -| 3/16 | 5/16 | 1/16 -|=================== - -And is throwed away at the image borders. - -[source,c] -------------------------------------------------------------------------------- -#include <GP_Filters.h> - -int GP_FilterFloydSteinberg_RGB888(const GP_Context *src, - GP_Context *dst, - GP_ProgressCallback *callback); -------------------------------------------------------------------------------- - -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; 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_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"] +link:filters_dithering.html[Dithering filters] are filters for better loosy +(source pixel type has more bits to represent color or grayscale value) pixel +type conversions. Median ~~~~~~ diff --git a/doc/filters_dithering.txt b/doc/filters_dithering.txt new file mode 100644 index 0000000..91ac47f --- /dev/null +++ b/doc/filters_dithering.txt @@ -0,0 +1,159 @@ +Dithering +--------- + +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 +~~~~~~~~~~~~~~~ + +Classical Floyd-Steinberg. Produces good results and is a little faster than +the Hilbert-Peano dithering. + +The error is distributed to neighbor pixels as follows: + +[width="10%"] +|=================== +| | X | 7/16 +| 3/16 | 5/16 | 1/16 +|=================== + +And is throwed away at the image borders. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_Dither.h> + +int GP_FilterFloydSteinberg(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback); +------------------------------------------------------------------------------- + +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. + +Not all pixel types all supported. If particular combination is not supported +the function returns non-zero and sets errno to 'ENOSYS'. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_Dither.h> + +GP_Context *GP_FilterFloydSteinbergAlloc(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. + +Not all pixel types all supported. If particular combination is not supported +the function returns 'NULL' and sets errno to 'ENOSYS'. + +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.h> +/* or */ +#include <filters/GP_Dither.h> + +int GP_FilterHilbertPeano(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. + +Not all pixel types all supported. If particular combination is not supported +the function returns 'NULL' and sets errno to 'ENOSYS'. + +[source,c] +------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <filters/GP_Dither.h> + +GP_Context *GP_FilterHilbertPeanoAlloc(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. + +Not all pixel types all supported. If particular combination is not supported +the function returns 'NULL' and sets errno to 'ENOSYS'. + +Example Images +^^^^^^^^^^^^^^ +All following images were generated using 'grinder'. +(Click for bigger size) + +.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_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/filters_python.txt b/doc/filters_python.txt new file mode 100644 index 0000000..a7c1ae4 --- /dev/null +++ b/doc/filters_python.txt @@ -0,0 +1,35 @@ +Python Filters module +--------------------- + +The python binding maps mostly to the C API with the 'GP_Filter' prefix +stripped. + +The filter functions could be called directly as +filters.Foo(img, ..)+ or +from submodule as +img.filters.Foo(..)+. Note that in the second case the +image is passed automatically as a first parameter. + +Ditherings +~~~~~~~~~~ + +[source,python] +------------------------------------------------------------------------------- +import gfxprim.core as core +import gfxprim.filters as filters + + # Returns img dithered to 1-bit Grayscale as a new image + res = img.filters.FloydSteinbergAlloc(core.C.PIXEL_G1, None) + + # Returns img dithered to 1-bit Grayscale as a new image + res = img.filters.HilbertPeanoAlloc(core.C.PIXEL_G1, None) + +------------------------------------------------------------------------------- + +Returns new 1-bit Grayscale image which is result from Floyd-Steinberg, +Hilbert-Peano dithering. + +The first parameter is pixel type, the second is progress callback. + +For more information and example images see link:filters_dithering.html[C +dithering documentation]. + +TIP: See complete link:example_py_dithering.html[example].
http://repo.or.cz/w/gfxprim.git/commit/84bb1080f66c943353a9e3aac213f0837a2c…
commit 84bb1080f66c943353a9e3aac213f0837a2ca583 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Tue Sep 24 17:43:57 2013 +0200 filters: ditherings: Cleanups. Change the API of Floyd-Steinberg and Hilbert-Peano ditherings to match rest of the functions function. * Rename the functions * Fix all usages * Update list of filters exported symbols * Fix python bindings * Add ditherings to API Coverage tests Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/build/syms/Filters_symbols.txt b/build/syms/Filters_symbols.txt index 839c437..970c881 100644 --- a/build/syms/Filters_symbols.txt +++ b/build/syms/Filters_symbols.txt @@ -21,44 +21,15 @@ GP_FilterDifference_Raw GP_FilterEdgePrewitt GP_FilterEdgeSharpening - GP_FilterEdgeSharpeningAlloc GP_FilterEdgeSobel -GP_FilterFloydSteinberg_RGB888 -GP_FilterFloydSteinberg_RGB888_Alloc -GP_FilterFloydSteinberg_RGB888_Raw -GP_FilterFloydSteinberg_RGB888_to_BGR888_Raw -GP_FilterFloydSteinberg_RGB888_to_G1_Raw -GP_FilterFloydSteinberg_RGB888_to_G2_Raw -GP_FilterFloydSteinberg_RGB888_to_G4_Raw -GP_FilterFloydSteinberg_RGB888_to_G8_Raw -GP_FilterFloydSteinberg_RGB888_to_RGB565_Raw -GP_FilterFloydSteinberg_RGB888_to_RGB666_Raw -GP_FilterFloydSteinberg_RGB888_to_RGB888_Raw -GP_FilterFloydSteinberg_RGB888_to_xRGB14666_Raw -GP_FilterFloydSteinberg_RGB888_to_xRGB2222_Raw -GP_FilterFloydSteinberg_RGB888_to_xRGB7333_Raw -GP_FilterFloydSteinberg_RGB888_to_xRGB8888_Raw -GP_FilterFloydSteinberg_RGB888_to_G16_Raw - -GP_FilterHilbertPeano_RGB888 -GP_FilterHilbertPeano_RGB888_Alloc -GP_FilterHilbertPeano_RGB888_Raw -GP_FilterHilbertPeano_RGB888_to_BGR888_Raw -GP_FilterHilbertPeano_RGB888_to_G1_Raw -GP_FilterHilbertPeano_RGB888_to_G2_Raw -GP_FilterHilbertPeano_RGB888_to_G4_Raw -GP_FilterHilbertPeano_RGB888_to_G8_Raw -GP_FilterHilbertPeano_RGB888_to_RGB565_Raw -GP_FilterHilbertPeano_RGB888_to_RGB666_Raw -GP_FilterHilbertPeano_RGB888_to_RGB888_Raw -GP_FilterHilbertPeano_RGB888_to_xRGB14666_Raw -GP_FilterHilbertPeano_RGB888_to_xRGB2222_Raw -GP_FilterHilbertPeano_RGB888_to_xRGB7333_Raw -GP_FilterHilbertPeano_RGB888_to_xRGB8888_Raw -GP_FilterHilbertPeano_RGB888_to_G16_Raw +GP_FilterFloydSteinberg +GP_FilterFloydSteinbergAlloc + +GP_FilterHilbertPeano +GP_FilterHilbertPeanoAlloc GP_FilterGaussianBlurEx GP_FilterGaussianBlurExAlloc diff --git a/demos/c_simple/loaders_register.c b/demos/c_simple/loaders_register.c index 877bff9..4b36461 100644 --- a/demos/c_simple/loaders_register.c +++ b/demos/c_simple/loaders_register.c @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) return 1; } - gc = GP_FilterFloydSteinberg_RGB888_Alloc(c, GP_PIXEL_G2, NULL); + gc = GP_FilterFloydSteinbergAlloc(c, GP_PIXEL_G2, NULL); if (gc == NULL) { fprintf(stderr, "FloydSteinberg: %sn", strerror(errno)); diff --git a/demos/c_simple/v4l2_show.c b/demos/c_simple/v4l2_show.c index 50ea514..c564f95 100644 --- a/demos/c_simple/v4l2_show.c +++ b/demos/c_simple/v4l2_show.c @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) break; case 2: GP_FilterGaussianBlur(img, img, 1, 1, NULL); - res = GP_FilterFloydSteinberg_RGB888_Alloc(img, GP_PIXEL_G2, NULL); + res = GP_FilterFloydSteinbergAlloc(img, GP_PIXEL_G2, NULL); break; } diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index c406ef5..7bc3071 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -465,8 +465,8 @@ static int dither(GP_Context **c, const char *params) } GP_Context *bw; - bw = GP_FilterFloydSteinberg_RGB888_Alloc(*c, dither_pixel_types[fmt], - progress_callback); + bw = GP_FilterFloydSteinbergAlloc(*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/py_simple/dither.py b/demos/py_simple/dither.py index d7ca1b8..0437931 100755 --- a/demos/py_simple/dither.py +++ b/demos/py_simple/dither.py @@ -13,7 +13,7 @@ def main(): # Load Image img = loaders.Load(sys.argv[1]) # Use Floyd-Steinberg dithering - res = filters.FloydSteinberg_RGB888_Alloc(img, core.C.PIXEL_G1, None) + res = img.filters.FloydSteinbergAlloc(core.C.PIXEL_G1, None) # Save result into grayscale png res.loaders.SavePNG("out.png") diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 2d4e4ef..8be792a 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -318,8 +318,8 @@ static void update_display(struct loader_params *params, GP_Context *img, if (params->use_dithering) { callback.priv = "Dithering"; GP_SubContext(context, &sub_display, cx, cy, img->w, img->h); - GP_FilterFloydSteinberg_RGB888(img, &sub_display, NULL); - // GP_FilterHilbertPeano_RGB888(img, &sub_display, NULL); + GP_FilterFloydSteinberg(img, &sub_display, NULL); + // GP_FilterHilbertPeano(img, &sub_display, NULL); } else { if (GP_PixelHasFlags(img->pixel_type, GP_PIXEL_HAS_ALPHA)) pattern_fill(context, cx, cy, img->w, img->h); diff --git a/include/filters/GP_Dither.h b/include/filters/GP_Dither.h index 2c4d321..848ea83 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-2012 Cyril Hrubis <metan(a)ucw.cz> * + * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> * * * *****************************************************************************/ @@ -50,13 +50,6 @@ */ /* - * Semi internal raw version, use at your own risk. - */ -int GP_FilterFloydSteinberg_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. @@ -65,17 +58,17 @@ int GP_FilterFloydSteinberg_RGB888_Raw(const GP_Context *src, * * If operation was aborted from within a callback, non-zero is returned. */ -int GP_FilterFloydSteinberg_RGB888(const GP_Context *src, - GP_Context *dst, - GP_ProgressCallback *callback); +int GP_FilterFloydSteinberg(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_FilterFloydSteinberg_RGB888_Alloc(const GP_Context *src, - GP_PixelType pixel_type, - GP_ProgressCallback *callback); +GP_Context *GP_FilterFloydSteinbergAlloc(const GP_Context *src, + GP_PixelType pixel_type, + GP_ProgressCallback *callback); /* * Hilbert-Peano space filling curve based dithering. @@ -88,13 +81,6 @@ GP_Context *GP_FilterFloydSteinberg_RGB888_Alloc(const GP_Context *src, */ /* - * Semi internal raw version, use at your own risk. - */ -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. @@ -103,16 +89,16 @@ int GP_FilterHilbertPeano_RGB888_Raw(const GP_Context *src, * * 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); +int GP_FilterHilbertPeano(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); +GP_Context *GP_FilterHilbertPeanoAlloc(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 deleted file mode 100644 index a050513..0000000 --- a/libs/filters/GP_Dither.c +++ /dev/null @@ -1,85 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> * - * * - *****************************************************************************/ - -#include "GP_Dither.h" - -int GP_FilterFloydSteinberg_RGB888(const GP_Context *src, - GP_Context *dst, - GP_ProgressCallback *callback) -{ - GP_CHECK(src->pixel_type == GP_PIXEL_RGB888); - GP_CHECK(src->w <= dst->w); - GP_CHECK(src->h <= dst->h); - - return GP_FilterFloydSteinberg_RGB888_Raw(src, dst, callback); -} - - -GP_Context *GP_FilterFloydSteinberg_RGB888_Alloc(const GP_Context *src, - GP_PixelType pixel_type, - GP_ProgressCallback *callback) -{ - GP_Context *ret; - - ret = GP_ContextAlloc(src->w, src->h, pixel_type); - - if (ret == NULL) - return NULL; - - if (GP_FilterFloydSteinberg_RGB888_Raw(src, ret, callback)) { - GP_ContextFree(ret); - return NULL; - } - - return ret; -} - - -int GP_FilterHilbertPeano_RGB888(const GP_Context *src, - GP_Context *dst, - GP_ProgressCallback *callback) -{ - GP_CHECK(src->pixel_type == GP_PIXEL_RGB888); - GP_CHECK(src->w <= dst->w); - GP_CHECK(src->h <= dst->h); - - 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; - - 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; -} diff --git a/libs/filters/GP_FloydSteinberg.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t index 2d4d401..32a2534 100644 --- a/libs/filters/GP_FloydSteinberg.gen.c.t +++ b/libs/filters/GP_FloydSteinberg.gen.c.t @@ -26,11 +26,13 @@ %% block body +#include <string.h> +#include <errno.h> + #include "core/GP_Core.h" #include "core/GP_Pixel.h" -#include "GP_Filter.h" - -#include <string.h> +#include "filters/GP_Filter.h" +#include "filters/GP_Dither.h" %% macro distribute_error(errors, x, y, w, err) if ({{ x }} + 1 < {{ w }}) @@ -46,16 +48,17 @@ %% endmacro %% for pt in pixeltypes -%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha() +%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha() /* * Floyd Steinberg RGB888 to {{ pt.name }} */ -int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, GP_Context *dst, +static int floyd_steinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, + GP_Context *dst, GP_ProgressCallback *callback) { -%% for c in pt.chanslist +%% for c in pt.chanslist float errors_{{ c[0] }}[2][src->w]; -%% endfor +%% endfor GP_DEBUG(1, "Floyd Steinberg %s to %s %ux%u", GP_PixelTypeName(src->pixel_type), @@ -64,51 +67,51 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G GP_Coord x, y; -%% for c in pt.chanslist +%% for c in pt.chanslist memset(errors_{{ c[0] }}[0], 0, src->w * sizeof(float)); memset(errors_{{ c[0] }}[1], 0, src->w * sizeof(float)); -%% endfor +%% endfor for (y = 0; y < (GP_Coord)src->h; y++) { for (x = 0; x < (GP_Coord)src->w; x++) { GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, x, y); -%% for c in pt.chanslist -%% if pt.is_gray() +%% for c in pt.chanslist +%% if pt.is_gray() float val_{{ c[0] }} = GP_Pixel_GET_R_RGB888(pix) + GP_Pixel_GET_G_RGB888(pix) + GP_Pixel_GET_B_RGB888(pix); -%% else +%% else float val_{{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_RGB888(pix); -%% endif +%% endif val_{{ c[0] }} += errors_{{ c[0] }}[y%2][x]; float err_{{ c[0] }} = val_{{ c[0] }}; -%% if pt.is_gray() +%% if pt.is_gray() GP_Pixel res_{{ c[0] }} = {{ 2 ** c[2] - 1}} * val_{{ c[0] }} / (3 * 255); err_{{ c[0] }} -= res_{{ c[0] }} * (3 * 255) / {{ 2 ** c[2] - 1}}; -%% else +%% else GP_Pixel res_{{ c[0] }} = {{ 2 ** c[2] - 1}} * val_{{ c[0] }} / 255; err_{{ c[0] }} -= res_{{ c[0] }} * 255 / {{ 2 ** c[2] - 1}}; -%% endif +%% endif {{ distribute_error("errors_%s"|format(c[0]), 'x', 'y', '(GP_Coord)src->w', 'err_%s'|format(c[0])) }} {{ clamp_val("res_%s"|format(c[0]), c[2]) }} -%% endfor +%% endfor -%% if pt.is_gray() +%% if pt.is_gray() GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, res_V); -%% else +%% else GP_Pixel res = GP_Pixel_CREATE_{{ pt.name }}(res_{{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, res_{{ c[0] }}{% endfor %}); GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, res); -%% endif +%% endif } -%% for c in pt.chanslist +%% for c in pt.chanslist memset(errors_{{ c[0] }}[y%2], 0, src->w * sizeof(float)); -%% endfor +%% endfor if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) return 1; @@ -118,23 +121,61 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G return 0; } -%% endif +%% endif %% endfor -int GP_FilterFloydSteinberg_RGB888_Raw(const GP_Context *src, - GP_Context *dst, - GP_ProgressCallback *callback) +static int floyd_steinberg(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) { switch (dst->pixel_type) { -%% for pt in pixeltypes -%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha() +%% for pt in pixeltypes +%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha() case GP_PIXEL_{{ pt.name }}: - return GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(src, dst, callback); -%% endif -%% endfor + return floyd_steinberg_RGB888_to_{{ pt.name }}_Raw(src, dst, callback); +%% endif +%% endfor default: return 1; } } +int GP_FilterFloydSteinberg(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + GP_CHECK(src->w <= dst->w); + GP_CHECK(src->h <= dst->h); + + if (src->pixel_type != GP_PIXEL_RGB888) { + errno = ENOSYS; + return 1; + } + + return floyd_steinberg(src, dst, callback); +} + + +GP_Context *GP_FilterFloydSteinbergAlloc(const GP_Context *src, + GP_PixelType pixel_type, + GP_ProgressCallback *callback) +{ + GP_Context *ret; + + if (src->pixel_type != GP_PIXEL_RGB888) { + errno = ENOSYS; + return NULL; + } + + ret = GP_ContextAlloc(src->w, src->h, pixel_type); + + if (ret == NULL) + return NULL; + + if (floyd_steinberg(src, ret, callback)) { + GP_ContextFree(ret); + return NULL; + } + + return ret; +} + %% endblock body diff --git a/libs/filters/GP_HilbertPeano.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t index 90ed943..c1660e4 100644 --- a/libs/filters/GP_HilbertPeano.gen.c.t +++ b/libs/filters/GP_HilbertPeano.gen.c.t @@ -26,10 +26,13 @@ %% block body +#include <errno.h> + #include "core/GP_Core.h" #include "core/GP_GetPutPixel.h" -#include "GP_HilbertCurve.h" -#include "GP_Filter.h" +#include "filters/GP_HilbertCurve.h" +#include "filters/GP_Filter.h" +#include "filters/GP_Dither.h" /* * Returns closest greater square of two, used to determine the curve size. @@ -49,11 +52,11 @@ static unsigned int count_bits(unsigned int n) } %% for pt in pixeltypes -%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha() +%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha() /* * Hilbert Peano RGB888 to {{ pt.name }} */ -int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, +static int hilbert_peano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback) { @@ -70,41 +73,41 @@ int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, unsigned int cnt = 0; /* error counters */ -%% for c in pt.chanslist +%% for c in pt.chanslist int err_{{ c[0] }} = 0; -%% endfor +%% endfor while (GP_HilbertCurveContinues(&state)) { if (state.x < src->w && state.y < src->h) { GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, state.x, state.y); -%% for c in pt.chanslist -%% if pt.is_gray() +%% for c in pt.chanslist +%% if pt.is_gray() int pix_{{ c[0] }} = GP_Pixel_GET_R_RGB888(pix) + GP_Pixel_GET_G_RGB888(pix) + GP_Pixel_GET_B_RGB888(pix); -%% else +%% else int pix_{{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_RGB888(pix); -%% endif +%% endif pix_{{ c[0] }} += err_{{ c[0] }}; -%% if pt.is_gray() +%% if pt.is_gray() int res_{{ c[0] }} = ({{ 2 ** c[2] - 1}} * pix_{{ c[0] }} + 382) / {{ 3 * 255 }}; err_{{ c[0] }} = pix_{{ c[0] }} - {{ 3 * 255 }} * res_{{ c[0] }} / {{ 2 ** c[2] - 1 }}; -%% else +%% else int res_{{ c[0] }} = ({{ 2 ** c[2] - 1}} * pix_{{ c[0] }} + 127) / 255; err_{{ c[0] }} = pix_{{ c[0] }} - 255 * res_{{ c[0] }} / {{ 2 ** c[2] - 1 }}; -%% endif -%% endfor +%% endif +%% endfor -%% if pt.is_gray() +%% if pt.is_gray() GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, state.x, state.y, res_V); -%% else +%% else GP_Pixel res = GP_Pixel_CREATE_{{ pt.name }}(res_{{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, res_{{ c[0] }}{% endfor %}); GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, state.x, state.y, res); -%% endif +%% endif cnt++; if (GP_ProgressCallbackReport(callback, cnt/src->h, src->w, src->h)) @@ -116,9 +119,9 @@ int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, return 0; } } else { -%% for c in pt.chanslist +%% for c in pt.chanslist err_{{ c[0] }} = 0; -%% endfor +%% endfor } GP_HilbertCurveNext(&state); @@ -128,23 +131,60 @@ int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, return 0; } -%% endif +%% endif %% endfor -int GP_FilterHilbertPeano_RGB888_Raw(const GP_Context *src, - GP_Context *dst, - GP_ProgressCallback *callback) +static int hilbert_peano(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) { switch (dst->pixel_type) { %% for pt in pixeltypes -%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha() +%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha() case GP_PIXEL_{{ pt.name }}: - return GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(src, dst, callback); -%% endif + return hilbert_peano_RGB888_to_{{ pt.name }}_Raw(src, dst, callback); +%% endif %% endfor default: return 1; } } +int GP_FilterHilbertPeano(const GP_Context *src, GP_Context *dst, + GP_ProgressCallback *callback) +{ + GP_CHECK(src->w <= dst->w); + GP_CHECK(src->h <= dst->h); + + if (src->pixel_type != GP_PIXEL_RGB888) { + errno = ENOSYS; + return 1; + } + + return hilbert_peano(src, dst, callback); +} + +GP_Context *GP_FilterHilbertPeanoAlloc(const GP_Context *src, + GP_PixelType pixel_type, + GP_ProgressCallback *callback) +{ + GP_Context *ret; + + if (src->pixel_type != GP_PIXEL_RGB888) { + errno = ENOSYS; + return NULL; + } + + ret = GP_ContextAlloc(src->w, src->h, pixel_type); + + if (ret == NULL) + return NULL; + + if (hilbert_peano(src, ret, callback)) { + GP_ContextFree(ret); + return NULL; + } + + return ret; +} + %% endblock body diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py index 4ce1880..67022ba 100644 --- a/pylib/gfxprim/filters/__init__.py +++ b/pylib/gfxprim/filters/__init__.py @@ -34,7 +34,9 @@ def _init(module): 'Laplace', 'LaplaceAlloc', 'EdgeSharpening', 'EdgeSharpeningAlloc', 'Median', 'MedianAlloc', 'MedianEx', 'MedianExAlloc', - 'Sigma', 'SigmaAlloc', 'SigmaEx', 'SigmaExAlloc']: + 'Sigma', 'SigmaAlloc', 'SigmaEx', 'SigmaExAlloc', + 'FloydSteinberg', 'FloydSteinbergAlloc', + 'HilbertPeano', 'HilbertPeanoAlloc']: extend_submodule(FiltersSubmodule, name, c_filters.__getattribute__('GP_Filter' + name)) # Imports from the SWIG module diff --git a/pylib/gfxprim/filters/filters.i b/pylib/gfxprim/filters/filters.i index 9610342..7417ec4 100644 --- a/pylib/gfxprim/filters/filters.i +++ b/pylib/gfxprim/filters/filters.i @@ -71,13 +71,9 @@ FILTER_FUNC(ResizeLinearInt); FILTER_FUNC(ResizeLinearLFInt); %include "GP_ResizeLinear.h" -/* TODO: Ditherings */ -%newobject GP_FilterFloydSteinberg_RGB888_Alloc; -ERROR_ON_NULL(GP_FilterFloydSteinberg_RGB888_Alloc); -%newobject GP_FilterHilbertPeano_RGB888_Alloc; -ERROR_ON_NULL(GP_FilterHilbertPeano_RGB888_Alloc); -ERROR_ON_NONZERO(GP_FilterFloydSteinberg_RGB888); -ERROR_ON_NONZERO(GP_FilterHilbertPeano_RGB888); +/* Ditherings */ +FILTER_FUNC(FloydSteinberg); +FILTER_FUNC(GP_FilterHilbertPeano); %include "GP_Dither.h" /* Laplace and Laplace Edge Sharpening */ diff --git a/tests/filters/APICoverage.gen.c.t b/tests/filters/APICoverage.gen.c.t index ab22dd0..323f614 100644 --- a/tests/filters/APICoverage.gen.c.t +++ b/tests/filters/APICoverage.gen.c.t @@ -96,6 +96,16 @@ 'GP_ProgressCallback'], ['ResizeNNAlloc', 'GP_Context:in', 'int:w', 'int:h', 'GP_ProgressCallback'], + + ['FloydSteinberg', 'GP_Context:in', 'GP_Context:out', + 'GP_ProgressCallback'], + ['FloydSteinbergAlloc', 'GP_Context:in', 'GP_PixelType:G8', + 'GP_ProgressCallback'], + + ['HilbertPeano', 'GP_Context:in', 'GP_Context:out', + 'GP_ProgressCallback'], + ['HilbertPeanoAlloc', 'GP_Context:in', 'GP_PixelType:G8', + 'GP_ProgressCallback'], ] %% macro prep_context(id, pt) @@ -110,6 +120,10 @@ int {{ id }} = 2; %% endmacro +%% macro prep_pixel_type(id) + GP_PixelType {{ id }} = GP_PIXEL_{{ id }}; +%% endmacro + %% macro prep_median_weights(id) unsigned int {{ id }}_w[] = { @@ -161,6 +175,9 @@ %% if (param.split(':', 1)[0] == 'GP_FilterKernel2D') {{ prep_filter_kernel_2d(param.split(':', 1)[1]) }} %% endif +%% if (param.split(':', 1)[0] == 'GP_PixelType') +{{ prep_pixel_type(param.split(':', 1)[1]) }} +%% endif %% endmacro {% macro get_param(param) %}{% if len(param.split(':', 1)) == 1 %}NULL{% else %}{{ param.split(':', 1)[1] }}{% endif %}{% endmacro %} @@ -190,7 +207,7 @@ const struct tst_suite tst_suite = { %% for fn in API_List %% for pt in pixeltypes %% if not pt.is_unknown() - {.name = "Filter {{ fn[0] }} {{ pt.name }}", + {.name = "Filter {{ fn[0] }} {{ pt.name }}", .tst_fn = Filter_{{ fn[0] }}_{{ pt.name }}}, %% endif %% endfor ----------------------------------------------------------------------- Summary of changes: build/Makefile | 4 +- build/check_symbols.sh | 17 ++ build/syms/Core_symbols.txt | 3 + build/syms/Filters_symbols.txt | 39 +---- build/syms/Text_symbols.txt | 5 +- demos/c_simple/loaders_register.c | 2 +- demos/c_simple/v4l2_show.c | 2 +- demos/grinder/grinder.c | 4 +- demos/py_simple/dither.py | 2 +- demos/spiv/spiv.c | 4 +- doc/Makefile | 1 + doc/asciidoc.conf | 5 +- ...le_py_backends.txt => example_py_dithering.txt} | 8 +- doc/filters.txt | 141 +----------------- doc/filters_dithering.txt | 159 ++++++++++++++++++++ doc/filters_python.txt | 35 +++++ include/filters/GP_Dither.h | 40 ++---- libs/filters/GP_Dither.c | 85 ----------- libs/filters/GP_FloydSteinberg.gen.c.t | 103 +++++++++---- libs/filters/GP_HilbertPeano.gen.c.t | 92 ++++++++---- pylib/gfxprim/filters/__init__.py | 4 +- pylib/gfxprim/filters/filters.i | 10 +- tests/filters/APICoverage.gen.c.t | 19 +++- 23 files changed, 416 insertions(+), 368 deletions(-) copy doc/{example_py_backends.txt => example_py_dithering.txt} (51%) create mode 100644 doc/filters_dithering.txt create mode 100644 doc/filters_python.txt delete mode 100644 libs/filters/GP_Dither.c repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive no reply. -- gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
0
0
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc0-183-g07fc6dc
by metan
20 Sep '13
20 Sep '13
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git. The branch, master has been updated via 07fc6dce72522e9b86d09dffb4c61be6db3a127c (commit) via 56000d2d040c16241af166e510bb72ec760fcfb6 (commit) from 285f37259943b8777104bf7e34e45cd1da2706a9 (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/07fc6dce72522e9b86d09dffb4c61be6db3a…
commit 07fc6dce72522e9b86d09dffb4c61be6db3a127c Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 20 00:46:15 2013 +0200 test: framework: malloc check: Add realloc() Use realloc to track malloced memory too. Fixes warnings: "Chunk passed to free not found (0x15c2650)" When realloc was used to allocate memory. (found by TIFF loader tests) Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/tests/framework/tst_preload.c b/tests/framework/tst_preload.c index 6bb0c36..9205a66 100644 --- a/tests/framework/tst_preload.c +++ b/tests/framework/tst_preload.c @@ -126,8 +126,29 @@ void *malloc(size_t size) void *ptr = real_malloc(size); - if (check_malloc && ptr != NULL) + if (check_malloc && ptr) + add_chunk(size, ptr); + + return ptr; +} + +void *realloc(void *optr, size_t size) +{ + static void *(*real_realloc)(void*, size_t) = NULL; + + if (!real_realloc) + real_realloc = dlsym(RTLD_NEXT, "realloc"); + + void *ptr = real_realloc(optr, size); + + if (!ptr) + return NULL; + + if (check_malloc) { + if (optr) + rem_chunk(optr); add_chunk(size, ptr); + } return ptr; }
http://repo.or.cz/w/gfxprim.git/commit/56000d2d040c16241af166e510bb72ec760f…
commit 56000d2d040c16241af166e510bb72ec760fcfb6 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Fri Sep 20 00:44:28 2013 +0200 tests: framework: Fix whitespaces. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/tests/framework/test.c b/tests/framework/test.c index 8111855..db42323 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -34,7 +34,7 @@ int success_fn(void) { tst_msg("This test does nothing"); tst_msg("But successfully"); - + return TST_SUCCESS; } @@ -76,7 +76,7 @@ int temp_dir_fn(void) int malloc_leak_fn(void) { void *p, *q, *r; - + q = malloc(100); p = malloc(4); p = malloc(3); @@ -130,7 +130,7 @@ int barrier_allocation(void) buf[i] = 0; tst_msg("About to use address after the buffer with barrier"); - + buf[31] = 0; tst_msg("This is not printed at all"); @@ -150,7 +150,7 @@ int fail_FILE(void) int fail = 0; FILE *f; - + f = fopen("test_fail_fclose", "w"); if (f == NULL) { @@ -182,7 +182,7 @@ int fail_FILE(void) if (fail) return TST_FAILED; - + return TST_SUCCESS; } @@ -191,7 +191,7 @@ static int messages_test_fn(void) /* stdout and stderr capture test */ printf("This is stdoutn"); fprintf(stderr, "This is stderrn"); - + tst_msg("This is message"); tst_warn("This is a warning"); tst_err("This is an error"); @@ -220,7 +220,7 @@ static int untested_fn(void) static int res_fn(void) { - if (access("test.c", R_OK) == 0) + if (access("test.c", R_OK) == 0) tst_msg("File correctly copied"); return TST_SUCCESS; @@ -236,7 +236,7 @@ static int fpe_fn(void) /* * Let's benchmark memset. - */ + */ static int benchmark_fn(void) { char buf[256]; diff --git a/tests/framework/tst_alloc_barriers.c b/tests/framework/tst_alloc_barriers.c index fb745b6..567e462 100644 --- a/tests/framework/tst_alloc_barriers.c +++ b/tests/framework/tst_alloc_barriers.c @@ -32,7 +32,7 @@ void *tst_alloc_barrier_right(size_t size) size_t pagesize = sysconf(_SC_PAGESIZE); size_t pages = size/pagesize + !!(size%pagesize) + 1; char *buf; - + if (posix_memalign((void*)&buf, pagesize, pages * pagesize)) return NULL; @@ -70,11 +70,11 @@ void *tst_alloc_barrier_left(size_t size) size_t pages = size/pagesize + !!(size%pagesize) + 1; char *buf; - + if (posix_memalign((void*)&buf, pagesize, pages * pagesize)) return NULL; - /* + /* * Turn off read/write acces on the first page, the buffer starts right * after it. */ @@ -91,7 +91,7 @@ void tst_free_barrier_left(void *ptr, size_t size __attribute__((unused))) { size_t pagesize = sysconf(_SC_PAGESIZE); void *start = ptr - pagesize; - + /* Reset the memory protection back to RW */ if (mprotect(start, pagesize, PROT_READ | PROT_WRITE)) { perror("mprotect"); diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index ca2b079..1d0d754 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -69,7 +69,7 @@ static void remove_tmpdir(const char *path) ret = system(buf); if (ret) - tst_warn("Failed to clean temp dir."); + tst_warn("Failed to clean temp dir."); } /* @@ -100,7 +100,7 @@ static void prepare_tmpdir(const char *name, const char *res_path, exit(TST_INTERR); } - /* + /* * Copy resources if needed * * If resource is directory, copy only it's content. @@ -118,7 +118,7 @@ static void prepare_tmpdir(const char *name, const char *res_path, if (S_ISDIR(st.st_mode)) p = "/*"; - + snprintf(tmp, sizeof(tmp), "cp -r '%s'%s '%s'", res_path, p, template); @@ -148,7 +148,7 @@ static void write_timespec(struct tst_job *job, char type, char *ptr = buf; *(ptr++) = type; - + memcpy(ptr, time, sizeof(*time)); if (write(job->pipefd, buf, sizeof(buf)) != sizeof(buf)) @@ -187,12 +187,12 @@ static int tst_vreport(int level, const char *fmt, va_list va) char buf[258]; ret = vsnprintf(buf+3, sizeof(buf) - 3, fmt, va); - + ssize_t size = ret > 255 ? 255 : ret + 1; buf[0] = 'm'; buf[1] = level; - ((unsigned char*)buf)[2] = size; + ((unsigned char*)buf)[2] = size; if (in_child()) { if (write(my_job->pipefd, buf, size + 3) != size + 3) @@ -221,7 +221,7 @@ int tst_msg(const char *fmt, ...) { va_list va; int ret; - + va_start(va, fmt); if (in_child()) @@ -238,7 +238,7 @@ int tst_warn(const char *fmt, ...) { va_list va; int ret; - + va_start(va, fmt); if (in_child()) @@ -255,7 +255,7 @@ int tst_err(const char *fmt, ...) { va_list va; int ret; - + va_start(va, fmt); if (in_child()) @@ -292,24 +292,24 @@ static int tst_job_benchmark(struct tst_job *job) struct timespec sum = {.tv_sec = 0, .tv_nsec = 0}; struct timespec dev = {.tv_sec = 0, .tv_nsec = 0}; int ret; - + /* Warm up */ ret = job_run(job); - + if (ret) return ret; /* Collect the data */ for (i = 0; i < iter; i++) { clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cputime_start); - + ret = job_run(job); - + if (ret) return ret; clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cputime_stop); - + timespec_sub(&cputime_stop, &cputime_start, &bench[i]); timespec_add(&bench[i], &sum); @@ -317,17 +317,17 @@ static int tst_job_benchmark(struct tst_job *job) /* Compute mean */ timespec_div(&sum, iter); - + double sum_d = timespec_to_double(&sum); double dev_d = 0; /* And standard deviation */ for (i = 0; i < iter; i++) { double b = timespec_to_double(&bench[i]); - + b -= sum_d; b = b * b; - + dev_d += b; } @@ -348,7 +348,7 @@ void tst_job_run(struct tst_job *job) int ret; char template[256]; int pipefd[2]; - + /* Write down starting time of the test */ clock_gettime(CLOCK_MONOTONIC, &job->start_time); @@ -397,7 +397,7 @@ void tst_job_run(struct tst_job *job) prepare_tmpdir(job->test->name, job->test->res_path, template, sizeof(template)); - /* + /* * If timeout is specified, setup alarm. * * If alarm fires the test will be killed by SIGALRM. @@ -486,7 +486,7 @@ void tst_job_read(struct tst_job *job) if (ret < 0) { tst_warn("job_read: read() failed: %s", strerror(errno)); job->running = 0; - + //TODO: kill the process? return; @@ -498,9 +498,9 @@ void tst_job_read(struct tst_job *job) tst_warn("job_read: read() returned EAGAIN"); return; } - + job->running = 0; - + return; } @@ -566,7 +566,7 @@ void tst_job_collect(struct tst_job *job) case SIGFPE: job->result = TST_FPE; break; - /* + /* * abort() called most likely double free or malloc data * corruption */ @@ -578,7 +578,7 @@ void tst_job_collect(struct tst_job *job) job->result = TST_INTERR; } } - + /* Write down stop time */ clock_gettime(CLOCK_MONOTONIC, &job->stop_time); } diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c index aecb8dc..658419e 100644 --- a/tests/framework/tst_log.c +++ b/tests/framework/tst_log.c @@ -105,7 +105,7 @@ static void append_benchmark_json(struct tst_job *job, FILE *f) fprintf(f, "tttt"Time Mean": %i.%09i,n", (int)job->bench_mean.tv_sec, (int)job->bench_mean.tv_nsec); - + fprintf(f, "tttt"Time Variance": %i.%09i,n", (int)job->bench_var.tv_sec, (int)job->bench_var.tv_nsec); @@ -143,12 +143,12 @@ int tst_log_append(struct tst_job *job, FILE *f) int sec, nsec; timespec_diff(&sec, &nsec, &job->start_time, &job->stop_time); - + fprintf(f, "ttt"CPU Time": %i.%09i,n", (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec); fprintf(f, "ttt"Run Time": %i.%09in", sec, nsec); - + fprintf(f, "tt}"); return 0; @@ -161,14 +161,14 @@ static void write_system_info_json(FILE *f) uname(&buf); fprintf(f, "t"System Info": {n"); - + fprintf(f, "tt"OS": "%s",n", buf.sysname); fprintf(f, "tt"Hostname": "%s",n", buf.nodename); fprintf(f, "tt"Release": "%s",n", buf.release); /* CPU related info */ fprintf(f, "tt"CPU": {"); - + /* lscpu is part of reasonably new util-linux */ FILE *cmd = popen("lscpu 2> /dev/null", "r"); @@ -180,11 +180,11 @@ static void write_system_info_json(FILE *f) fprintf(f, "%sttt"%s": "%s"", del, id, val); del = ",n"; } - + fclose(cmd); fprintf(f, "n"); } - + fprintf(f, "tt}n"); fprintf(f, "t},n"); diff --git a/tests/framework/tst_main.c b/tests/framework/tst_main.c index a45b2c6..a06ee82 100644 --- a/tests/framework/tst_main.c +++ b/tests/framework/tst_main.c @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) return 1; } } - + tst_run_suite(&tst_suite, NULL); return 0; diff --git a/tests/framework/tst_msg.c b/tests/framework/tst_msg.c index 8deafd1..b4f150f 100644 --- a/tests/framework/tst_msg.c +++ b/tests/framework/tst_msg.c @@ -48,7 +48,7 @@ int tst_msg_append(struct tst_msg_store *self, int type, const char *msg_text) { size_t len = strlen(msg_text); struct tst_msg *msg; - + msg = malloc(sizeof(struct tst_msg) + len + 1); if (msg == NULL) { diff --git a/tests/framework/tst_preload.c b/tests/framework/tst_preload.c index aec364f..6bb0c36 100644 --- a/tests/framework/tst_preload.c +++ b/tests/framework/tst_preload.c @@ -52,10 +52,10 @@ void tst_malloc_check_report(struct malloc_stats *stats) { stats->total_size = total_size; stats->total_chunks = total_chunks; - + stats->max_size = max_size; stats->max_chunks = max_chunks; - + stats->lost_size = cur_size; stats->lost_chunks = cur_chunks; } @@ -103,14 +103,13 @@ static void rem_chunk(void *ptr) for (i = 0; i < chunks_top; i++) { if (chunks[i].ptr == ptr) { - /* Update global stats */ cur_size -= chunks[i].size; cur_chunks--; - + /* Replace found chunk with top one */ chunks[i] = chunks[--chunks_top]; - + return; } } @@ -139,7 +138,7 @@ void free(void *ptr) if (!real_free) real_free = dlsym(RTLD_NEXT, "free"); - + if (check_malloc && ptr != NULL) rem_chunk(ptr); diff --git a/tests/framework/tst_preload_FILE.c b/tests/framework/tst_preload_FILE.c index 2365b6b..1d546a2 100644 --- a/tests/framework/tst_preload_FILE.c +++ b/tests/framework/tst_preload_FILE.c @@ -43,7 +43,7 @@ static struct tst_fail_FILE *failure_by_path(const char *path, if (failures == NULL) return NULL; - + for (i = 0; failures[i].path != NULL; i++) if (failures[i].call == call && !strcmp(path, failures[i].path)) @@ -58,7 +58,7 @@ void failures_init_FILE(const char *path, FILE *f) if (failures == NULL) return; - + //TODO: warn on f not NULL for (i = 0; failures[i].path != NULL; i++) if (!strcmp(path, failures[i].path)) @@ -68,7 +68,7 @@ void failures_init_FILE(const char *path, FILE *f) static struct tst_fail_FILE *failure_by_FILE(FILE *f, enum tst_file_call call) { unsigned int i; - + if (failures == NULL) return NULL; @@ -109,19 +109,19 @@ int fclose(FILE *fp) if (!real_fclose) real_fclose = dlsym(RTLD_NEXT, "fclose"); - + struct tst_fail_FILE *failure = failure_by_FILE(fp, TST_FAIL_FCLOSE); - /* + /* * We close the file here correctly, we can because when fclose() has * failed any further access results in undefined behavior. */ if (failure) { real_fclose(fp); - + if (failure->err) errno = failure->err; - + return EOF; } diff --git a/tests/framework/tst_suite.c b/tests/framework/tst_suite.c index 2bb8455..6088db3 100644 --- a/tests/framework/tst_suite.c +++ b/tests/framework/tst_suite.c @@ -47,7 +47,7 @@ static void test_job_report(const struct tst_job *job) if ((job->result == TST_SUCCESS || job->result == TST_SKIPPED) && !tst_suite_verbose) return; - + timespec_diff(&sec, &nsec, &job->start_time, &job->stop_time); switch (job->result) { @@ -84,9 +84,9 @@ static void test_job_report(const struct tst_job *job) case TST_MAX: break; } - + fprintf(stderr, "e[1;37m%se[0m", name); - + int i; for (i = strlen(name); i < NAME_PADD; i++) @@ -94,7 +94,7 @@ static void test_job_report(const struct tst_job *job) fprintf(stderr, " finished (Time %3i.%03is) %sn", sec, nsec/1000000, result); - + if (job->bench_iter) { for (i = 0; i < NAME_PADD; i++) fprintf(stderr, " "); @@ -111,7 +111,7 @@ static void test_job_report(const struct tst_job *job) /* Now print test message store */ tst_msg_print(&job->store); - + fprintf(stderr, "------------------------------------------------------" "------------------------- n"); } @@ -122,7 +122,7 @@ static int run_test(const struct tst_test *test, FILE *json) job.test = test; - /* + /* * Flush the file before forking, otherwise * there would be a copy of its buffers in both * child and parent and the lines in the resulting @@ -133,7 +133,7 @@ static int run_test(const struct tst_test *test, FILE *json) tst_job_run(&job); tst_job_wait(&job); - + /* report result into stdout */ test_job_report(&job); @@ -156,7 +156,7 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name) fprintf(stderr, "Running e[1;37m%se[0mnn", suite->suite_name); FILE *json = NULL; - + if (tst_log_dir) { char buf[512]; snprintf(buf, sizeof(buf), "%s/%s.json", @@ -168,7 +168,7 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name) if (tst_name == NULL || !strcmp(tst_name, suite->tests[i].name)) { ret = run_test(&suite->tests[i], json); counters[ret]++; - + if (ret != TST_SKIPPED) counter++; } @@ -178,7 +178,7 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name) tst_log_close(json); float percents; - + if (counter == 0) percents = 100; else diff --git a/tests/framework/tst_timespec.c b/tests/framework/tst_timespec.c index 233095c..45a4422 100644 --- a/tests/framework/tst_timespec.c +++ b/tests/framework/tst_timespec.c @@ -40,7 +40,7 @@ void timespec_diff(int *sec, int *nsec, double timespec_to_double(const struct timespec *t) { double res; - + res = t->tv_sec; res *= NSEC_IN_SEC; res += t->tv_nsec; ----------------------------------------------------------------------- Summary of changes: tests/framework/test.c | 16 +++++----- tests/framework/tst_alloc_barriers.c | 8 +++--- tests/framework/tst_job.c | 48 +++++++++++++++++----------------- tests/framework/tst_log.c | 14 +++++----- tests/framework/tst_main.c | 2 +- tests/framework/tst_msg.c | 2 +- tests/framework/tst_preload.c | 34 +++++++++++++++++++----- tests/framework/tst_preload_FILE.c | 14 +++++----- tests/framework/tst_suite.c | 20 +++++++------- tests/framework/tst_timespec.c | 2 +- 10 files changed, 90 insertions(+), 70 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
0
0
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc0-181-g285f372
by metan
19 Sep '13
19 Sep '13
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git. The branch, master has been updated via 285f37259943b8777104bf7e34e45cd1da2706a9 (commit) via d838051917f95c332c457eadba72c5369147678f (commit) via 4d6e63045fabb823aeb543122fd4c26697117bbe (commit) via 28d21ca42de6b4e894b677f49f30a0b9849902eb (commit) via eb664a99edb339aba95731b9a437dd8a30ef31b5 (commit) via 98452c22c9737ea12fa14cfb1f9551886ee320a2 (commit) via 5f8f0740414d5bc5e5fd4cf51824ed75057681ea (commit) via 9eda828f0117515f5698c1101e632fff823830fd (commit) from 8d2ecb32294836112e300b456b2d620f1b033b31 (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/285f37259943b8777104bf7e34e45cd1da27…
commit 285f37259943b8777104bf7e34e45cd1da2706a9 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 19 23:36:58 2013 +0200 loaders: BMP, JPG: Simplify LineConvert usage. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c index b6f3a50..3a56413 100644 --- a/libs/loaders/GP_BMP.c +++ b/libs/loaders/GP_BMP.c @@ -780,20 +780,15 @@ static int bmp_fill_header(const GP_Context *src, struct bitmap_info_header *hea { GP_PixelType out_pix; - switch (src->pixel_type) { - case GP_PIXEL_RGB888: - header->bpp = 24; - break; - default: - out_pix = GP_LineConvertible(src->pixel_type, out_pixel_types); + out_pix = GP_LineConvertible(src->pixel_type, out_pixel_types); - if (out_pix == GP_PIXEL_UNKNOWN) { - GP_DEBUG(1, "Unsupported pixel type %s", - GP_PixelTypeName(src->pixel_type)); - return ENOSYS; - } + if (out_pix == GP_PIXEL_UNKNOWN) { + GP_DEBUG(1, "Unsupported pixel type %s", + GP_PixelTypeName(src->pixel_type)); + return ENOSYS; } + header->bpp = 24; header->w = src->w; header->h = src->h; diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c index 3b52821..aa6b1c4 100644 --- a/libs/loaders/GP_JPG.c +++ b/libs/loaders/GP_JPG.c @@ -410,20 +410,13 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path, GP_DEBUG(1, "Saving JPG Image '%s'", dst_path); - switch (src->pixel_type) { - case GP_PIXEL_BGR888: - case GP_PIXEL_G8: - out_pix = src->pixel_type; - break; - default: - out_pix = GP_LineConvertible(src->pixel_type, out_pixel_types); + out_pix = GP_LineConvertible(src->pixel_type, out_pixel_types); - if (out_pix == GP_PIXEL_UNKNOWN) { - GP_DEBUG(1, "Unsupported pixel type %s", - GP_PixelTypeName(src->pixel_type)); - errno = ENOSYS; - return 1; - } + if (out_pix == GP_PIXEL_UNKNOWN) { + GP_DEBUG(1, "Unsupported pixel type %s", + GP_PixelTypeName(src->pixel_type)); + errno = ENOSYS; + return 1; } f = fopen(dst_path, "wb");
http://repo.or.cz/w/gfxprim.git/commit/d838051917f95c332c457eadba72c5369147…
commit d838051917f95c332c457eadba72c5369147678f Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 19 23:31:15 2013 +0200 tests: loaders: Add simple pixelcheck to save_load. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/tests/loaders/Loader.h b/tests/loaders/Loader.h index d1a81b2..36b20ef 100644 --- a/tests/loaders/Loader.h +++ b/tests/loaders/Loader.h @@ -115,6 +115,7 @@ struct testcase_save_load { static int test_save_load(struct testcase_save_load *test) { GP_Context *img, *img2; + unsigned int x, y; img = GP_ContextAlloc(test->w, test->h, test->pixel_type); @@ -124,6 +125,10 @@ static int test_save_load(struct testcase_save_load *test) return TST_FAILED; } + for (x = 0; x < img->w; x++) + for (y = 0; y < img->w; y++) + GP_PutPixel(img, x, y, 0); + errno = 0; if (SAVE(img, "testfile", NULL)) { @@ -168,12 +173,18 @@ static int test_save_load(struct testcase_save_load *test) tst_msg("Source pixel type %s and loaded type %s differs", GP_PixelTypeName(img->pixel_type), GP_PixelTypeName(img2->pixel_type)); + return TST_FAILED; + } + + if (GP_GetPixel(img2, 0, 0) != 0) { + tst_msg("Pixel value is wrong %x", GP_GetPixel(img2, 0, 0)); + GP_ContextFree(img); + GP_ContextFree(img2); + return TST_FAILED; } GP_ContextFree(img); GP_ContextFree(img2); - //TODO: Check pixels - return TST_SUCCESS; }
http://repo.or.cz/w/gfxprim.git/commit/4d6e63045fabb823aeb543122fd4c2669711…
commit 4d6e63045fabb823aeb543122fd4c26697117bbe Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 19 23:30:11 2013 +0200 loaders: PNM: Fix SavePBM. Inverse the value on SavePBM. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c index 7100fb8..027dae2 100644 --- a/libs/loaders/GP_PNM.c +++ b/libs/loaders/GP_PNM.c @@ -551,15 +551,20 @@ static int load_bin_rgb888(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb) return 0; } -static int save_ascii(FILE *f, const GP_Context *ctx, GP_ProgressCallback *cb) +static int save_ascii(FILE *f, const GP_Context *ctx, + GP_ProgressCallback *cb, int inv) { uint32_t x, y; int err; for (y = 0; y < ctx->h; y++) { for (x = 0; x < ctx->w; x++) { + int val = GP_GetPixel_Raw(ctx, x, y); - if (fprintf(f, "%i ", GP_GetPixel_Raw(ctx, x, y)) < 0) { + if (inv) + val = !val; + + if (fprintf(f, "%i ", val) < 0) { err = errno; GP_DEBUG(1, "Failed to write data"); return err; @@ -674,7 +679,7 @@ int GP_SavePBM(const GP_Context *src, const char *dst_path, (unsigned int) src->w, (unsigned int) src->h) < 0) goto err; - if (save_ascii(f, src, callback)) + if (save_ascii(f, src, callback, 1)) goto err; if (fclose(f)) @@ -847,7 +852,7 @@ int GP_SavePGM(const GP_Context *src, const char *dst_path, (unsigned int) src->w, (unsigned int) src->h, depth) < 0) goto err1; - if ((err = save_ascii(f, src, callback))) + if ((err = save_ascii(f, src, callback, 0))) goto err1; if (fclose(f)) {
http://repo.or.cz/w/gfxprim.git/commit/28d21ca42de6b4e894b677f49f30a0b98499…
commit 28d21ca42de6b4e894b677f49f30a0b9849902eb Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 19 23:20:48 2013 +0200 loaders: PNM: Make use of LineConvert. So far only for PNM and PPM. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c index dc29a7c..7100fb8 100644 --- a/libs/loaders/GP_PNM.c +++ b/libs/loaders/GP_PNM.c @@ -57,6 +57,7 @@ #include "core/GP_Debug.h" #include "core/GP_Context.h" #include "core/GP_GetPutPixel.h" +#include "loaders/GP_LineConvert.h" #include "loaders/GP_PNM.h" @@ -947,14 +948,23 @@ static int write_binary_ppm(FILE *f, GP_Context *src) } static int save_ascii_rgb888(FILE *f, const GP_Context *ctx, - GP_ProgressCallback *cb) + GP_LineConvert Convert, GP_ProgressCallback *cb) { uint32_t x, y; int ret; + uint8_t buf[3 * ctx->w], *addr; for (y = 0; y < ctx->h; y++) { + + addr = GP_PIXEL_ADDR(ctx, 0, y); + + if (Convert) { + Convert(addr, buf, ctx->w); + addr = buf; + } + for (x = 0; x < ctx->w; x++) { - GP_Pixel pix = GP_GetPixel_Raw_24BPP(ctx, x, y); + GP_Pixel pix = *(addr+=3); ret = fprintf(f, "%u %u %u ", GP_Pixel_GET_R_RGB888(pix), @@ -978,16 +988,25 @@ static int save_ascii_rgb888(FILE *f, const GP_Context *ctx, return 0; } +static GP_PixelType ppm_save_pixels[] = { + GP_PIXEL_RGB888, + GP_PIXEL_UNKNOWN, +}; + int GP_SavePPM(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback) { + GP_Pixel out_pix; + GP_LineConvert Convert; FILE *f; int err = EIO; GP_DEBUG(1, "Saving context %ux%u %s to '%s'", src->w, src->h, GP_PixelTypeName(src->pixel_type), dst_path); - if (src->pixel_type != GP_PIXEL_RGB888) { + out_pix = GP_LineConvertible(src->pixel_type, ppm_save_pixels); + + if (out_pix == GP_PIXEL_UNKNOWN) { GP_DEBUG(1, "Invalid pixel type '%s'", GP_PixelTypeName(src->pixel_type)); errno = EINVAL; @@ -1007,7 +1026,9 @@ int GP_SavePPM(const GP_Context *src, const char *dst_path, (unsigned int) src->w, (unsigned int) src->h) < 0) goto err1; - if ((err = save_ascii_rgb888(f, src, callback))) + Convert = GP_LineConvertGet(src->pixel_type, out_pix); + + if ((err = save_ascii_rgb888(f, src, Convert, callback))) goto err1; if (fclose(f)) { @@ -1075,6 +1096,9 @@ int GP_SavePNM(const GP_Context *src, const char *dst_path, case GP_PIXEL_RGB888: return GP_SavePPM(src, dst_path, callback); default: + if (GP_LineConvertible(src->pixel_type, ppm_save_pixels)) + return GP_SavePPM(src, dst_path, callback); + errno = EINVAL; return 1; }
http://repo.or.cz/w/gfxprim.git/commit/eb664a99edb339aba95731b9a437dd8a30ef…
commit eb664a99edb339aba95731b9a437dd8a30ef31b5 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 19 23:14:49 2013 +0200 loaders: LineConvert: Add more conversions. Add match for identity (returns NULL convert functions). Add conversions between xRGB888 and RGB888 and BGR888. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/loaders/GP_LineConvert.c b/libs/loaders/GP_LineConvert.c index 9f3b70c..18655bc 100644 --- a/libs/loaders/GP_LineConvert.c +++ b/libs/loaders/GP_LineConvert.c @@ -23,7 +23,8 @@ #include "core/GP_Debug.h" #include "GP_LineConvert.h" -static void xyz888_to_zyx888(const uint8_t *inbuf, uint8_t *outbuf, unsigned int len) +static void ABC888_to_CBA888(const uint8_t *inbuf, uint8_t *outbuf, + unsigned int len) { unsigned int i; @@ -37,13 +38,43 @@ static void xyz888_to_zyx888(const uint8_t *inbuf, uint8_t *outbuf, unsigned int } } +static void xABC8888_to_ABC888(const uint8_t *inbuf, uint8_t *outbuf, + unsigned int len) +{ + unsigned int i; + + for (i = 0; i < len; i++) { + outbuf[0] = inbuf[1]; + outbuf[1] = inbuf[2]; + outbuf[2] = inbuf[3]; + + outbuf+=3; + inbuf+=4; + } +} + +static void xABC8888_to_CBA888(const uint8_t *inbuf, uint8_t *outbuf, + unsigned int len) +{ + unsigned int i; + + for (i = 0; i < len; i++) { + outbuf[0] = inbuf[3]; + outbuf[1] = inbuf[2]; + outbuf[2] = inbuf[1]; + + outbuf+=3; + inbuf+=4; + } +} + GP_LineConvert GP_LineConvertGet(GP_PixelType in, GP_PixelType out) { switch (in) { case GP_PIXEL_RGB888: switch (out) { case GP_PIXEL_BGR888: - return xyz888_to_zyx888; + return ABC888_to_CBA888; break; default: break; @@ -52,7 +83,19 @@ GP_LineConvert GP_LineConvertGet(GP_PixelType in, GP_PixelType out) case GP_PIXEL_BGR888: switch (out) { case GP_PIXEL_RGB888: - return xyz888_to_zyx888; + return ABC888_to_CBA888; + break; + default: + break; + } + break; + case GP_PIXEL_xRGB8888: + switch (out) { + case GP_PIXEL_RGB888: + return xABC8888_to_ABC888; + break; + case GP_PIXEL_BGR888: + return xABC8888_to_CBA888; break; default: break; @@ -71,6 +114,14 @@ GP_PixelType GP_LineConvertible(GP_PixelType in, GP_PixelType out[]) GP_DEBUG(1, "Trying to find conversion for %s", GP_PixelTypeName(in)); + + for (i = 0; out[i] != GP_PIXEL_UNKNOWN; i++) { + if (out[i] == in) { + GP_DEBUG(1, "Found identity for %s", GP_PixelTypeName(in)); + return in; + } + } + for (i = 0; out[i] != GP_PIXEL_UNKNOWN; i++) { if (GP_LineConvertGet(in, out[i])) { GP_DEBUG(1, "Found %s -> %s", GP_PixelTypeName(in),
http://repo.or.cz/w/gfxprim.git/commit/98452c22c9737ea12fa14cfb1f9551886ee3…
commit 98452c22c9737ea12fa14cfb1f9551886ee320a2 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 19 22:46:47 2013 +0200 loaders: TIFF: Handle correctly on unsuppored pixeltypes. Make the saver exit with ENOSYS on unsupported pixeltypes. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c index 160a85a..3a7b422 100644 --- a/libs/loaders/GP_TIFF.c +++ b/libs/loaders/GP_TIFF.c @@ -621,6 +621,11 @@ int GP_SaveTIFF(const GP_Context *src, const char *dst_path, } switch (src->pixel_type) { + case GP_PIXEL_G1: + case GP_PIXEL_G2: + case GP_PIXEL_G4: + case GP_PIXEL_G8: + break; case GP_PIXEL_RGB888: case GP_PIXEL_BGR888: case GP_PIXEL_xRGB8888: @@ -628,6 +633,8 @@ int GP_SaveTIFF(const GP_Context *src, const char *dst_path, default: GP_DEBUG(1, "Unsupported pixel type %s", GP_PixelTypeName(src->pixel_type)); + errno = ENOSYS; + return 1; } /* Open TIFF image */
http://repo.or.cz/w/gfxprim.git/commit/5f8f0740414d5bc5e5fd4cf51824ed750576…
commit 5f8f0740414d5bc5e5fd4cf51824ed75057681ea Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 19 22:31:12 2013 +0200 tests: loaders: New SaveLoad test. The test calls for each format and each pixel corresponding save function. The expected behavior is either failure with ENOSYS or success. In case of success the image is loaded back and checked. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile index 1d8cc2e..24cd1e4 100644 --- a/tests/loaders/Makefile +++ b/tests/loaders/Makefile @@ -1,11 +1,13 @@ TOPDIR=../.. include $(TOPDIR)/pre.mk -CSOURCES=$(shell echo *.c) +CSOURCES=loaders_suite.c PNG.c PBM.c PGM.c PPM.c +GENSOURCES=SaveLoad.gen.c -APPS=loaders_suite PNG PBM PGM PPM +APPS=loaders_suite PNG PBM PGM PPM SaveLoad.gen include ../tests.mk +include $(TOPDIR)/gen.mk include $(TOPDIR)/app.mk include $(TOPDIR)/post.mk diff --git a/tests/loaders/SaveLoad.gen.c.t b/tests/loaders/SaveLoad.gen.c.t new file mode 100644 index 0000000..df2767f --- /dev/null +++ b/tests/loaders/SaveLoad.gen.c.t @@ -0,0 +1,136 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> * + * * + *****************************************************************************/ + +%% extends "base.test.c.t" + +%% block descr +Iterate over all pixel types, try to save and load back context. +%% endblock descr + +%% block body + +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +#include <core/GP_Context.h> +#include <core/GP_GetPutPixel.h> +#include <loaders/GP_Loaders.h> + +#include "tst_test.h" + +%% set fmts = ['PNG', 'JPG', 'TIFF', 'BMP', 'PBM', 'PGM', 'PPM', 'PNM'] + +typedef int (*Save)(const GP_Context *src, const char *path, GP_ProgressCallback *callback); +typedef GP_Context *(*Load)(const char *path, GP_ProgressCallback *callback); + +static int test(Save Saver, Load Loader, GP_PixelType pixel_type) +{ + GP_Context *src; + GP_Context *res; + unsigned int x, y; + int ret = TST_SUCCESS; + + src = GP_ContextAlloc(100, 100, pixel_type); + + if (!src) { + tst_msg("Malloc failed"); + return TST_UNTESTED; + } + + for (x = 0; x < src->w; x++) + for (y = 0; y < src->w; y++) + GP_PutPixel(src, x, y, 0); + + if (Saver(src, "testfile", NULL)) { + if (errno == ENOSYS) { + tst_msg("Unimplemented pixel value"); + ret = TST_SKIPPED; + goto err; + } + + if (errno == EINVAL) { + tst_msg("Invalid pixel value for the format"); + ret = TST_SKIPPED; + goto err; + } + + tst_msg("Saver failed with %s", strerror(errno)); + ret = TST_FAILED; + goto err; + } + + res = Loader("testfile", NULL); + + if (!res) { + tst_msg("Failed to load saved image"); + ret = TST_FAILED; + goto err; + } + + tst_msg("Loaded back as %s", GP_PixelTypeName(res->pixel_type)); + + if (res->w != src->w || res->h != src->h) { + tst_msg("Invalid loaded image size %ux%u", res->w, res->h); + ret = TST_FAILED; + } + + if (GP_GetPixel(res, 0, 0) != 0) { + tst_msg("Pixel value is wrong %x", GP_GetPixel(res, 0, 0)); + ret = TST_FAILED; + } + + GP_ContextFree(res); +err: + GP_ContextFree(src); + return ret; +} + +%% for fmt in fmts +%% for pt in pixeltypes +%% if not pt.is_unknown() +static int test_{{ fmt }}_{{ pt.name }}(void) +{ + return test(GP_Save{{ fmt }}, GP_Load{{ fmt }}, GP_PIXEL_{{ pt.name }}); +} + +%% endif +%% endfor +%% endfor + +const struct tst_suite tst_suite = { + .suite_name = "SaveLoad", + .tests = { +%% for fmt in fmts +%% for pt in pixeltypes +%% if not pt.is_unknown() + {.name = "{{ fmt }} {{ pt.name }}", + .tst_fn = test_{{ fmt }}_{{ pt.name }}, + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, +%% endif +%% endfor +%% endfor + {.name = NULL}, + } +}; + +%% endblock body diff --git a/tests/loaders/test_list.txt b/tests/loaders/test_list.txt index 1593ff6..e9fdf3d 100644 --- a/tests/loaders/test_list.txt +++ b/tests/loaders/test_list.txt @@ -4,3 +4,4 @@ PNG PBM PGM PPM +SaveLoad.gen
http://repo.or.cz/w/gfxprim.git/commit/9eda828f0117515f5698c1101e632fff8238…
commit 9eda828f0117515f5698c1101e632fff823830fd Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 19 21:18:43 2013 +0200 test: loaders: Fix whitespaces. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/tests/loaders/Loader.h b/tests/loaders/Loader.h index d8a916d..d1a81b2 100644 --- a/tests/loaders/Loader.h +++ b/tests/loaders/Loader.h @@ -58,7 +58,7 @@ static int test_load(struct testcase *test) for (y = 0; y < img->h; y++) { GP_Pixel pix = GP_GetPixel(img, x, y); - + if (pix != test->pix) { if (err < 5) tst_msg("%08x instead of %08x (%ux%u)", diff --git a/tests/loaders/PBM.c b/tests/loaders/PBM.c index ac87f25..86a20a5 100644 --- a/tests/loaders/PBM.c +++ b/tests/loaders/PBM.c @@ -141,31 +141,31 @@ const struct tst_suite tst_suite = { .res_path = "data/pbm/valid/black_2x2_bin.pbm", .data = &black_2x2_bin, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PBM Load 3x9 (black) Raw", .tst_fn = test_load, .res_path = "data/pbm/valid/black_3x9_bin.pbm", .data = &black_3x9_bin, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PBM Load corrupt", .tst_fn = test_load_fail, .res_path = "data/pbm/corrupt/short.pbm", .data = "short.pbm", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PBM Load wrong header", .tst_fn = test_load_fail, .res_path = "data/pbm/corrupt/wrong_header.pbm", .data = "wrong_header.pbm", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PBM Load empty", .tst_fn = test_load_fail, .res_path = "data/pbm/corrupt/empty.pbm", .data = "empty.pbm", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PBM Save Load", .tst_fn = test_save_load, .data = &save_load, diff --git a/tests/loaders/PGM.c b/tests/loaders/PGM.c index f914a8e..6bac05a 100644 --- a/tests/loaders/PGM.c +++ b/tests/loaders/PGM.c @@ -94,7 +94,7 @@ const struct tst_suite tst_suite = { .res_path = "data/pgm/valid/black_1x1_1bpp.pgm", .data = &black_1x1_1bpp, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PGM Load 1x1 2bpp (black)", .tst_fn = test_load, .res_path = "data/pgm/valid/black_1x1_2bpp.pgm", @@ -106,7 +106,7 @@ const struct tst_suite tst_suite = { .res_path = "data/pgm/valid/black_1x1_4bpp.pgm", .data = &black_1x1_4bpp, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PGM Load 1x1 8bpp (black)", .tst_fn = test_load, .res_path = "data/pgm/valid/black_1x1_8bpp.pgm", @@ -132,13 +132,13 @@ const struct tst_suite tst_suite = { .tst_fn = test_save_load, .data = &save_load_8bpp, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PGM Load wrong header", .tst_fn = test_load_fail, .res_path = "data/pgm/corrupt/wrong_header.pgm", .data = "wrong_header.pgm", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PGM Load incomplete", .tst_fn = test_load_fail, .res_path = "data/pgm/corrupt/incomplete.pgm", diff --git a/tests/loaders/PNG.c b/tests/loaders/PNG.c index 540e492..0803e98 100644 --- a/tests/loaders/PNG.c +++ b/tests/loaders/PNG.c @@ -134,7 +134,7 @@ static int test_save_PNG(GP_PixelType pixel_type) tst_msg("Failed to allocate context"); return TST_UNTESTED; } - + errno = 0; ret = GP_SavePNG(ctx, "/dev/null", NULL); @@ -166,53 +166,53 @@ const struct tst_suite tst_suite = { .res_path = "data/png/valid/100x100-red.png", .data = &red, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 RGB 50% alpha", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-red-alpha.png", .data = "100x100-red-alpha.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 8 bit Grayscale", .tst_fn = test_load_PNG_check_color, .res_path = "data/png/valid/100x100-black-grayscale.png", .data = &black_grayscale, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 8 bit Grayscale + alpha", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-black-grayscale-alpha.png", .data = "100x100-black-grayscale-alpha.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 Palette + alpha", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-palette-alpha.png", .data = "100x100-palette-alpha.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 Palette", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-red-palette.png", .data = "100x100-red-palette.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 RGB Adam7", .tst_fn = test_load_PNG_check_color, .res_path = "data/png/valid/100x100-white-adam7.png", .data = &white_adam7, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Save 100x100 G1", .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_G1, .flags = TST_CHECK_MALLOC}, - + {.name = "PNG Save 100x100 G2", .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_G2, .flags = TST_CHECK_MALLOC}, - + {.name = "PNG Save 100x100 G4", .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_G4, @@ -222,12 +222,12 @@ const struct tst_suite tst_suite = { .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_G8, .flags = TST_CHECK_MALLOC}, - + {.name = "PNG Save 100x100 RGB888", .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_RGB888, .flags = TST_CHECK_MALLOC}, - + {.name = "PNG Save 100x100 BGR888", .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_BGR888, diff --git a/tests/loaders/PPM.c b/tests/loaders/PPM.c index b4790cf..3082ce4 100644 --- a/tests/loaders/PPM.c +++ b/tests/loaders/PPM.c @@ -55,7 +55,7 @@ const struct tst_suite tst_suite = { .res_path = "data/ppm/valid/black_1x1.ppm", .data = &black_1x1, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PPM Save Load", .tst_fn = test_save_load, .data = &save_load, @@ -66,7 +66,7 @@ const struct tst_suite tst_suite = { .res_path = "data/ppm/corrupt/wrong_header.ppm", .data = "wrong_header.ppm", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PPM Load incomplete", .tst_fn = test_load_fail, .res_path = "data/ppm/corrupt/incomplete.ppm", diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c index 8b378dd..333eccd 100644 --- a/tests/loaders/loaders_suite.c +++ b/tests/loaders/loaders_suite.c @@ -97,7 +97,7 @@ static int save_load(enum fmt fmt, GP_Size w, GP_Size h) GP_Context *img, *res; img = GP_ContextAlloc(w, h, GP_PIXEL_RGB888); - + if (img == NULL) { tst_warn("GP_ContextAlloc failed"); return TST_UNTESTED; @@ -110,7 +110,7 @@ static int save_load(enum fmt fmt, GP_Size w, GP_Size h) tst_msg("Save %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; } - + tst_msg("Failed to save %s: %s", strfmt(fmt), strerror(errno)); return TST_FAILED; @@ -163,14 +163,14 @@ static int test_BMP_stress(void) static int load_enoent(enum fmt fmt) { GP_Context *img; - - img = load(fmt, "nonexistent"); - + + img = load(fmt, "nonexistent"); + if (img != NULL) { tst_msg("Test succedded unexpectedly"); return TST_FAILED; } - + if (errno == ENOSYS) { tst_msg("Load %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; @@ -210,7 +210,7 @@ static int load_eacces(enum fmt fmt) GP_Context *img; snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt)); - + FILE *f = fopen(buf, "w"); if (f == NULL) { @@ -231,7 +231,7 @@ static int load_eacces(enum fmt fmt) tst_msg("Test succedded unexpectedly"); return TST_FAILED; } - + if (errno == ENOSYS) { tst_msg("Load %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; @@ -272,7 +272,7 @@ static int load_eio(enum fmt fmt) GP_Context *img; snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt)); - + FILE *f = fopen(buf, "w"); if (f == NULL) { @@ -288,7 +288,7 @@ static int load_eio(enum fmt fmt) tst_msg("Test succedded unexpectedly"); return TST_FAILED; } - + if (errno == ENOSYS) { tst_msg("Load %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; @@ -299,7 +299,7 @@ static int load_eio(enum fmt fmt) strerror(errno)); return TST_FAILED; } - + return TST_SUCCESS; } @@ -344,7 +344,7 @@ static int test_PNG_Save_abort(void) tst_msg("Failed to save PNG saving"); return TST_FAILED; } - + if (errno == ENOSYS) { tst_msg("Load PNG: ENOSYS"); return TST_SKIPPED; @@ -357,7 +357,7 @@ static int test_PNG_Save_abort(void) } GP_ContextFree(img); - + return TST_SUCCESS; } @@ -368,12 +368,12 @@ static int test_PNG_Load_abort(void) img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888); if (GP_SavePNG(img, "test.png", NULL)) { - + if (errno == ENOSYS) { tst_msg("Save PNG: ENOSYS"); return TST_SKIPPED; } - + tst_msg("Failed to save PNG: %s", strerror(errno)); return TST_FAILED; } @@ -417,7 +417,7 @@ enum file_flags { }; static struct file_testcase file_testcases[] = { - + /* * Should fail the file signature based loader * as the signature could have been loaded but @@ -443,7 +443,7 @@ static struct file_testcase file_testcases[] = { {"wrong.tif", FILE_CREATE | FILE_FILL, ENOSYS}, {"wrong.tiff", FILE_CREATE | FILE_FILL, ENOSYS}, - /* + /* * Should start signature-based loader and * fail it to read start of the file. */ @@ -453,7 +453,7 @@ static struct file_testcase file_testcases[] = { {".dc", FILE_CREATE, EIO}, {"dc", FILE_CREATE, EIO}, {"cba", FILE_CREATE, EIO}, - + /* * Dtto but for hits the extension based * loader first and fail to read image header @@ -501,8 +501,7 @@ static int test_Load(void) if (file_testcases[i].create & FILE_FILL) { if (fwrite(buf, sizeof(buf), 1, f) != 1) tst_msg("Failed to write to '%s'", - file_testcases[i].filename); - + file_testcases[i].filename); } fclose(f); @@ -514,7 +513,6 @@ static int test_Load(void) for (i = 0; file_testcases[i].filename != NULL; i++) { GP_Context *ret; - errno = 0; ret = GP_LoadImage(file_testcases[i].filename, NULL); @@ -533,7 +531,7 @@ static int test_Load(void) file_testcases[i].filename); continue; } - + if (file_testcases[i].expected_errno != saved_errno) { tst_msg("Expected errno %i (%s) got %i (%s) on '%s'", file_testcases[i].expected_errno, @@ -676,7 +674,7 @@ const struct tst_suite tst_suite = { .flags = TST_TMPDIR}, {.name = "BMP Load EACCES", .tst_fn = test_BMP_Load_EACCES, .flags = TST_TMPDIR}, - + {.name = "PNG Load EIO", .tst_fn = test_PNG_Load_EIO, .flags = TST_TMPDIR}, {.name = "JPG Load EIO", .tst_fn = test_JPG_Load_EIO, @@ -685,17 +683,17 @@ const struct tst_suite tst_suite = { .flags = TST_TMPDIR}, {.name = "BMP Load EIO", .tst_fn = test_BMP_Load_EIO, .flags = TST_TMPDIR}, - + /* Generic GP_LoadImage test */ {.name = "Image Load", .tst_fn = test_Load, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + /* Callback abort tests */ {.name = "PNG Load abort", .tst_fn = test_PNG_Load_abort, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, {.name = "PNG Save abort", .tst_fn = test_PNG_Save_abort, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + /* Basic Save Load tests */ {.name = "PNG Save Load", .tst_fn = test_PNG_Save_Load, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, @@ -703,7 +701,7 @@ const struct tst_suite tst_suite = { .flags = TST_TMPDIR | TST_CHECK_MALLOC}, {.name = "BMP Save Load", .tst_fn = test_BMP_Save_Load, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + /* Stress Save Load tests */ {.name = "PNG Stress", .tst_fn = test_PNG_stress, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, @@ -717,37 +715,37 @@ const struct tst_suite tst_suite = { .tst_fn = test_load_BMP_1bpp_1x1, .res_path = "data/bmp/bitmaps/valid/1bpp-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP Load 4bpp 1x1", .tst_fn = test_load_BMP_4bpp_1x1, .res_path = "data/bmp/bitmaps/valid/4bpp-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP Load 8bpp 1x1", .tst_fn = test_load_BMP_8bpp_1x1, .res_path = "data/bmp/bitmaps/valid/8bpp-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP 24bpp 1x1", .tst_fn = test_load_BMP_24bpp_1x1, .res_path = "data/bmp/bitmaps/valid/24bpp-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP 32bpp 1x1", .tst_fn = test_load_BMP_32bpp_1x1, .res_path = "data/bmp/bitmaps/valid/32bpp-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP 555 1x1", .tst_fn = test_load_BMP_555_1x1, .res_path = "data/bmp/bitmaps/valid/555-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP 565 1x1", .tst_fn = test_load_BMP_565_1x1, .res_path = "data/bmp/bitmaps/valid/565-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP 8bpp 1x64000", .tst_fn = test_load_BMP_8bpp_1x64000, .res_path = "data/bmp/bitmaps/valid/8bpp-1x64000.bmp", ----------------------------------------------------------------------- Summary of changes: libs/loaders/GP_BMP.c | 17 ++--- libs/loaders/GP_JPG.c | 19 ++---- libs/loaders/GP_LineConvert.c | 57 ++++++++++++++++- libs/loaders/GP_PNM.c | 45 +++++++++++--- libs/loaders/GP_TIFF.c | 7 ++ tests/loaders/Loader.h | 17 ++++- tests/loaders/Makefile | 6 +- tests/loaders/PBM.c | 10 ++-- tests/loaders/PGM.c | 8 +- tests/loaders/PNG.c | 24 ++++---- tests/loaders/PPM.c | 4 +- tests/loaders/SaveLoad.gen.c.t | 136 ++++++++++++++++++++++++++++++++++++++++ tests/loaders/loaders_suite.c | 66 +++++++++---------- tests/loaders/test_list.txt | 1 + 14 files changed, 320 insertions(+), 97 deletions(-) create mode 100644 tests/loaders/SaveLoad.gen.c.t repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive no reply. -- gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
0
0
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc0-173-g8d2ecb3
by metan
18 Sep '13
18 Sep '13
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git. The branch, master has been updated via 8d2ecb32294836112e300b456b2d620f1b033b31 (commit) via 68bf70ebf964f8c18fd9c6236bed90635bba33aa (commit) via 7bf591aaf8c469582e3f0ad66a09f4de9d9141c7 (commit) via 3d75c6b108284ae15bd94f5741023d92b87225b9 (commit) from 2af0fde79674ad30155948d78316c5dfa3df83c4 (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/8d2ecb32294836112e300b456b2d620f1b03…
commit 8d2ecb32294836112e300b456b2d620f1b033b31 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Wed Sep 18 00:14:24 2013 +0200 text: fonts: Add C64 like monospace font. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c index 5091ffa..f0608c7 100644 --- a/demos/c_simple/fileview.c +++ b/demos/c_simple/fileview.c @@ -72,6 +72,9 @@ void redraw_screen(void) style.font = GP_FontTiny; break; case 4: + style.font = GP_FontC64; + break; + case 5: style.font = font; break; } @@ -133,9 +136,9 @@ void event_loop(void) switch (ev.val.key.key) { case GP_KEY_SPACE: if (font) - font_flag = (font_flag + 1) % 5; + font_flag = (font_flag + 1) % 6; else - font_flag = (font_flag + 1) % 4; + font_flag = (font_flag + 1) % 5; redraw_screen(); GP_BackendFlip(backend); diff --git a/demos/c_simple/fonttest.c b/demos/c_simple/fonttest.c index 4c35110..2ecfa05 100644 --- a/demos/c_simple/fonttest.c +++ b/demos/c_simple/fonttest.c @@ -119,6 +119,9 @@ void redraw_screen(void) style.font = GP_FontTinyMono; break; case 4: + style.font = GP_FontC64; + break; + case 5: style.font = font; break; } @@ -201,9 +204,9 @@ void event_loop(void) switch (ev.val.key.key) { case GP_KEY_SPACE: if (font) - font_flag = (font_flag + 1) % 5; + font_flag = (font_flag + 1) % 6; else - font_flag = (font_flag + 1) % 4; + font_flag = (font_flag + 1) % 5; redraw_screen(); GP_BackendFlip(win); diff --git a/include/text/GP_Fonts.h b/include/text/GP_Fonts.h index d05dfc3..3a54da3 100644 --- a/include/text/GP_Fonts.h +++ b/include/text/GP_Fonts.h @@ -39,4 +39,9 @@ extern const GP_FontFace *GP_FontTinyMono; */ extern const GP_FontFace *GP_FontTiny; +/* + * Monospace 8x8 Commodore 64 like font. + */ +extern const GP_FontFace *GP_FontC64; + #endif /* TEXT_GP_FONTS_H */ diff --git a/libs/text/GP_FontC64.c b/libs/text/GP_FontC64.c new file mode 100644 index 0000000..4d476de --- /dev/null +++ b/libs/text/GP_FontC64.c @@ -0,0 +1,231 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> * + * * + *****************************************************************************/ + +#include "GP_Font.h" + +static int8_t c64_glyphs[] = { + /* ' ' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '!' */ 8, 7, 0, 7, 8, + 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x30, + /* '"' */ 8, 7, 0, 7, 8, + 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x00, 0x00, + /* '#' */ 8, 7, -1, 7, 8, + 0x66, 0x66, 0xff, 0x66, 0xff, 0x66, 0x66, + /* '$' */ 8, 7, 0, 7, 8, + 0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30, + /* '%' */ 8, 7, 0, 7, 8, + 0xc4, 0xcc, 0x18, 0x30, 0x60, 0xcc, 0x8c, + /* '&' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0x78, 0x70, 0xce, 0xcc, 0x7e, + /* ''' */ 8, 7, 0, 7, 8, + 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, + /* '(' */ 8, 7, 0, 7, 8, + 0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, + /* ')' */ 8, 7, 0, 7, 8, + 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, + /* '*' */ 8, 7, -1, 7, 8, + 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, + /* '+' */ 8, 7, 0, 7, 8, + 0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, + /* ',' */ 8, 7, 0, 6, 8, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60, + /* '-' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, + /* '.' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, + /* '/' */ 8, 7, 0, 7, 8, + 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, + /* '0' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0xdc, 0xec, 0xcc, 0xcc, 0x78, + /* '1' */ 8, 7, 0, 7, 8, + 0x30, 0x30, 0x70, 0x30, 0x30, 0x30, 0xfc, + /* '2' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0x0c, 0x18, 0x60, 0xc0, 0xfc, + /* '3' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, + /* '4' */ 8, 7, 0, 7, 8, + 0x0c, 0x1c, 0x3c, 0xcc, 0xfe, 0x0c, 0x0c, + /* '5' */ 8, 7, 0, 7, 8, + 0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, + /* '6' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, + /* '7' */ 8, 7, 0, 7, 8, + 0xfc, 0xcc, 0x18, 0x30, 0x30, 0x30, 0x30, + /* '8' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, + /* '9' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, + /* ':' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0x30, 0x00, 0x00, 0x30, 0x00, + /* ';' */ 8, 7, 0, 6, 8, + 0x00, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60, + /* '<' */ 8, 7, 0, 7, 8, + 0x1c, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x1c, + /* '=' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0x00, + /* '>' */ 8, 7, 0, 7, 8, + 0xe0, 0x30, 0x18, 0x0c, 0x18, 0x30, 0xe0, + /* '?' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, + /* '@' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0xdc, 0xdc, 0xc0, 0xc4, 0x78, + /* 'A' */ 8, 7, 0, 7, 8, + 0x30, 0x78, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, + /* 'B' */ 8, 7, 0, 7, 8, + 0xf8, 0xcc, 0xcc, 0xf8, 0xcc, 0xcc, 0xf8, + /* 'C' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0xc0, 0xc0, 0xc0, 0xcc, 0x78, + /* 'D' */ 8, 7, 0, 7, 8, + 0xf0, 0xd8, 0xcc, 0xcc, 0xcc, 0xd8, 0xf0, + /* 'E' */ 8, 7, 0, 7, 8, + 0xfc, 0xc0, 0xc0, 0xf8, 0xc0, 0xc0, 0xfc, + /* 'F' */ 8, 7, 0, 7, 8, + 0xfc, 0xc0, 0xc0, 0xf8, 0xc0, 0xc0, 0xc0, + /* 'G' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0xc0, 0xdc, 0xcc, 0xcc, 0x78, + /* 'H' */ 8, 7, 0, 7, 8, + 0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, + /* 'I' */ 8, 7, 0, 7, 8, + 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, + /* 'J' */ 8, 7, 0, 7, 8, + 0x3c, 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, + /* 'K' */ 8, 7, 0, 7, 8, + 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, + /* 'L' */ 8, 7, 0, 7, 8, + 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, + /* 'M' */ 8, 7, 0, 7, 8, + 0xc6, 0xee, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, + /* 'N' */ 8, 7, 0, 7, 8, + 0xcc, 0xec, 0xfc, 0xfc, 0xdc, 0xcc, 0xcc, + /* 'O' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, + /* 'P' */ 8, 7, 0, 7, 8, + 0xf8, 0xcc, 0xcc, 0xf8, 0xc0, 0xc0, 0xc0, + /* 'Q' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x1c, + /* 'R' */ 8, 7, 0, 7, 8, + 0xf8, 0xcc, 0xcc, 0xf8, 0xf0, 0xd8, 0xcc, + /* 'S' */ 8, 7, 0, 7, 8, + 0x78, 0xcc, 0xc0, 0x78, 0x0c, 0xcc, 0x78, + /* 'T' */ 8, 7, 0, 7, 8, + 0xfc, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + /* 'U' */ 8, 7, 0, 7, 8, + 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, + /* 'V' */ 8, 7, 0, 7, 8, + 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, + /* 'W' */ 8, 7, 0, 7, 8, + 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, + /* 'X' */ 8, 7, 0, 7, 8, + 0xcc, 0xcc, 0x78, 0x30, 0x78, 0xcc, 0xcc, + /* 'Y' */ 8, 7, 0, 7, 8, + 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x30, + /* 'Z' */ 8, 7, 0, 7, 8, + 0xfc, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xfc, + /* '[' */ 8, 7, 0, 7, 8, + 0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, + /* '' */ 8, 7, 0, 7, 8, + 0x00, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, + /* ']' */ 8, 7, 0, 7, 8, + 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, + /* '^' */ 8, 7, 0, 7, 8, + 0x30, 0x78, 0xcc, 0x00, 0x00, 0x00, 0x00, + /* '_' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, + /* '`' */ 8, 7, 0, 7, 8, + 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, + /* 'a' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7c, + /* 'b' */ 8, 7, 0, 7, 8, + 0x00, 0xc0, 0xc0, 0xf8, 0xcc, 0xcc, 0xf8, + /* 'c' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0x78, 0xc0, 0xc0, 0xc0, 0x78, + /* 'd' */ 8, 7, 0, 7, 8, + 0x00, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x7c, + /* 'e' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, + /* 'f' */ 8, 7, 0, 7, 8, + 0x00, 0x38, 0x60, 0xf8, 0x60, 0x60, 0x60, + /* 'g' */ 8, 7, 0, 6, 8, + 0x00, 0x7c, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, + /* 'h' */ 8, 7, 0, 7, 8, + 0x00, 0xc0, 0xc0, 0xf8, 0xcc, 0xcc, 0xcc, + /* 'i' */ 8, 7, 0, 7, 8, + 0x00, 0x30, 0x00, 0x70, 0x30, 0x30, 0x78, + /* 'j' */ 8, 7, 0, 6, 8, + 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0xf0, + /* 'k' */ 8, 7, 0, 7, 8, + 0x00, 0xc0, 0xc0, 0xd8, 0xf0, 0xd8, 0xcc, + /* 'l' */ 8, 7, 0, 7, 8, + 0x00, 0x70, 0x30, 0x30, 0x30, 0x30, 0x78, + /* 'm' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xc6, + /* 'n' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0xcc, + /* 'o' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, + /* 'p' */ 8, 7, 0, 6, 8, + 0x00, 0xf8, 0xcc, 0xcc, 0xf8, 0xc0, 0xc0, + /* 'q' */ 8, 7, 0, 6, 8, + 0x00, 0x7c, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, + /* 'r' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0xf8, 0xcc, 0xc0, 0xc0, 0xc0, + /* 's' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, + /* 't' */ 8, 7, 0, 7, 8, + 0x00, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x1c, + /* 'u' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, + /* 'v' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, + /* 'w' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0xc6, 0xd6, 0xfe, 0x7c, 0x6c, + /* 'x' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0xcc, 0x78, 0x30, 0x78, 0xcc, + /* 'y' */ 8, 7, 0, 6, 8, + 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x18, 0xf0, + /* 'z' */ 8, 7, 0, 7, 8, + 0x00, 0x00, 0xfc, 0x18, 0x30, 0x60, 0xfc, + /* '{' */ 8, 7, 0, 7, 8, + 0x30, 0x60, 0x60, 0xc0, 0x60, 0x60, 0x30, + /* '|' */ 8, 7, 0, 7, 8, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + /* '}' */ 8, 7, 0, 7, 8, + 0x30, 0x18, 0x18, 0x0c, 0x18, 0x18, 0x30, + /* '~' */ 8, 7, 0, 7, 8, + 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static struct GP_FontFace c64 = { + .family_name = "C64", + .style_name = "Mono", + .charset = GP_CHARSET_7BIT, + .ascend = 7, + .descend = 2, + .max_glyph_width = 8, + .max_glyph_advance = 9, + .glyph_bitmap_format = GP_FONT_BITMAP_1BPP, + .glyphs = c64_glyphs, + .glyph_offsets = {12}, +}; + +const struct GP_FontFace *GP_FontC64 = &c64;
http://repo.or.cz/w/gfxprim.git/commit/68bf70ebf964f8c18fd9c6236bed90635bba…
commit 68bf70ebf964f8c18fd9c6236bed90635bba33aa Author: Cyril Hrubis <metan(a)ucw.cz> Date: Wed Sep 18 00:11:24 2013 +0200 libs: text: Small enhancements for default monospace font. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/text/GP_DefaultFont.c b/libs/text/GP_DefaultFont.c index 52b6608..d67fa99 100644 --- a/libs/text/GP_DefaultFont.c +++ b/libs/text/GP_DefaultFont.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * <jiri.bluebear.dluhos(a)gmail.com> * * * - * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> * + * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> * * * *****************************************************************************/ @@ -58,25 +58,25 @@ static int8_t default_console_glyphs[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, /* '/' */ 7, 11, 0, 9, 8, 0x00, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x00, 0x00, - /* '0' */ 7, 11, 0, 9, 8, + /* '0' */ 7, 11, 1, 9, 8, 0x78, 0x84, 0x8c, 0x94, 0xb4, 0xa4, 0xc4, 0x84, 0x78, 0x00, 0x00, - /* '1' */ 7, 11, 0, 9, 8, + /* '1' */ 7, 11, 1, 9, 8, 0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, - /* '2' */ 7, 11, 0, 9, 8, + /* '2' */ 7, 11, 1, 9, 8, 0x78, 0x84, 0x84, 0x04, 0x18, 0x60, 0x80, 0x80, 0xfc, 0x00, 0x00, - /* '3' */ 7, 11, 0, 9, 8, + /* '3' */ 7, 11, 1, 9, 8, 0x78, 0x84, 0x84, 0x04, 0x18, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '4' */ 7, 11, 0, 9, 8, + /* '4' */ 7, 11, 1, 9, 8, 0x18, 0x28, 0x48, 0x48, 0x88, 0xfc, 0x08, 0x08, 0x08, 0x00, 0x00, - /* '5' */ 7, 11, 0, 9, 8, + /* '5' */ 7, 11, 1, 9, 8, 0xfc, 0x80, 0x80, 0xf8, 0x04, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '6' */ 7, 11, 0, 9, 8, + /* '6' */ 7, 11, 1, 9, 8, 0x78, 0x80, 0x80, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '7' */ 7, 11, 0, 9, 8, + /* '7' */ 7, 11, 1, 9, 8, 0xfc, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, - /* '8' */ 7, 11, 0, 9, 8, + /* '8' */ 7, 11, 1, 9, 8, 0x78, 0x84, 0x84, 0x84, 0x78, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '9' */ 7, 11, 0, 9, 8, + /* '9' */ 7, 11, 1, 9, 8, 0x78, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, 0x78, 0x00, 0x00, /* ':' */ 7, 11, 0, 9, 8, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, @@ -100,7 +100,7 @@ static int8_t default_console_glyphs[] = { 0x7c, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00, 0x00, /* 'D' */ 7, 11, 0, 9, 8, 0xf8, 0x84, 0x82, 0x82, 0x82, 0x82, 0x82, 0x84, 0xf8, 0x00, 0x00, - /* 'E' */ 7, 11, 0, 9, 8, + /* 'E' */ 7, 11, 0, 9, 8, 0xfe, 0x80, 0x80, 0x80, 0xfc, 0x80, 0x80, 0x80, 0xfe, 0x00, 0x00, /* 'F' */ 7, 11, 0, 9, 8, 0xfe, 0x80, 0x80, 0x80, 0xf8, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, @@ -149,7 +149,7 @@ static int8_t default_console_glyphs[] = { /* '' */ 7, 11, 0, 9, 8, 0x00, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x00, 0x00, /* ']' */ 7, 11, 0, 9, 8, - 0x1e, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x1e, 0x00, 0x00, + 0x3c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x3c, 0x00, 0x00, /* '^' */ 7, 11, 0, 9, 8, 0x08, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* '_' */ 7, 11, 0, 9, 8,
http://repo.or.cz/w/gfxprim.git/commit/7bf591aaf8c469582e3f0ad66a09f4de9d91…
commit 7bf591aaf8c469582e3f0ad66a09f4de9d9141c7 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Wed Sep 18 00:02:59 2013 +0200 loaders: ZIP: Load PNG images from stored records Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c index 83fe617..794d794 100644 --- a/libs/loaders/GP_ZIP.c +++ b/libs/loaders/GP_ZIP.c @@ -343,8 +343,15 @@ static GP_Context *zip_next_file(FILE *f, GP_ProgressCallback *callback) if (header.uncomp_size == 0) goto out; + off_t cur_off = ftell(f); + ret = GP_ReadJPG(f, callback); + if (!ret) { + fseek(f, cur_off, SEEK_SET); + ret = GP_ReadPNG(f, callback); + } + goto out; break; case COMPRESS_DEFLATE:
http://repo.or.cz/w/gfxprim.git/commit/3d75c6b108284ae15bd94f5741023d92b872…
commit 3d75c6b108284ae15bd94f5741023d92b87225b9 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Sun Sep 15 20:58:10 2013 +0200 core: GP_Pixel: Fix segfault. This fixes segfault in GP_PixelRGBMatch() and GP_PixelRGBLookup() when currently matched pixel in table is not RGB (by skipping all pixels that aren't). NOTE: This was found on paletted framebuffer where (for obvious reasons) correct pixel wasn't found and the framebuffer backend initialization segfaulted while trying to match pixel type (on GP_PIXEL_G8 on NULL dereference). Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c index 4fb13fb..6bb59ea 100644 --- a/libs/core/GP_Pixel.c +++ b/libs/core/GP_Pixel.c @@ -19,14 +19,14 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * <jiri.bluebear.dluhos(a)gmail.com> * * * - * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> * + * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> * * * *****************************************************************************/ #include <string.h> #include "GP_Debug.h" -#include "GP_Pixel.h" +#include "GP_Pixel.h" static const GP_PixelTypeChannel * get_channel(const GP_PixelTypeDescription *desc, const char *name) @@ -78,9 +78,11 @@ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask, for (i = 0; i < GP_PIXEL_MAX; i++) { int res; - const GP_PixelTypeChannel *r, *g, *b, *a; + if (!GP_PixelHasFlags(i, GP_PIXEL_IS_RGB)) + continue; + if (GP_PixelTypes[i].size != bits_per_pixel) continue; @@ -133,6 +135,9 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff, for (i = 0; i < GP_PIXEL_MAX; i++) { const GP_PixelTypeChannel *r, *g, *b, *a; + if (!GP_PixelHasFlags(i, GP_PIXEL_IS_RGB)) + continue; + if (GP_PixelTypes[i].size != bits_per_pixel) continue; ----------------------------------------------------------------------- Summary of changes: demos/c_simple/fileview.c | 7 +- demos/c_simple/fonttest.c | 7 +- include/text/GP_Fonts.h | 5 + libs/core/GP_Pixel.c | 11 ++- libs/loaders/GP_ZIP.c | 7 ++ libs/text/GP_DefaultFont.c | 26 +++--- libs/text/GP_FontC64.c | 231 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 274 insertions(+), 20 deletions(-) create mode 100644 libs/text/GP_FontC64.c repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive no reply. -- gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
0
0
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc0-169-g2af0fde
by metan
12 Sep '13
12 Sep '13
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git. The branch, master has been updated via 2af0fde79674ad30155948d78316c5dfa3df83c4 (commit) via 28e75fadc2c5e65e41fdbba3c868739a9c6b74cc (commit) via e13ec4c6eb8e16ba3d44dfe6f0ff717c73a90552 (commit) from 17fe2ed28b93515ca3cf486e1af6aff088a7d8bd (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/2af0fde79674ad30155948d78316c5dfa3df…
commit 2af0fde79674ad30155948d78316c5dfa3df83c4 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Thu Sep 12 22:48:17 2013 +0200 tests: core: GetPutPixel: Fix warnings. Fix "This decimal constant is unsigned only in ISO C90" warnings. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/tests/core/GetPutPixel.gen.c.t b/tests/core/GetPutPixel.gen.c.t index a843509..1e8bccd 100644 --- a/tests/core/GetPutPixel.gen.c.t +++ b/tests/core/GetPutPixel.gen.c.t @@ -55,7 +55,7 @@ static int check_filled(GP_Context *c) tst_msg("Pixels different %i %i", x, y); return 1; } - + return 0; } @@ -85,16 +85,16 @@ static int GetPutPixel_{{ pt.name }}(void) return TST_UNTESTED; } - if (try_pattern(c, 0x55555555 & {{ 2 ** pt.pixelsize.size - 1}})) + if (try_pattern(c, 0x55555555 & {{ 2 ** pt.pixelsize.size - 1}}U)) err++; - - if (try_pattern(c, 0xaaaaaaaa & {{ 2 ** pt.pixelsize.size - 1}})) + + if (try_pattern(c, 0xaaaaaaaa & {{ 2 ** pt.pixelsize.size - 1}}U)) err++; - - if (try_pattern(c, 0x0f0f0f0f & {{ 2 ** pt.pixelsize.size - 1}})) + + if (try_pattern(c, 0x0f0f0f0f & {{ 2 ** pt.pixelsize.size - 1}}U)) err++; - - if (try_pattern(c, 0xf0f0f0f0 & {{ 2 ** pt.pixelsize.size - 1}})) + + if (try_pattern(c, 0xf0f0f0f0 & {{ 2 ** pt.pixelsize.size - 1}}U)) err++; GP_ContextFree(c); @@ -112,7 +112,7 @@ static int GetPutPixel_{{ pt.name }}(void) static int GetPutPixel_Clipping_{{ pt.name }}(void) { GP_Context *c; - + c = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt.name }}); if (c == NULL) { @@ -129,7 +129,7 @@ static int GetPutPixel_Clipping_{{ pt.name }}(void) for (y = -1000; y < 200; y++) { if (x > 0 && x < 100 && y > 0 && y < 100) continue; - + /* Must be no-op */ GP_PutPixel(c, x, y, 0); @@ -141,9 +141,9 @@ static int GetPutPixel_Clipping_{{ pt.name }}(void) } } } - + GP_ContextFree(c); - + if (err) return TST_FAILED; @@ -157,18 +157,18 @@ const struct tst_suite tst_suite = { .tests = { %% for pt in pixeltypes %% if not pt.is_unknown() - {.name = "GetPutPixel {{ pt.name }}", + {.name = "GetPutPixel {{ pt.name }}", .tst_fn = GetPutPixel_{{ pt.name }}}, %% endif %% endfor %% for pt in pixeltypes %% if not pt.is_unknown() - {.name = "GetPutPixel Clipping {{ pt.name }}", + {.name = "GetPutPixel Clipping {{ pt.name }}", .tst_fn = GetPutPixel_Clipping_{{ pt.name }}}, %% endif %% endfor - + {.name = NULL} } };
http://repo.or.cz/w/gfxprim.git/commit/28e75fadc2c5e65e41fdbba3c868739a9c6b…
commit 28e75fadc2c5e65e41fdbba3c868739a9c6b74cc Author: Cyril Hrubis <metan(a)ucw.cz> Date: Wed Sep 11 19:28:51 2013 +0200 tests: framework: Use $(CC) instead of gcc Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/tests/framework/Makefile b/tests/framework/Makefile index bc04fc1..f7ceb2e 100644 --- a/tests/framework/Makefile +++ b/tests/framework/Makefile @@ -15,10 +15,10 @@ APPS=test ALL+=libtst_preload.so libtst.a libtst_preload.so: tst_preload.o tst_alloc_barriers.o tst_preload_FILE.o - gcc -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@ + $(CC) -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@ libtst.a: tst_suite.o tst_job.o tst_msg.o tst_log.o tst_main.o tst_timespec.o - ar rcs $@ $^ + $(AR) rcs $@ $^ CLEAN+=libtst_preload.so libtst.a log.json
http://repo.or.cz/w/gfxprim.git/commit/e13ec4c6eb8e16ba3d44dfe6f0ff717c73a9…
commit e13ec4c6eb8e16ba3d44dfe6f0ff717c73a90552 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Wed Sep 11 19:19:57 2013 +0200 build: Makefile: include config.mk So that CC and friends are set correctly. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> diff --git a/build/Makefile b/build/Makefile index d21da7a..075c19d 100644 --- a/build/Makefile +++ b/build/Makefile @@ -2,7 +2,9 @@ LIB_OBJECTS=$(shell ./get_objs.sh) .SUFFIXES: -include ../libver.mk +TOPDIR=../ +include $(TOPDIR)/config.mk +include $(TOPDIR)/libver.mk LIB_NAME=libGP ----------------------------------------------------------------------- Summary of changes: build/Makefile | 4 +++- tests/core/GetPutPixel.gen.c.t | 30 +++++++++++++++--------------- tests/framework/Makefile | 4 ++-- 3 files changed, 20 insertions(+), 18 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
0
0
← Newer
1
...
10
11
12
13
14
15
16
...
93
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Results per page:
10
25
50
100
200