Gfxprim
Threads by month
- ----- 2026 -----
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
May 2013
- 1 participants
- 32 discussions
18 May '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 e596ea9912cfde653e3048e64d3a821328975f14 (commit)
via c21eede58f5a634eb89685bfe3b4cc689a21cbcc (commit)
via 86959990865d791b8c411c58db7a0aec37b7425d (commit)
from ea54d1823b32741eebb6465568654e8d1bcd4354 (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/e596ea9912cfde653e3048e64d3a82132897…
commit e596ea9912cfde653e3048e64d3a821328975f14
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 17 23:11:26 2013 +0200
core: GP_Convert: Make it more readable.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t
index 7a7397e..72c974b 100644
--- a/include/core/GP_Convert.gen.h.t
+++ b/include/core/GP_Convert.gen.h.t
@@ -34,16 +34,16 @@
%% set M = out.chans['M']
%% set Y = out.chans['Y']
%% set K = out.chans['K']
-%% set max_bits = max(R[2], G[2], B[2])
-%% set max_val = 2 ** max_bits - 1
- GP_Pixel _R = GP_SCALE_VAL_{{ R[2] }}_{{ max_bits }}(GP_GET_BITS({{ R[1] }}+o1, {{ R[2] }}, p1)); - GP_Pixel _G = GP_SCALE_VAL_{{ G[2] }}_{{ max_bits }}(GP_GET_BITS({{ G[1] }}+o1, {{ G[2] }}, p1)); - GP_Pixel _B = GP_SCALE_VAL_{{ B[2] }}_{{ max_bits }}(GP_GET_BITS({{ B[1] }}+o1, {{ B[2] }}, p1)); +%% set max_size = max(R.size, G.size, B.size)
+%% set max_val = 2 ** max_size - 1
+ GP_Pixel _R = GP_SCALE_VAL_{{ R.size }}_{{ max_size }}(GP_GET_BITS({{ R.off }}+o1, {{ R.size }}, p1)); + GP_Pixel _G = GP_SCALE_VAL_{{ G.size }}_{{ max_size }}(GP_GET_BITS({{ G.off }}+o1, {{ G.size }}, p1)); + GP_Pixel _B = GP_SCALE_VAL_{{ B.size }}_{{ max_size }}(GP_GET_BITS({{ B.off }}+o1, {{ B.size }}, p1)); GP_Pixel _K = GP_MAX3(_R, _G, _B); - GP_SET_BITS({{ C[1] }}+o2, {{ C[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ C[2] }}((_K - _R))); - GP_SET_BITS({{ M[1] }}+o2, {{ M[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ M[2] }}((_K - _G))); - GP_SET_BITS({{ Y[1] }}+o2, {{ Y[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ Y[2] }}((_K - _B))); - GP_SET_BITS({{ K[1] }}+o2, {{ K[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ K[2] }}({{ max_val }} - _K)); + GP_SET_BITS({{ C.off }}+o2, {{ C.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ C.size }}((_K - _R))); + GP_SET_BITS({{ M.off }}+o2, {{ M.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ M.size }}((_K - _G))); + GP_SET_BITS({{ Y.off }}+o2, {{ Y.si
ze }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ Y.size }}((_K - _B))); + GP_SET_BITS({{ K.off }}+o2, {{ K.size }}, p2, GP_SCALE_VAL_{{ max_size }}_{{ K.size }}({{ max_val }} - _K)); %% endmacro
%% macro GP_Pixel_TYPE_TO_TYPE(pt1, pt2)
@@ -60,23 +60,23 @@
{# case 1: just copy a channel -#}
%% if c2[0] in pt1.chans.keys()
%% set c1 = pt1.chans[c2[0]]
- /* {{ c2[0] }}:={{ c1[0] }} */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2,- GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1))); + /* {{ c2[0] }}:={{ c1[0] }} */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2,+ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1))); {# case 2: set A to full opacity (not present in source) -#}
%% elif c2[0]=='A'
- /* A:={{ hex(c2[2]) }} */GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2, {{ hex(2 ** c2[2] - 1) }}); + /* A:={{ c2.C_max }} */GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, {{ c2.C_max }}); {# case 3: calculate V as average of RGB -#}
%% elif c2[0]=='V' and pt1.is_rgb()
- /* V:=RGB_avg */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2, ( + /* V:=RGB_avg */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2, ( %% for c1 in [pt1.chans['R'], pt1.chans['G'], pt1.chans['B']]
- /* {{c1[0]}} */ GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1)) + + /* {{ c1.name }} */ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1)) + %% endfor
0)/3); {# case 4: set each RGB to V -#}
%% elif c2[0] in 'RGB' and pt1.is_gray()
%% set c1 = pt1.chans['V']
- /* {{ c2[0] }}:=V */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2,- GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1))); + /* {{ c2[0] }}:=V */ GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2,+ GP_SCALE_VAL_{{ c1.size }}_{{ c2.size }}(GP_GET_BITS({{ c1.off }}+o1, {{ c1.size }}, p1))); {# case 5: CMYK to RGB -#}
%% elif c2[0] in 'RGB' and pt1.is_cmyk()
%% set K = pt1.chans['K']
@@ -88,10 +88,10 @@
%% else
%% set V = pt1.chans['Y']
%% endif
- GP_SET_BITS({{ c2[1] }}+o2, {{ c2[2] }}, p2,- GP_SCALE_VAL_{{ K[2] + V[2] }}_{{ c2[2] }}(- (({{ 2 ** K[2] - 1 }} - GP_GET_BITS({{ K[1] }}+o1, {{ K[2] }}, p1)) * - ({{ 2 ** V[2] - 1 }} - GP_GET_BITS({{ V[1] }}+o1, {{ V[2] }}, p1))))); + GP_SET_BITS({{ c2.off }}+o2, {{ c2.size }}, p2,+ GP_SCALE_VAL_{{ K.size + V.size }}_{{ c2.size }}(+ (({{ K.C_max }} - GP_GET_BITS({{ K.off }}+o1, {{ K.size }}, p1)) * + ({{ V.C_max }} - GP_GET_BITS({{ V.off }}+o1, {{ V.size }}, p1))))); {# case 7: invalid mapping -#}
%% else
{{ error('Channel conversion ' + pt1.name + ' to ' + pt2.name + ' not supported.') }}
http://repo.or.cz/w/gfxprim.git/commit/c21eede58f5a634eb89685bfe3b4cc689a21…
commit c21eede58f5a634eb89685bfe3b4cc689a21cbcc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 17 20:18:43 2013 +0200
tests: core: New test for pixel conversions.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t
index 6f445e2..84159f1 100644
--- a/tests/core/Convert.gen.c.t
+++ b/tests/core/Convert.gen.c.t
@@ -37,15 +37,15 @@ static GP_Pixel get_black(GP_PixelType pixel_type)
{
switch (pixel_type) {
%% for pt in pixeltypes
- case GP_PIXEL_{{ pt.name }}:
+ case {{ pt.C_enum }}:
%% if pt.is_cmyk()
%% set K = pt.chans['K']
/* Black in CMYK is full K rest zero */
- return {{ hex((2 ** K[2] - 1) * (2 ** K[1]))}};
+ return {{ K.C_mask }};
%% elif pt.is_alpha()
%% set A = pt.chans['A']
/* Black with Alpha channel is full A rest zero */
- return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}};
+ return {{ A.C_mask }};
%% else
return 0;
%% endif
@@ -57,43 +57,86 @@ static GP_Pixel get_black(GP_PixelType pixel_type)
}
/*
+ * Returns white color for particular pixel type.
+ */
+static GP_Pixel get_white(GP_PixelType pixel_type)
+{
+ switch (pixel_type) {
+%% for pt in pixeltypes
+ case {{ pt.C_enum }}:
+%% if pt.is_cmyk()
+ /* White in CMYK is zero */
+ return 0x0;
+%% elif pt.is_rgb()
+%% set R = pt.chans['R']
+%% set G = pt.chans['G']
+%% set B = pt.chans['B']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* White in RGBA */
+ return {{ A.C_mask }} | {{ R.C_mask }} | {{ G.C_mask }} | {{ B.C_mask }};
+%% else
+ /* Plain old RGB */
+ return {{ R.C_mask }} | {{ G.C_mask }} | {{ B.C_mask }};
+%% endif
+%% elif pt.is_gray()
+%% set V = pt.chans['V']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Grayscale with Alpha */
+ return {{ V.C_mask }} | {{ A.C_mask }};
+%% else
+ /* Grayscale */
+ return {{ V.C_mask }};
+%% endif
+%% else
+ tst_msg("FIXME: Unsupported conversion to %s",
+ GP_PixelTypeName(pixel_type));
+ exit(TST_INTERR);
+%% endif
+%% endfor
+ default:
+ tst_msg("Invalid pixel type %i", pixel_type);
+ exit(TST_INTERR);
+ }
+}
+
+/*
* Returns red color for particular pixel type.
*/
static GP_Pixel get_red(GP_PixelType pixel_type)
{
switch (pixel_type) {
%% for pt in pixeltypes
- case GP_PIXEL_{{ pt.name }}:
+ case {{ pt.C_enum }}:
%% if pt.is_cmyk()
%% set M = pt.chans['M']
%% set Y = pt.chans['Y']
/* Red in CMYK is full M and Y rest zero */
- return {{ hex((2 ** M[2] - 1) * (2 ** M[1]))}}
- | {{ hex((2 ** Y[2] - 1) * (2 ** Y[1]))}};
+ return {{ M.C_mask }} | {{ Y.C_mask }};
%% elif pt.is_rgb()
%% set R = pt.chans['R']
%% if pt.is_alpha()
%% set A = pt.chans['A']
/* Red with Alpha channel is full Alpha and R rest zero */
- return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}}
- | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+ return {{ A.C_mask }} | {{ R.C_mask }};
%% else
/* Plain old RGB */
- return {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+ return {{ R.C_mask }};
%% endif
%% elif pt.is_gray()
%% set V = pt.chans['V']
%% if pt.is_alpha()
%% set A = pt.chans['A']
/* Grayscale with Alpha channel is full Alpha + 1/3 Gray */
- return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}};
- | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+ return ({{ hex(V.max // 3)}}{{ V.C_shift }}) | {{ A.C_mask }};
%% else
/* Grayscale is 1/3 Gray */
- return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}};
+ return {{ hex(V.max // 3) }}{{ V.C_shift }};
%% endif
%% else
- tst_msg("Unsupported conversion to %s", GP_PixelTypeName(pixel_type));
+ tst_msg("FIXME: Unsupported conversion to %s",
+ GP_PixelTypeName(pixel_type));
exit(TST_INTERR);
%% endif
%% endfor
@@ -110,6 +153,8 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi
GP_Pixel in = get_{{ test_name }}(GP_PIXEL_{{ in_name }});
GP_Pixel out_exp = get_{{ test_name }}(GP_PIXEL_{{ out_name }});
+ tst_msg("{{ in_name }} %08x -> {{ out_name }} %08x", in, out_exp);
+
GP_Pixel_{{ in_name }}_TO_{{ out_name }}(in, out);
if (out_exp != out) {
@@ -125,12 +170,22 @@ static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(voi
%% macro gen_converts()
%% for pt1 in pixeltypes
%% if not pt1.is_unknown() and not pt1.is_palette()
-%% for pt2 in pixeltypes
-%% if pt2.name in ['RGB888', 'RGBA8888']
-{{ gen_convert_and_check('black', pt2.name, pt1.name) }}
-{{ gen_convert_and_check('red', pt2.name, pt1.name) }}
-%% endif
-%% endfor
+%% if pt1.name not in ['RGB888', 'RGBA8888']
+{{ gen_convert_and_check('white', pt1.name, 'RGB888') }}
+{{ gen_convert_and_check('white', pt1.name, 'RGBA8888') }}
+{{ gen_convert_and_check('white', 'RGB888', pt1.name) }}
+{{ gen_convert_and_check('white', 'RGBA8888', pt1.name) }}
+{{ gen_convert_and_check('black', pt1.name, 'RGB888') }}
+{{ gen_convert_and_check('black', pt1.name, 'RGBA8888') }}
+{{ gen_convert_and_check('black', 'RGB888', pt1.name) }}
+{{ gen_convert_and_check('black', 'RGBA8888', pt1.name) }}
+%% if not pt1.is_gray()
+{{ gen_convert_and_check('red', pt1.name, 'RGB888') }}
+{{ gen_convert_and_check('red', pt1.name, 'RGBA8888') }}
+%% endif
+{{ gen_convert_and_check('red', 'RGB888', pt1.name) }}
+{{ gen_convert_and_check('red', 'RGBA8888', pt1.name) }}
+%% endif
%% endif
%% endfor
%% endmacro
@@ -147,17 +202,24 @@ const struct tst_suite tst_suite = {
.tests = {
%% for pt1 in pixeltypes
%% if not pt1.is_unknown() and not pt1.is_palette()
-%% for pt2 in pixeltypes
-%% if pt2.name in ['RGB888', 'RGBA8888']
-{{ gen_suite_entry('black', pt2.name, pt1.name) }}
-{{ gen_suite_entry('red', pt2.name, pt1.name) }}
+%% if pt1.name not in ['RGB888', 'RGBA8888']
+{{ gen_suite_entry('white', pt1.name, 'RGB888') }}
+{{ gen_suite_entry('white', pt1.name, 'RGBA8888') }}
+{{ gen_suite_entry('white', 'RGB888', pt1.name) }}
+{{ gen_suite_entry('white', 'RGBA8888', pt1.name) }}
+{{ gen_suite_entry('black', pt1.name, 'RGB888') }}
+{{ gen_suite_entry('black', pt1.name, 'RGBA8888') }}
+{{ gen_suite_entry('black', 'RGB888', pt1.name) }}
+{{ gen_suite_entry('black', 'RGBA8888', pt1.name) }}
+%% if not pt1.is_gray()
+{{ gen_suite_entry('red', pt1.name, 'RGB888') }}
+{{ gen_suite_entry('red', pt1.name, 'RGBA8888') }}
%% endif
-%% endfor
+{{ gen_suite_entry('red', 'RGB888', pt1.name) }}
+{{ gen_suite_entry('red', 'RGBA8888', pt1.name) }}
+%% endif
%% endif
%% endfor
-
-{{ gen_suite_entry('red', 'RGB888', 'CMYK8888') }}
-
{.name = NULL}
}
};
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 2fb3c86..2c0d363 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -4,9 +4,9 @@ include $(TOPDIR)/pre.mk
CSOURCES=Context.c Pixel.c
-GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c BlitConv.gen.c
+GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c Convert.gen.c BlitConv.gen.c
-APPS=WritePixel.gen Pixel Context GetPutPixel.gen BlitConv.gen
+APPS=WritePixel.gen Pixel Context GetPutPixel.gen Convert.gen BlitConv.gen
include ../tests.mk
diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt
index 432bef9..45702bb 100644
--- a/tests/core/test_list.txt
+++ b/tests/core/test_list.txt
@@ -3,4 +3,5 @@ WritePixel.gen
Context
Pixel
GetPutPixel.gen
+Convert.gen
BlitConv.gen
http://repo.or.cz/w/gfxprim.git/commit/86959990865d791b8c411c58db7a0aec37b7…
commit 86959990865d791b8c411c58db7a0aec37b7425d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 17 19:50:35 2013 +0200
gp_codegen: pixeltype.py: Edhance channel list members.
Previously the channel list (and dict) members were simple triplets.
This commit creates ChannelList object derived from list and adds
a few convinience member values.
* c.name returns channel name (same as c[0])
* c.off returns channel offset (same as c[1])
* c.size returns channel size in bits (same as c[2])
* c.C_shift returns string with C shift (i.e. " << 8" if off=8)
* c.max returns maximal channel value as int (i.e. 2 ^ len - 1)
* c.C_max returns maximal channel value as hex string
* c.mask returns channel mask as as int
* c.C_mask returns C mask as a string (i.e. "0xff00 for len=8 and off=8)
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gp_codegen/pixeltype.py b/pylib/gp_codegen/pixeltype.py
index eaac404..9e89ddc 100644
--- a/pylib/gp_codegen/pixeltype.py
+++ b/pylib/gp_codegen/pixeltype.py
@@ -2,11 +2,34 @@
# gfxprim.pixeltype - Module with PixelType descrition class
#
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+# 2013 Cyril Hrubis <metan(a)ucw.cz>
#
import re
from .pixelsize import PixelSize
+class PixelChannel(list):
+ def __init__(self, triplet):
+ (name, offset, size) = triplet
+ # Create the list -> backward compatibility with triplets
+ self.append(name)
+ self.append(offset)
+ self.append(size)
+ # Add some convinience variables
+ self.name = name
+ self.off = offset
+ self.size = size
+ # Shift ready to used in C
+ self.C_shift = " << " + hex(offset)
+ # Maximal channel value as an integer
+ self.max = 2 ** size - 1
+ # Maximal value as a C string
+ self.C_max = hex(self.max)
+ # Chanel bitmask as int
+ self.mask = self.max * (2 ** offset)
+ # Channel bitmas as hex string
+ self.C_mask = hex(self.mask)
+
class PixelType(object):
"""Representation of one GP_PixelType"""
@@ -20,14 +43,21 @@ class PixelType(object):
"""
assert re.match('A[A-Za-z][A-Za-z0-9_]*Z', name)
self.name = name
- self.chanslist = chanslist
+ # Create channel list with convinience variables
+ new_chanslist = []
+ for i in chanslist:
+ new_chanslist.append(PixelChannel(i))
+ self.chanslist = new_chanslist
self.chans = dict() # { chan_name: (offset, size) }
self.pixelsize = pixelsize
+ # C enum as defined in GP_Pixel.gen.h
+ self.C_enum = "GP_PIXEL_" + self.name
+
# Verify channel bits for overlaps
# also builds a bit-map of the PixelType
self.bits = ['x'] * pixelsize.size
- for c in chanslist:
+ for c in new_chanslist:
assert c[0] not in self.chans.keys()
self.chans[c[0]] = c
for i in range(c[1], c[1] + c[2]):
diff --git a/tests/core/Convert.gen.c.t b/tests/core/Convert.gen.c.t
new file mode 100644
index 0000000..6f445e2
--- /dev/null
+++ b/tests/core/Convert.gen.c.t
@@ -0,0 +1,165 @@
+/*****************************************************************************
+ * 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 body
+
+#include <stdio.h>
+
+#include <core/GP_Convert.h>
+
+#include "tst_test.h"
+
+/*
+ * Returns black color for particular pixel type.
+ */
+static GP_Pixel get_black(GP_PixelType pixel_type)
+{
+ switch (pixel_type) {
+%% for pt in pixeltypes
+ case GP_PIXEL_{{ pt.name }}:
+%% if pt.is_cmyk()
+%% set K = pt.chans['K']
+ /* Black in CMYK is full K rest zero */
+ return {{ hex((2 ** K[2] - 1) * (2 ** K[1]))}};
+%% elif pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Black with Alpha channel is full A rest zero */
+ return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}};
+%% else
+ return 0;
+%% endif
+%% endfor
+ default:
+ tst_msg("Invalid pixel type %i", pixel_type);
+ exit(TST_INTERR);
+ }
+}
+
+/*
+ * Returns red color for particular pixel type.
+ */
+static GP_Pixel get_red(GP_PixelType pixel_type)
+{
+ switch (pixel_type) {
+%% for pt in pixeltypes
+ case GP_PIXEL_{{ pt.name }}:
+%% if pt.is_cmyk()
+%% set M = pt.chans['M']
+%% set Y = pt.chans['Y']
+ /* Red in CMYK is full M and Y rest zero */
+ return {{ hex((2 ** M[2] - 1) * (2 ** M[1]))}}
+ | {{ hex((2 ** Y[2] - 1) * (2 ** Y[1]))}};
+%% elif pt.is_rgb()
+%% set R = pt.chans['R']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Red with Alpha channel is full Alpha and R rest zero */
+ return {{ hex((2 ** A[2] - 1) * (2 ** A[1]))}}
+ | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+%% else
+ /* Plain old RGB */
+ return {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+%% endif
+%% elif pt.is_gray()
+%% set V = pt.chans['V']
+%% if pt.is_alpha()
+%% set A = pt.chans['A']
+ /* Grayscale with Alpha channel is full Alpha + 1/3 Gray */
+ return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}};
+ | {{ hex((2 ** R[2] - 1) * (2 ** R[1]))}};
+%% else
+ /* Grayscale is 1/3 Gray */
+ return {{ hex(((2 ** V[2] - 1) // 3) * (2 ** V[1]))}};
+%% endif
+%% else
+ tst_msg("Unsupported conversion to %s", GP_PixelTypeName(pixel_type));
+ exit(TST_INTERR);
+%% endif
+%% endfor
+ default:
+ tst_msg("Invalid pixel type %i", pixel_type);
+ exit(TST_INTERR);
+ }
+}
+
+%% macro gen_convert_and_check(test_name, in_name, out_name)
+static int convert_and_check_{{ test_name }}_{{ in_name }}_to_{{ out_name }}(void)
+{
+ GP_Pixel out = 0;
+ GP_Pixel in = get_{{ test_name }}(GP_PIXEL_{{ in_name }});
+ GP_Pixel out_exp = get_{{ test_name }}(GP_PIXEL_{{ out_name }});
+
+ GP_Pixel_{{ in_name }}_TO_{{ out_name }}(in, out);
+
+ if (out_exp != out) {
+ tst_msg("Pixels are different have %08x, expected %08x",
+ out, out_exp);
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+%% endmacro
+
+%% macro gen_converts()
+%% for pt1 in pixeltypes
+%% if not pt1.is_unknown() and not pt1.is_palette()
+%% for pt2 in pixeltypes
+%% if pt2.name in ['RGB888', 'RGBA8888']
+{{ gen_convert_and_check('black', pt2.name, pt1.name) }}
+{{ gen_convert_and_check('red', pt2.name, pt1.name) }}
+%% endif
+%% endfor
+%% endif
+%% endfor
+%% endmacro
+
+{{ gen_converts() }}
+
+%% macro gen_suite_entry(name, from, to)
+ {.name = "Convert {{ name }} {{ from }} -> {{ to }}",
+ .tst_fn = convert_and_check_{{ name }}_{{ from }}_to_{{ to }}},
+%% endmacro
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Pixel Conversions Testsuite",
+ .tests = {
+%% for pt1 in pixeltypes
+%% if not pt1.is_unknown() and not pt1.is_palette()
+%% for pt2 in pixeltypes
+%% if pt2.name in ['RGB888', 'RGBA8888']
+{{ gen_suite_entry('black', pt2.name, pt1.name) }}
+{{ gen_suite_entry('red', pt2.name, pt1.name) }}
+%% endif
+%% endfor
+%% endif
+%% endfor
+
+{{ gen_suite_entry('red', 'RGB888', 'CMYK8888') }}
+
+ {.name = NULL}
+ }
+};
+
+%% endblock body
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Convert.gen.h.t | 40 ++++----
pylib/gp_codegen/pixeltype.py | 34 ++++++-
tests/core/Convert.gen.c.t | 227 +++++++++++++++++++++++++++++++++++++++
tests/core/Makefile | 4 +-
tests/core/test_list.txt | 1 +
5 files changed, 282 insertions(+), 24 deletions(-)
create mode 100644 tests/core/Convert.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
14 May '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 ea54d1823b32741eebb6465568654e8d1bcd4354 (commit)
from 1db276a11bc1bca52f361c7e9f7e4cf2933353d6 (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/ea54d1823b32741eebb6465568654e8d1bcd…
commit ea54d1823b32741eebb6465568654e8d1bcd4354
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue May 14 23:31:21 2013 +0200
spiv: Update help and keys help.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index f16be8c..93dd301 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -709,9 +709,24 @@ static void init_caches(struct loader_params *params)
static const char *keys_help[] = {
"Keyboard control:",
"",
+ "Esc, Enter, Q - quit spiv",
+ "",
+ "< KP Minus - zoom out by 1.5",
+ ">, KP Plus - zoom in by 1.5",
+ "R - rotate by 90 degrees clockwise",
+ "Up, Down, Left, Right - move image by 1px",
+ " (by 10 with Shift)",
+ "",
+ "Space - move to the next image",
+ "BackSpace - move to the prev image",
+ "PgDown - move to the start of directory",
+ "PgUp - move to the end of directory",
+ "Home - move to the first image",
+ "End - move to the last image",
+ "",
"I - toggle show info box",
"P - toggle show progress",
- "R - rotate by 90 degrees",
+ "",
"] - change to next resampling method",
"[ - change to prev resampling method",
" (current method is shown in info box)",
@@ -719,17 +734,6 @@ static const char *keys_help[] = {
"D - drop image cache",
"H - toggle help",
"",
- "Esc",
- "Enter",
- "Q - quit spiv",
- "",
- "PgDown - move 10 images forward",
- "PgUp - move 10 images backward",
- "",
- "Space - move to the next image",
- "",
- "BckSpc - move to the prev image",
- "",
"1 - resize spiv window to the image size",
"2 - resize spiv window to the half of the image size",
"3 - resize spiv window to the third of the image size",
@@ -757,6 +761,8 @@ static void print_help(void)
printf("-e pixel_typentturns on backend type emulationn");
printf("tfor example -e G1 sets 1-bit grayscalenn");
printf("-r anglentrotate display 90,180 or 270 degreesnn");
+ printf("-z sets zoom modent-zf zoom is set and modified by usern");
+ printf("t-zw zoom is fixed to window size (currently default)nn");
printf("-bntpass backend init string to backend initn");
printf("tpass -b help for more infonn");
@@ -783,7 +789,7 @@ static void show_help(void)
GP_Fill(c, black_pixel);
for (i = 0; i < keys_help_len; i++) {
- GP_Print(c, NULL, 20, i * 15, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
+ GP_Print(c, NULL, 20, 2 + i * 15, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white_pixel, black_pixel, "%s", keys_help[i]);
}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 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
11 May '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 1db276a11bc1bca52f361c7e9f7e4cf2933353d6 (commit)
from cd239b320e899c30e786fe99ce8b65c44aabf3a1 (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/1db276a11bc1bca52f361c7e9f7e4cf29333…
commit 1db276a11bc1bca52f361c7e9f7e4cf2933353d6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 11 16:21:39 2013 +0200
tests: core: More tests in BlitConv.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/BlitConv.gen.c.t b/tests/core/BlitConv.gen.c.t
index 4338beb..3305c0e 100644
--- a/tests/core/BlitConv.gen.c.t
+++ b/tests/core/BlitConv.gen.c.t
@@ -73,11 +73,15 @@ static int check_filled(GP_Context *c, GP_Pixel p)
return 0;
}
-%% macro blit_color(name, r, g, b)
-%% for pt1 in pixeltypes
-%% if not pt1.is_unknown() and not pt1.is_palette()
-%% for pt2 in pixeltypes
-%% if not pt2.is_unknown() and not pt2.is_palette()
+static GP_Pixel rgb_to_pixel(int r, int g, int b, GP_Context *c)
+{
+ if (GP_PixelHasFlags(c->pixel_type, GP_PIXEL_HAS_ALPHA))
+ return GP_RGBAToContextPixel(r, g, b, 0xff, c);
+
+ return GP_RGBToContextPixel(r, g, b, c);
+}
+
+%% macro gen_blit(name, r, g, b, pt1, pt2)
static int blit_{{ name }}_{{ pt1.name }}_to_{{ pt2.name }}(void)
{
GP_Context *src = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt1.name }});
@@ -90,17 +94,9 @@ static int blit_{{ name }}_{{ pt1.name }}_to_{{ pt2.name }}(void)
return TST_UNTESTED;
}
- /* Fill source with black, destination with pseudo random mess */
-%% if pt1.is_alpha()
- GP_Pixel pix_src = GP_RGBAToContextPixel({{ r }}, {{ g }}, {{ b }}, 0xff, src);
-%% else
- GP_Pixel pix_src = GP_RGBToContextPixel({{ r }}, {{ g }}, {{ b }}, src);
-%% endif
-%% if pt2.is_alpha()
- GP_Pixel pix_dst = GP_RGBAToContextPixel({{ r }}, {{ g }}, {{ b }}, 0xff, dst);
-%% else
- GP_Pixel pix_dst = GP_RGBToContextPixel({{ r }}, {{ g }}, {{ b }}, dst);
-%% endif
+ /* Fill source with color, destination with pseudo random mess */
+ GP_Pixel pix_src = rgb_to_pixel({{ r }}, {{ g }}, {{ b }}, src);
+ GP_Pixel pix_dst = rgb_to_pixel({{ r }}, {{ g }}, {{ b }}, dst);
tst_msg("pixel_src=%08x pixel_dst=%08x", pix_src, pix_dst);
@@ -114,6 +110,14 @@ static int blit_{{ name }}_{{ pt1.name }}_to_{{ pt2.name }}(void)
return TST_SUCCESS;
}
+%% endmacro
+
+%% macro blit_color(name, r, g, b)
+%% for pt1 in pixeltypes
+%% if not pt1.is_unknown() and not pt1.is_palette()
+%% for pt2 in pixeltypes
+%% if not pt2.is_unknown() and not pt2.is_palette()
+{{ gen_blit(name, r, g, b, pt1, pt2) }}
%% endif
%% endfor
%% endif
@@ -123,6 +127,36 @@ static int blit_{{ name }}_{{ pt1.name }}_to_{{ pt2.name }}(void)
{{ blit_color('black', '0x00', '0x00', '0x00') }}
{{ blit_color('white', '0xff', '0xff', '0xff') }}
+%% macro blit_equal_pixel(name, r, g, b)
+%% for pt1 in pixeltypes
+%% if not pt1.is_unknown() and not pt1.is_palette()
+{{ gen_blit(name, r, g, b, pt1, pt1) }}
+%% endif
+%% endfor
+%% endmacro
+
+{{ blit_equal_pixel('equal_pixel', '0x0f', '0xff', '0x00') }}
+
+%% macro gen_blit2(name, r, g, b, pname1, pname2)
+{{ gen_blit(name, r, g, b, pixeltypes_dict[pname1], pixeltypes_dict[pname2]) }}
+%% endmacro
+
+{{ gen_blit2('red', '0xff', '0x00', '0x00', 'RGB888', 'CMYK8888') }}
+{{ gen_blit2('green', '0x00', '0xff', '0x00', 'RGB888', 'CMYK8888') }}
+{{ gen_blit2('blue', '0x00', '0x00', '0xff', 'RGB888', 'CMYK8888') }}
+{{ gen_blit2('gray', '0xef', '0xef', '0xef', 'RGB888', 'CMYK8888') }}
+
+{{ gen_blit2('red', '0xff', '0x00', '0x00', 'CMYK8888', 'RGB888') }}
+{{ gen_blit2('green', '0x00', '0xff', '0x00', 'CMYK8888', 'RGB888') }}
+{{ gen_blit2('blue', '0x00', '0x00', '0xff', 'CMYK8888', 'RGB888') }}
+{{ gen_blit2('gray', '0xef', '0xef', '0xef', 'CMYK8888', 'RGB888') }}
+
+
+%% macro gen_suite_entry(name, from, to)
+ {.name = "Blit {{ from }} to {{ to }}",
+ .tst_fn = blit_{{ name }}_{{ from }}_to_{{ to }}},
+%% endmacro
+
const struct tst_suite tst_suite = {
.suite_name = "Blit Conversions Testsuite",
.tests = {
@@ -130,14 +164,31 @@ const struct tst_suite tst_suite = {
%% if not pt1.is_unknown() and not pt1.is_palette()
%% for pt2 in pixeltypes
%% if not pt2.is_unknown() and not pt2.is_palette()
- {.name = "blit black {{ pt1.name }} to {{ pt2.name }}",
+ {.name = "Blit black {{ pt1.name }} to {{ pt2.name }}",
.tst_fn = blit_black_{{ pt1.name }}_to_{{ pt2.name }}},
- {.name = "blit white {{ pt1.name }} to {{ pt2.name }}",
+ {.name = "Blit white {{ pt1.name }} to {{ pt2.name }}",
.tst_fn = blit_white_{{ pt1.name }}_to_{{ pt2.name }}},
%% endif
%% endfor
%% endif
%% endfor
+%% for pt1 in pixeltypes
+%% if not pt1.is_unknown() and not pt1.is_palette()
+ {.name = "Blit {{ pt1.name }} to {{ pt1.name }}",
+ .tst_fn = blit_equal_pixel_{{ pt1.name }}_to_{{ pt1.name }}},
+%% endif
+%% endfor
+
+{{ gen_suite_entry('red', 'RGB888', 'CMYK8888') }}
+{{ gen_suite_entry('green', 'RGB888', 'CMYK8888') }}
+{{ gen_suite_entry('blue', 'RGB888', 'CMYK8888') }}
+{{ gen_suite_entry('gray', 'RGB888', 'CMYK8888') }}
+
+{{ gen_suite_entry('red', 'CMYK8888', 'RGB888') }}
+{{ gen_suite_entry('green', 'CMYK8888', 'RGB888') }}
+{{ gen_suite_entry('blue', 'CMYK8888', 'RGB888') }}
+{{ gen_suite_entry('gray', 'CMYK8888', 'RGB888') }}
+
{.name = NULL}
}
};
-----------------------------------------------------------------------
Summary of changes:
tests/core/BlitConv.gen.c.t | 87 ++++++++++++++++++++++++++++++++++---------
1 files changed, 69 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
11 May '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 cd239b320e899c30e786fe99ce8b65c44aabf3a1 (commit)
via 29839fd2b1137f294b4819d5da2eb1442997dcfe (commit)
via 74fca49d3a34a21bb5f0ce41af4b13d8b32584d9 (commit)
via 95cc2bf08aeb3596868dfab5a8ac94a5ad859ac9 (commit)
via c91491c8b4fe7b2bad685dcc5143ff4c309dda23 (commit)
from 125caf8cdfeee0056f22bd69a1d4673bc08b386e (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/cd239b320e899c30e786fe99ce8b65c44aab…
commit cd239b320e899c30e786fe99ce8b65c44aabf3a1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 11 15:42:57 2013 +0200
core: Convert: Fix XXX -> XXXA conversion.
The alpha for blits from XXX -> XXXA wasn't filled propery. Was filled
with number of bytes rather than with the maximal value.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t
index 89cbe50..7a7397e 100644
--- a/include/core/GP_Convert.gen.h.t
+++ b/include/core/GP_Convert.gen.h.t
@@ -64,7 +64,7 @@
GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1))); {# case 2: set A to full opacity (not present in source) -#}
%% elif c2[0]=='A'
- /* A:={{ hex(c2[2]) }} */GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2, {{ hex(c2[2]) }}); + /* A:={{ hex(c2[2]) }} */GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2, {{ hex(2 ** c2[2] - 1) }}); {# case 3: calculate V as average of RGB -#}
%% elif c2[0]=='V' and pt1.is_rgb()
/* V:=RGB_avg */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2, (
http://repo.or.cz/w/gfxprim.git/commit/29839fd2b1137f294b4819d5da2eb1442997…
commit 29839fd2b1137f294b4819d5da2eb1442997dcfe
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 11 15:27:34 2013 +0200
tests: core: Cleanup BlitConv.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/BlitConv.gen.c.t b/tests/core/BlitConv.gen.c.t
index 6e95acc..4338beb 100644
--- a/tests/core/BlitConv.gen.c.t
+++ b/tests/core/BlitConv.gen.c.t
@@ -73,11 +73,12 @@ static int check_filled(GP_Context *c, GP_Pixel p)
return 0;
}
-%% for pt1 in pixeltypes
-%% if not pt1.is_unknown() and not pt1.is_palette()
-%% for pt2 in pixeltypes
-%% if not pt2.is_unknown() and not pt2.is_palette()
-static int blit_black_{{ pt1.name }}_to_{{ pt2.name }}(void)
+%% macro blit_color(name, r, g, b)
+%% for pt1 in pixeltypes
+%% if not pt1.is_unknown() and not pt1.is_palette()
+%% for pt2 in pixeltypes
+%% if not pt2.is_unknown() and not pt2.is_palette()
+static int blit_{{ name }}_{{ pt1.name }}_to_{{ pt2.name }}(void)
{
GP_Context *src = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt1.name }});
GP_Context *dst = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt2.name }});
@@ -90,67 +91,37 @@ static int blit_black_{{ pt1.name }}_to_{{ pt2.name }}(void)
}
/* Fill source with black, destination with pseudo random mess */
-%% if pt1.is_alpha()
- GP_Pixel black_src = GP_RGBAToContextPixel(0, 0, 0, 0xff, src);
-%% else
- GP_Pixel black_src = GP_RGBToContextPixel(0, 0, 0, src);
-%% endif
-%% if pt2.is_alpha()
- GP_Pixel black_dst = GP_RGBAToContextPixel(0, 0, 0, 0xff, src);
-%% else
- GP_Pixel black_dst = GP_RGBToContextPixel(0, 0, 0, dst);
-%% endif
-
- fill_context(src, black_src);
+%% if pt1.is_alpha()
+ GP_Pixel pix_src = GP_RGBAToContextPixel({{ r }}, {{ g }}, {{ b }}, 0xff, src);
+%% else
+ GP_Pixel pix_src = GP_RGBToContextPixel({{ r }}, {{ g }}, {{ b }}, src);
+%% endif
+%% if pt2.is_alpha()
+ GP_Pixel pix_dst = GP_RGBAToContextPixel({{ r }}, {{ g }}, {{ b }}, 0xff, dst);
+%% else
+ GP_Pixel pix_dst = GP_RGBToContextPixel({{ r }}, {{ g }}, {{ b }}, dst);
+%% endif
+
+ tst_msg("pixel_src=%08x pixel_dst=%08x", pix_src, pix_dst);
+
+ fill_context(src, pix_src);
mess_context(dst);
GP_Blit(src, 0, 0, src->w, src->h, dst, 0, 0);
- if (check_filled(dst, black_dst))
+ if (check_filled(dst, pix_dst))
return TST_FAILED;
return TST_SUCCESS;
}
-
-static int blit_white_{{ pt1.name }}_to_{{ pt2.name }}(void)
-{
- GP_Context *src = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt1.name }});
- GP_Context *dst = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt2.name }});
-
- if (src == NULL || dst == NULL) {
- GP_ContextFree(src);
- GP_ContextFree(dst);
- tst_msg("Malloc failed :(");
- return TST_UNTESTED;
- }
-
- /* Fill source with white, destination with pseudo random mess */
-%% if pt1.is_alpha()
- GP_Pixel white_src = GP_RGBAToContextPixel(0xff, 0xff, 0xff, 0xff, src);
-%% else
- GP_Pixel white_src = GP_RGBToContextPixel(0xff, 0xff, 0xff, src);
%% endif
-%% if pt2.is_alpha()
- GP_Pixel white_dst = GP_RGBAToContextPixel(0xff, 0xff, 0xff, 0xff, src);
-%% else
- GP_Pixel white_dst = GP_RGBToContextPixel(0xff, 0xff, 0xff, dst);
-%% endif
-
- fill_context(src, white_src);
- mess_context(dst);
-
- GP_Blit(src, 0, 0, src->w, src->h, dst, 0, 0);
-
- if (check_filled(dst, white_dst))
- return TST_FAILED;
-
- return TST_SUCCESS;
-}
+%% endfor
+%% endif
+%% endfor
+%% endmacro
-%% endif
-%% endfor
-%% endif
-%% endfor
+{{ blit_color('black', '0x00', '0x00', '0x00') }}
+{{ blit_color('white', '0xff', '0xff', '0xff') }}
const struct tst_suite tst_suite = {
.suite_name = "Blit Conversions Testsuite",
http://repo.or.cz/w/gfxprim.git/commit/74fca49d3a34a21bb5f0ce41af4b13d8b325…
commit 74fca49d3a34a21bb5f0ce41af4b13d8b32584d9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 11 15:26:59 2013 +0200
core: Convert: Add experimental RGB -> CMYK.
BEWARE UNTESTED.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t
index 2f59fc3..89cbe50 100644
--- a/include/core/GP_Convert.gen.h.t
+++ b/include/core/GP_Convert.gen.h.t
@@ -25,12 +25,37 @@
{% block descr %}Convert PixelType values macros and functions{% endblock %}
+{# RGB -> CMYK requires special handling #}
+%% macro rgb_to_cmyk(in, out)
+%% set R = in.chans['R']
+%% set G = in.chans['G']
+%% set B = in.chans['B']
+%% set C = out.chans['C']
+%% set M = out.chans['M']
+%% set Y = out.chans['Y']
+%% set K = out.chans['K']
+%% set max_bits = max(R[2], G[2], B[2])
+%% set max_val = 2 ** max_bits - 1
+ GP_Pixel _R = GP_SCALE_VAL_{{ R[2] }}_{{ max_bits }}(GP_GET_BITS({{ R[1] }}+o1, {{ R[2] }}, p1)); + GP_Pixel _G = GP_SCALE_VAL_{{ G[2] }}_{{ max_bits }}(GP_GET_BITS({{ G[1] }}+o1, {{ G[2] }}, p1)); + GP_Pixel _B = GP_SCALE_VAL_{{ B[2] }}_{{ max_bits }}(GP_GET_BITS({{ B[1] }}+o1, {{ B[2] }}, p1)); + GP_Pixel _K = GP_MAX3(_R, _G, _B); + GP_SET_BITS({{ C[1] }}+o2, {{ C[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ C[2] }}((_K - _R))); + GP_SET_BITS({{ M[1] }}+o2, {{ M[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ M[2] }}((_K - _G))); + GP_SET_BITS({{ Y[1] }}+o2, {{ Y[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ Y[2] }}((_K - _B))); + GP_SET_BITS({{ K[1] }}+o2, {{ K[2] }}, p2, GP_SCALE_VAL_{{ max_bits }}_{{ K[2] }}({{ max_val }} - _K)); +%% endmacro
+
%% macro GP_Pixel_TYPE_TO_TYPE(pt1, pt2)
/*** {{ pt1.name }} -> {{ pt2.name }} ***
* macro reads p1 ({{ pt1.name }} at bit-offset o1)
* and writes to p2 ({{ pt2.name }} at bit-offset o2)
* the relevant part of p2 is assumed to be cleared (zero) */
#define GP_Pixel_{{ pt1.name }}_TO_{{ pt2.name }}_OFFSET(p1, o1, p2, o2) do { +{# special cases -#}
+%% if pt1.is_rgb() and pt2.is_cmyk()
+{{ rgb_to_cmyk(pt1, pt2) -}}
+%% else
%% for c2 in pt2.chanslist
{# case 1: just copy a channel -#}
%% if c2[0] in pt1.chans.keys()
@@ -67,14 +92,12 @@
GP_SCALE_VAL_{{ K[2] + V[2] }}_{{ c2[2] }}( (({{ 2 ** K[2] - 1 }} - GP_GET_BITS({{ K[1] }}+o1, {{ K[2] }}, p1)) * ({{ 2 ** V[2] - 1 }} - GP_GET_BITS({{ V[1] }}+o1, {{ V[2] }}, p1))))); -{# case 6: RGB to CMYK -#}
-%% elif c2[0] in 'CMYK' and pt1.is_rgb()
- /* TODO */ {# case 7: invalid mapping -#}
%% else
{{ error('Channel conversion ' + pt1.name + ' to ' + pt2.name + ' not supported.') }}
%% endif
%% endfor
+%% endif
} while (0)
/* a version without offsets */
http://repo.or.cz/w/gfxprim.git/commit/95cc2bf08aeb3596868dfab5a8ac94a5ad85…
commit 95cc2bf08aeb3596868dfab5a8ac94a5ad859ac9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 11 15:26:14 2013 +0200
codegen: Propagate min, max to templating engine.
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 b4ca701..be9b32d 100644
--- a/pylib/gp_codegen/render_utils.py
+++ b/pylib/gp_codegen/render_utils.py
@@ -36,6 +36,8 @@ def create_environment(config, template_dir):
env.globals['int'] = int;
env.globals['float'] = float;
env.globals['round'] = round;
+ env.globals['min'] = min;
+ env.globals['max'] = max;
return env
http://repo.or.cz/w/gfxprim.git/commit/c91491c8b4fe7b2bad685dcc5143ff4c309d…
commit c91491c8b4fe7b2bad685dcc5143ff4c309dda23
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 11 15:25:18 2013 +0200
core: Common: Add MAX3(a, b, c) macro.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h
index 5a779c0..17d61b8 100644
--- a/include/core/GP_Common.h
+++ b/include/core/GP_Common.h
@@ -52,6 +52,16 @@
})
/*
+ * Returns maximum from three numbers.
+ */
+#define GP_MAX3(a, b, c) ({ + typeof(a) _a = (a); + typeof(b) _b = (b); + typeof(c) _c = (c); + _a > _b ? (_a > _c ? _a : _c) : (_b > _c ? _b : _c); +})
+
+/*
* Returns absolute value.
*/
#define GP_ABS(a) ({
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Common.h | 10 +++++
include/core/GP_Convert.gen.h.t | 31 ++++++++++++--
pylib/gp_codegen/render_utils.py | 2 +
tests/core/BlitConv.gen.c.t | 83 ++++++++++++-------------------------
4 files changed, 66 insertions(+), 60 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
11 May '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 125caf8cdfeee0056f22bd69a1d4673bc08b386e (commit)
from 69fe54806e58e8f78860761e97b90d592199b665 (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/125caf8cdfeee0056f22bd69a1d4673bc08b…
commit 125caf8cdfeee0056f22bd69a1d4673bc08b386e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 11 00:31:02 2013 +0200
test: core: Add Blit Conversions tests.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/BlitConv.gen.c.t b/tests/core/BlitConv.gen.c.t
new file mode 100644
index 0000000..6e95acc
--- /dev/null
+++ b/tests/core/BlitConv.gen.c.t
@@ -0,0 +1,174 @@
+/*****************************************************************************
+ * 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 body
+
+#include <stdio.h>
+
+#include <core/GP_Context.h>
+#include <core/GP_Convert.h>
+#include <core/GP_GetPutPixel.h>
+#include <core/GP_Blit.h>
+
+#include "tst_test.h"
+
+static void fill_context(GP_Context *c, GP_Pixel p)
+{
+ GP_Coord x, y;
+
+ for (x = 0; x < (GP_Coord)c->w; x++)
+ for (y = 0; y < (GP_Coord)c->h; y++)
+ GP_PutPixel(c, x, y, p);
+}
+
+static void mess_context(GP_Context *c)
+{
+ GP_Coord y;
+ unsigned int i;
+
+ for (y = 0; y < (GP_Coord)c->h; y++) {
+ uint8_t *row = GP_PIXEL_ADDR(c, 0, y);
+ for (i = 0; i < c->bytes_per_row; i++) {
+ row[i] = y ^ i;
+ }
+ }
+}
+
+static int check_filled(GP_Context *c, GP_Pixel p)
+{
+ GP_Coord x, y;
+ GP_Pixel pc;
+
+ for (x = 0; x < (GP_Coord)c->w; x++) {
+ for (y = 0; y < (GP_Coord)c->h; y++) {
+ pc = GP_GetPixel(c, x, y);
+ if (p != pc) {
+ tst_msg("Pixels different %08x %08x", p, pc);
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+%% for pt1 in pixeltypes
+%% if not pt1.is_unknown() and not pt1.is_palette()
+%% for pt2 in pixeltypes
+%% if not pt2.is_unknown() and not pt2.is_palette()
+static int blit_black_{{ pt1.name }}_to_{{ pt2.name }}(void)
+{
+ GP_Context *src = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt1.name }});
+ GP_Context *dst = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt2.name }});
+
+ if (src == NULL || dst == NULL) {
+ GP_ContextFree(src);
+ GP_ContextFree(dst);
+ tst_msg("Malloc failed :(");
+ return TST_UNTESTED;
+ }
+
+ /* Fill source with black, destination with pseudo random mess */
+%% if pt1.is_alpha()
+ GP_Pixel black_src = GP_RGBAToContextPixel(0, 0, 0, 0xff, src);
+%% else
+ GP_Pixel black_src = GP_RGBToContextPixel(0, 0, 0, src);
+%% endif
+%% if pt2.is_alpha()
+ GP_Pixel black_dst = GP_RGBAToContextPixel(0, 0, 0, 0xff, src);
+%% else
+ GP_Pixel black_dst = GP_RGBToContextPixel(0, 0, 0, dst);
+%% endif
+
+ fill_context(src, black_src);
+ mess_context(dst);
+
+ GP_Blit(src, 0, 0, src->w, src->h, dst, 0, 0);
+
+ if (check_filled(dst, black_dst))
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+static int blit_white_{{ pt1.name }}_to_{{ pt2.name }}(void)
+{
+ GP_Context *src = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt1.name }});
+ GP_Context *dst = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt2.name }});
+
+ if (src == NULL || dst == NULL) {
+ GP_ContextFree(src);
+ GP_ContextFree(dst);
+ tst_msg("Malloc failed :(");
+ return TST_UNTESTED;
+ }
+
+ /* Fill source with white, destination with pseudo random mess */
+%% if pt1.is_alpha()
+ GP_Pixel white_src = GP_RGBAToContextPixel(0xff, 0xff, 0xff, 0xff, src);
+%% else
+ GP_Pixel white_src = GP_RGBToContextPixel(0xff, 0xff, 0xff, src);
+%% endif
+%% if pt2.is_alpha()
+ GP_Pixel white_dst = GP_RGBAToContextPixel(0xff, 0xff, 0xff, 0xff, src);
+%% else
+ GP_Pixel white_dst = GP_RGBToContextPixel(0xff, 0xff, 0xff, dst);
+%% endif
+
+ fill_context(src, white_src);
+ mess_context(dst);
+
+ GP_Blit(src, 0, 0, src->w, src->h, dst, 0, 0);
+
+ if (check_filled(dst, white_dst))
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+%% endif
+%% endfor
+%% endif
+%% endfor
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Blit Conversions Testsuite",
+ .tests = {
+%% for pt1 in pixeltypes
+%% if not pt1.is_unknown() and not pt1.is_palette()
+%% for pt2 in pixeltypes
+%% if not pt2.is_unknown() and not pt2.is_palette()
+ {.name = "blit black {{ pt1.name }} to {{ pt2.name }}",
+ .tst_fn = blit_black_{{ pt1.name }}_to_{{ pt2.name }}},
+ {.name = "blit white {{ pt1.name }} to {{ pt2.name }}",
+ .tst_fn = blit_white_{{ pt1.name }}_to_{{ pt2.name }}},
+%% endif
+%% endfor
+%% endif
+%% endfor
+ {.name = NULL}
+ }
+};
+
+%% endblock body
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 8aa4196..2fb3c86 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -4,9 +4,9 @@ include $(TOPDIR)/pre.mk
CSOURCES=Context.c Pixel.c
-GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c
+GENSOURCES+=WritePixel.gen.c GetPutPixel.gen.c BlitConv.gen.c
-APPS=WritePixel.gen Pixel Context GetPutPixel.gen
+APPS=WritePixel.gen Pixel Context GetPutPixel.gen BlitConv.gen
include ../tests.mk
diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt
index 89cbedd..432bef9 100644
--- a/tests/core/test_list.txt
+++ b/tests/core/test_list.txt
@@ -3,3 +3,4 @@ WritePixel.gen
Context
Pixel
GetPutPixel.gen
+BlitConv.gen
-----------------------------------------------------------------------
Summary of changes:
tests/core/BlitConv.gen.c.t | 174 +++++++++++++++++++++++++++++++++++++++++++
tests/core/Makefile | 4 +-
tests/core/test_list.txt | 1 +
3 files changed, 177 insertions(+), 2 deletions(-)
create mode 100644 tests/core/BlitConv.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
10 May '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 69fe54806e58e8f78860761e97b90d592199b665 (commit)
via f19066b7575762295fe077dd20cbd149a330578d (commit)
via 390152eb9ac9b007ca33ab4309e44ab628d04c6a (commit)
via e0f1329f8cc9daf32cd26e3cdc80d6fee0feede5 (commit)
from fafd7bf50d69b47a22775fcbb166d9c3d48c565f (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/69fe54806e58e8f78860761e97b90d592199…
commit 69fe54806e58e8f78860761e97b90d592199b665
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 15:22:05 2013 +0200
loaders: JPG: Add support for loading CMYK images.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index 0e04ce6..11c34d1 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -140,6 +140,9 @@ GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback)
case JCS_RGB:
pixel_type = GP_PIXEL_RGB888;
break;
+ case JCS_CMYK:
+ pixel_type = GP_PIXEL_CMYK8888;
+ break;
default:
pixel_type = GP_PIXEL_UNKNOWN;
}
@@ -168,22 +171,35 @@ GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback)
JSAMPROW addr = (void*)GP_PIXEL_ADDR(ret, 0, y);
jpeg_read_scanlines(&cinfo, &addr, 1);
- if (pixel_type != GP_PIXEL_RGB888)
- continue;
+ if (pixel_type == GP_PIXEL_RGB888) {
+ //TODO: fixme bigendian?
+ /* fix the pixel, as we want in fact BGR */
+ unsigned int i;
- //TODO: fixme bigendian?
- /* fix the pixel, as we want in fact BGR */
- uint32_t i;
-
- for (i = 0; i < ret->w; i++) {
- uint8_t *pix = GP_PIXEL_ADDR(ret, i, y);
- GP_SWAP(pix[0], pix[2]);
- }
+ for (i = 0; i < ret->w; i++) {
+ uint8_t *pix = GP_PIXEL_ADDR(ret, i, y);
+ GP_SWAP(pix[0], pix[2]);
+ }
- if (GP_ProgressCallbackReport(callback, y, ret->h, ret->w)) {
- GP_DEBUG(1, "Operation aborted");
- err = ECANCELED;
- goto err2;
+ if (GP_ProgressCallbackReport(callback, y, ret->h, ret->w)) {
+ GP_DEBUG(1, "Operation aborted");
+ err = ECANCELED;
+ goto err2;
+ }
+ }
+
+ if (pixel_type == GP_PIXEL_CMYK8888) {
+ unsigned int i;
+ uint8_t *buf = GP_PIXEL_ADDR(ret, 0, y);
+
+ for (i = 0; i < ret->w; i++) {
+ unsigned int j = 4 * i;
+
+ buf[j] = 0xff - buf[j];
+ buf[j+1] = 0xff - buf[j+1];
+ buf[j+2] = 0xff - buf[j+2];
+ buf[j+3] = 0xff - buf[j+3];
+ }
}
}
http://repo.or.cz/w/gfxprim.git/commit/f19066b7575762295fe077dd20cbd149a330…
commit f19066b7575762295fe077dd20cbd149a330578d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 15:16:51 2013 +0200
core: Add initial support for CMYK8888.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/gen.txt b/doc/gen.txt
index cac6b9d..3f3c0d8 100644
--- a/doc/gen.txt
+++ b/doc/gen.txt
@@ -181,6 +181,9 @@ class PixelType(object):
def is_rgb(self):
...
+ def is_cmyk(self):
+ ...
+
def is_gray(self):
...
diff --git a/gfxprim_config.py b/gfxprim_config.py
index 1af12c9..dad4bbe 100644
--- a/gfxprim_config.py
+++ b/gfxprim_config.py
@@ -4,8 +4,8 @@
#
#
-# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
-# 2011 - Cyril Hrubis <metan(a)ucw.cz>
+# 2011 Tomas Gavenciak <gavento(a)ucw.cz>
+# 2011-2013 Cyril Hrubis <metan(a)ucw.cz>
#
# This file is sourced by all the generating scripts.
# Moreover, the generated files are sourced by almost all Gfxprim sources,
@@ -75,7 +75,16 @@ config = GfxPrimConfig(
('R', 12, 6),
('G', 6, 6),
('B', 0, 6)]),
-
+
+ #
+ # CMYK
+ #
+ PixelType(name="CMYK8888", pixelsize=PS_32BPP, chanslist=[
+ ('K', 24, 8),
+ ('Y', 16, 8),
+ ('M', 8, 8),
+ ('C', 0, 8)]),
+
#
# Palette types
#
diff --git a/include/core/GP_Convert.gen.h.t b/include/core/GP_Convert.gen.h.t
index 7dc25a9..2f59fc3 100644
--- a/include/core/GP_Convert.gen.h.t
+++ b/include/core/GP_Convert.gen.h.t
@@ -52,7 +52,25 @@
%% set c1 = pt1.chans['V']
/* {{ c2[0] }}:=V */ GP_SET_BITS({{c2[1]}}+o2, {{c2[2]}}, p2, GP_SCALE_VAL_{{c1[2]}}_{{c2[2]}}(GP_GET_BITS({{c1[1]}}+o1, {{c1[2]}}, p1))); -{# case 5: invalid mapping -#}
+{# case 5: CMYK to RGB -#}
+%% elif c2[0] in 'RGB' and pt1.is_cmyk()
+%% set K = pt1.chans['K']
+{# Get the right channel -#}
+%% if c2[0] == 'R'
+%% set V = pt1.chans['C']
+%% elif c2[0] == 'G'
+%% set V = pt1.chans['M']
+%% else
+%% set V = pt1.chans['Y']
+%% endif
+ GP_SET_BITS({{ c2[1] }}+o2, {{ c2[2] }}, p2,+ GP_SCALE_VAL_{{ K[2] + V[2] }}_{{ c2[2] }}(+ (({{ 2 ** K[2] - 1 }} - GP_GET_BITS({{ K[1] }}+o1, {{ K[2] }}, p1)) * + ({{ 2 ** V[2] - 1 }} - GP_GET_BITS({{ V[1] }}+o1, {{ V[2] }}, p1))))); +{# case 6: RGB to CMYK -#}
+%% elif c2[0] in 'CMYK' and pt1.is_rgb()
+ /* TODO */ +{# case 7: invalid mapping -#}
%% else
{{ error('Channel conversion ' + pt1.name + ' to ' + pt2.name + ' not supported.') }}
%% endif
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index ff2d710..4a0806e 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -97,6 +97,7 @@ typedef enum GP_PixelFlags {
GP_PIXEL_HAS_ALPHA = 0x01,
GP_PIXEL_IS_RGB = 0x02,
GP_PIXEL_IS_PALETTE = 0x04,
+ GP_PIXEL_IS_CMYK = 0x08,
GP_PIXEL_IS_GRAYSCALE = 0x10,
} GP_PixelFlags;
diff --git a/libs/core/GP_Pixel.gen.c.t b/libs/core/GP_Pixel.gen.c.t
index 7fad071..0511120 100644
--- a/libs/core/GP_Pixel.gen.c.t
+++ b/libs/core/GP_Pixel.gen.c.t
@@ -37,6 +37,7 @@ Pixel type definitions and functions
{% if pt.is_rgb() %} | GP_PIXEL_IS_RGB{% endif -%}
{% if pt.is_palette() %} | GP_PIXEL_IS_PALETTE{% endif -%}
{% if pt.is_gray() %} | GP_PIXEL_IS_GRAYSCALE{% endif -%}
+{% if pt.is_cmyk() %} | GP_PIXEL_IS_CMYK{% endif -%}
%%- endmacro
/*
diff --git a/pylib/gp_codegen/pixeltype.py b/pylib/gp_codegen/pixeltype.py
index 08e08fe..eaac404 100644
--- a/pylib/gp_codegen/pixeltype.py
+++ b/pylib/gp_codegen/pixeltype.py
@@ -58,6 +58,11 @@ class PixelType(object):
def is_gray(self):
return ('V' in self.chans)
+
+ def is_cmyk(self):
+ for i in 'CMYK':
+ if i not in self.chans: return False
+ return True
def is_alpha(self):
return ('A' in self.chans)
http://repo.or.cz/w/gfxprim.git/commit/390152eb9ac9b007ca33ab4309e44ab628d0…
commit 390152eb9ac9b007ca33ab4309e44ab628d04c6a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 13:47:39 2013 +0200
filters; Ditherings: Make list of output fmts explicit.
Make the list of output formats explicit so that the code doesn't break
when new pixel that is not RGB nor Gray is added.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_FloydSteinberg.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t
index e10a326..fde40d9 100644
--- a/libs/filters/GP_FloydSteinberg.gen.c.t
+++ b/libs/filters/GP_FloydSteinberg.gen.c.t
@@ -46,7 +46,7 @@
%% endmacro
%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_alpha() and not pt.is_palette()
+%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
/*
* Floyd Steinberg RGB888 to {{ pt.name }}
*/
@@ -127,7 +127,7 @@ int GP_FilterFloydSteinberg_RGB888_Raw(const GP_Context *src,
{
switch (dst->pixel_type) {
%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_alpha() and not pt.is_palette()
+%% 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
diff --git a/libs/filters/GP_HilbertPeano.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t
index 37a79d7..9c84bee 100644
--- a/libs/filters/GP_HilbertPeano.gen.c.t
+++ b/libs/filters/GP_HilbertPeano.gen.c.t
@@ -49,7 +49,7 @@ static unsigned int count_bits(unsigned int n)
}
%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_alpha() and not pt.is_palette()
+%% if pt.is_gray() or pt.is_rgb() and not pt.is_alpha()
/*
* Hilbert Peano RGB888 to {{ pt.name }}
*/
@@ -137,7 +137,7 @@ int GP_FilterHilbertPeano_RGB888_Raw(const GP_Context *src,
{
switch (dst->pixel_type) {
%% for pt in pixeltypes
-%% if not pt.is_unknown() and not pt.is_alpha() and not pt.is_palette()
+%% 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
http://repo.or.cz/w/gfxprim.git/commit/e0f1329f8cc9daf32cd26e3cdc80d6fee0fe…
commit e0f1329f8cc9daf32cd26e3cdc80d6fee0feede5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 13:15:15 2013 +0200
configure: Use Popen instead of check_output
Fixes configure with Python 2.6
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/configure b/configure
index df8a74f..36450a1 100755
--- a/configure
+++ b/configure
@@ -5,7 +5,7 @@
import os
import sys
from optparse import OptionParser
-from subprocess import check_output
+import subprocess
def header_exists(cfg, filename):
fpath = cfg['include_path'][0] + '/' + filename
@@ -45,7 +45,9 @@ def python_version(cfg):
sys.stderr.write('NAn')
return ''
- res = str(check_output("%s --ldflags" % cfg['PYTHON_CONFIG'][0], shell=True))
+ cmd = subprocess.Popen([cfg['PYTHON_CONFIG'][0], '--ldflags'],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ res = str(cmd.communicate())
res = res[res.find('-lpython')+8:]
res = res[:3]
-----------------------------------------------------------------------
Summary of changes:
configure | 6 +++-
doc/gen.txt | 3 ++
gfxprim_config.py | 15 ++++++++--
include/core/GP_Convert.gen.h.t | 20 +++++++++++++-
include/core/GP_Pixel.h | 1 +
libs/core/GP_Pixel.gen.c.t | 1 +
libs/filters/GP_FloydSteinberg.gen.c.t | 4 +-
libs/filters/GP_HilbertPeano.gen.c.t | 4 +-
libs/loaders/GP_JPG.c | 44 +++++++++++++++++++++----------
pylib/gp_codegen/pixeltype.py | 5 +++
10 files changed, 79 insertions(+), 24 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
10 May '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 fafd7bf50d69b47a22775fcbb166d9c3d48c565f (commit)
via 26a5965f520f882cd33c837e582ac545058efbec (commit)
via f8e9023cc4fa863d5a373c86c1f998ae7185d119 (commit)
via b0c52fdb07844102bc97b887672b2bf9ff4d1d1f (commit)
via a8071e4ec58be0465c9235ee50e0bf8f136aa5c9 (commit)
via 92a84bb8701fb5d421bac2b277debdb8056d68e4 (commit)
via 3b46f61b9b1698b2711c93e746464db13a486e62 (commit)
from c7c32efcf6deac514ea58f8adef8185afc0a3788 (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/fafd7bf50d69b47a22775fcbb166d9c3d48c…
commit fafd7bf50d69b47a22775fcbb166d9c3d48c565f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 13:02:36 2013 +0200
gfx: Remove unused Line.algo.h, fix copyrights.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/gfx/GP_Line.gen.c.t b/libs/gfx/GP_Line.gen.c.t
index 668d89f..a2dbd9d 100644
--- a/libs/gfx/GP_Line.gen.c.t
+++ b/libs/gfx/GP_Line.gen.c.t
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2012 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
diff --git a/libs/gfx/algo/Line.algo.h b/libs/gfx/algo/Line.algo.h
deleted file mode 100644
index 952598c..0000000
--- a/libs/gfx/algo/Line.algo.h
+++ /dev/null
@@ -1,81 +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-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-/*
- * The classical Bresenham line drawing algorithm.
- * Please see http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
- * for a nice and understandable description.
- */
-
-/*
- * This macro defines a line drawing function.
- * Arguments:
- * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL)
- * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL)
- * PUTPIXEL - a pixel drawing function f(context, x, y, pixval)
- * FN_NAME - name of the function to be defined
- */
-#define DEF_LINE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) -void FN_NAME(CONTEXT_T context, int x0, int y0, int x1, int y1, - PIXVAL_T pixval) -{ - if (x0 == x1) { - if (y0 > y1) - GP_SWAP(y0, y1); - int y; - for (y = y0; y <= y1; y++) - PUTPIXEL(context, x0, y, pixval); - return; - } -- int steep = abs(y1 - y0) / abs(x1 - x0); - if (steep) { - GP_SWAP(x0, y0); - GP_SWAP(x1, y1); - } - if (x0 > x1) { - GP_SWAP(x0, x1); - GP_SWAP(y0, y1); - } -- int deltax = x1 - x0; - int deltay = abs(y1 - y0); - int error = deltax / 2; - int y = y0, x; - int ystep = (y0 < y1) ? 1 : -1; - for (x = x0; x <= x1; x++) { -- if (steep) - PUTPIXEL(context, y, x, pixval); - else - PUTPIXEL(context, x, y, pixval); -- error = error - deltay; - if (error < 0) { - y = y + ystep; - error = error + deltax; - } - } -}
http://repo.or.cz/w/gfxprim.git/commit/26a5965f520f882cd33c837e582ac545058e…
commit 26a5965f520f882cd33c837e582ac545058efbec
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 13:00:05 2013 +0200
gfx: Remove commented out FillCircle from Circle.c
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c
index d8973e4..a19e98f 100644
--- a/libs/gfx/GP_Circle.c
+++ b/libs/gfx/GP_Circle.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2011 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> *
* *
*****************************************************************************/
@@ -53,11 +53,6 @@ void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Circle_Raw(context, xcenter, ycenter, r, pixel);
}
-/* #include "algo/FillCircle.algo.h" */
-
-/* Generate drawing functions for various bit depths. */
-//GP_DEF_FILL_FN_PER_BPP(GP_FillCircle_Raw, DEF_FILLCIRCLE_FN)
-
void GP_Ring_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r1, GP_Size r2, GP_Pixel pixel)
{
http://repo.or.cz/w/gfxprim.git/commit/f8e9023cc4fa863d5a373c86c1f998ae7185…
commit f8e9023cc4fa863d5a373c86c1f998ae7185d119
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 12:56:37 2013 +0200
tests: PNG: Add testcase for Adam7 interlacing.
* Add test for Adam7 interlacing
* Edhance a few testcases to check context
data pixel values.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/loaders/PNG.c b/tests/loaders/PNG.c
index d4901ca..540e492 100644
--- a/tests/loaders/PNG.c
+++ b/tests/loaders/PNG.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> *
* *
*****************************************************************************/
@@ -25,6 +25,7 @@
#include <sys/stat.h>
#include <core/GP_Context.h>
+#include <core/GP_GetPutPixel.h>
#include <loaders/GP_Loaders.h>
#include "tst_test.h"
@@ -57,6 +58,71 @@ static int test_load_PNG(const char *path)
return TST_SUCCESS;
}
+struct check_color_test {
+ const char *path;
+ GP_Pixel pixel;
+};
+
+static int test_load_PNG_check_color(struct check_color_test *test)
+{
+ GP_Context *img;
+
+ errno = 0;
+
+ img = GP_LoadPNG(test->path, NULL);
+
+ if (img == NULL) {
+ switch (errno) {
+ case ENOSYS:
+ tst_msg("Not Implemented");
+ return TST_SKIPPED;
+ default:
+ tst_msg("Got %s", strerror(errno));
+ return TST_FAILED;
+ }
+ }
+
+ unsigned int x, y, fail = 0;
+
+ for (x = 0; x < img->w; x++) {
+ for (y = 0; y < img->w; y++) {
+ GP_Pixel p = GP_GetPixel(img, x, y);
+
+ if (p != test->pixel) {
+ if (!fail)
+ tst_msg("First failed at %u,%u %x %x",
+ x, y, p, test->pixel);
+ fail = 1;
+ }
+ }
+ }
+
+ if (!fail)
+ tst_msg("Context pixels are correct");
+
+ GP_ContextFree(img);
+
+ if (fail)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+static struct check_color_test white_adam7 = {
+ .path = "100x100-white-adam7.png",
+ .pixel = 0xffffff,
+};
+
+static struct check_color_test black_grayscale = {
+ .path = "100x100-black-grayscale.png",
+ .pixel = 0x000000,
+};
+
+static struct check_color_test red = {
+ .path = "100x100-red.png",
+ .pixel = 0xff0000,
+};
+
static int test_save_PNG(GP_PixelType pixel_type)
{
GP_Context *ctx;
@@ -96,9 +162,9 @@ const struct tst_suite tst_suite = {
.tests = {
/* PNG loader tests */
{.name = "PNG Load 100x100 RGB",
- .tst_fn = test_load_PNG,
+ .tst_fn = test_load_PNG_check_color,
.res_path = "data/png/valid/100x100-red.png",
- .data = "100x100-red.png",
+ .data = &red,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PNG Load 100x100 RGB 50% alpha",
@@ -108,9 +174,9 @@ const struct tst_suite tst_suite = {
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PNG Load 100x100 8 bit Grayscale",
- .tst_fn = test_load_PNG,
+ .tst_fn = test_load_PNG_check_color,
.res_path = "data/png/valid/100x100-black-grayscale.png",
- .data = "100x100-black-grayscale.png",
+ .data = &black_grayscale,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PNG Load 100x100 8 bit Grayscale + alpha",
@@ -131,6 +197,12 @@ const struct tst_suite tst_suite = {
.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,
diff --git a/tests/loaders/data/png/valid/100x100-white-adam7.png b/tests/loaders/data/png/valid/100x100-white-adam7.png
new file mode 100644
index 0000000..c08b015
Binary files /dev/null and b/tests/loaders/data/png/valid/100x100-white-adam7.png differ
http://repo.or.cz/w/gfxprim.git/commit/b0c52fdb07844102bc97b887672b2bf9ff4d…
commit b0c52fdb07844102bc97b887672b2bf9ff4d1d1f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 12:23:01 2013 +0200
tests: gfx: Fix Line testsuite.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/gfx/Line.c b/tests/gfx/Line.c
index 5314a90..5fcc4a3 100644
--- a/tests/gfx/Line.c
+++ b/tests/gfx/Line.c
@@ -163,10 +163,10 @@ static struct testcase testcase_line_15 = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}
};
http://repo.or.cz/w/gfxprim.git/commit/a8071e4ec58be0465c9235ee50e0bf8f136a…
commit a8071e4ec58be0465c9235ee50e0bf8f136aa5c9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 12:18:16 2013 +0200
gfx: Move FillEllipse to template, fix special case.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/gfx/GP_Ellipse.c b/libs/gfx/GP_Ellipse.c
index a41ca5f..bd7d31b 100644
--- a/libs/gfx/GP_Ellipse.c
+++ b/libs/gfx/GP_Ellipse.c
@@ -54,28 +54,3 @@ void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Ellipse_Raw(context, xcenter, ycenter, a, b, pixel);
}
-
-#include "algo/FillEllipse.algo.h"
-
-/* Generate drawing functions for various bit depths. */
-GP_DEF_FILL_FN_PER_BPP(GP_FillEllipse_Raw, DEF_FILLELLIPSE_FN)
-
-void GP_FillEllipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_FN_PER_BPP_CONTEXT(GP_FillEllipse_Raw, context, context,
- xcenter, ycenter, a, b, pixel);
-}
-
-void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_TRANSFORM_POINT(context, xcenter, ycenter);
- GP_TRANSFORM_SWAP(context, a, b);
-
- GP_FillEllipse_Raw(context, xcenter, ycenter, a, b, pixel);
-}
diff --git a/libs/gfx/algo/FillEllipse.algo.h b/libs/gfx/GP_FillEllipse.gen.c.t
similarity index 56%
rename from libs/gfx/algo/FillEllipse.algo.h
rename to libs/gfx/GP_FillEllipse.gen.c.t
index 76da4bd..aed7d1f 100644
--- a/libs/gfx/algo/FillEllipse.algo.h
+++ b/libs/gfx/GP_FillEllipse.gen.c.t
@@ -19,10 +19,22 @@
* 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> *
* *
*****************************************************************************/
+%% extends "base.c.t"
+
+{% block descr %}A filled ellipse drawing algorithm.{% endblock %}
+
+%% block body
+
+#include "core/GP_GetPutPixel.h"
+#include "core/GP_FnPerBpp.h"
+#include "gfx/GP_HLine.h"
+#include "gfx/GP_VLine.h"
+#include "gfx/GP_Ellipse.h"
+
/*
* A filled ellipse drawing algorithm.
*
@@ -32,32 +44,55 @@
* we just iterate X until Y reaches next line, and then draw the full line.
*/
-/*
- * This macro defines a filled ellipse drawing function.
- * Arguments:
- * CONTEXT_T - user-defined type of drawing context (passed to HLINE)
- * PIXVAL_T - user-defined pixel value type (passed to HLINE)
- * HLINE - horizontal line drawing function f(context, x0, x1, y, pixval)
- * FN_NAME - name of the function to be defined
- */
-#define DEF_FILLELLIPSE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, HLINE) -static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, - unsigned int a, unsigned int b, PIXVAL_T pixval) -{ - /* Precompute quadratic terms. */ - int a2 = a*a; - int b2 = b*b; -- int x, y, error; - for (x = 0, error = -b2*a, y = b; y >= 0; y--) { - while (error < 0) { - error += b2 * (2*x + 1); - x++; - } - error += a2 * (-2*y + 1); -- /* Draw two horizontal lines reflected across Y. */ - HLINE(context, xcenter-x+1, xcenter+x-1, ycenter-y, pixval); - HLINE(context, xcenter-x+1, xcenter+x-1, ycenter+y, pixval); - } +%% for ps in pixelsizes
+
+static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord xcenter,
+ GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel)
+{
+ /* Precompute quadratic terms. */
+ int a2 = a*a;
+ int b2 = b*b;
+
+ /* Handle special case */
+ if (a == 0) {
+ GP_VLine_Raw_{{ ps.suffix }}(context, xcenter, ycenter - b, ycenter + b, pixel);
+ return;
+ }
+
+ int x, y, error;
+ for (x = 0, error = -b2*a, y = b; y >= 0; y--) {
+ while (error < 0) {
+ error += b2 * (2*x + 1);
+ x++;
+ }
+ error += a2 * (-2*y + 1);
+
+ /* Draw two horizontal lines reflected across Y. */
+ GP_HLine_Raw_{{ ps.suffix }}(context, xcenter-x+1, xcenter+x-1, ycenter-y, pixel);
+ GP_HLine_Raw_{{ ps.suffix }}(context, xcenter-x+1, xcenter+x-1, ycenter+y, pixel);
+ }
}
+
+%% endfor
+
+void GP_FillEllipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size a, GP_Size b, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP_CONTEXT(GP_FillEllipse_Raw, context, context,
+ xcenter, ycenter, a, b, pixel);
+}
+
+void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size a, GP_Size b, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_TRANSFORM_POINT(context, xcenter, ycenter);
+ GP_TRANSFORM_SWAP(context, a, b);
+
+ GP_FillEllipse_Raw(context, xcenter, ycenter, a, b, pixel);
+}
+
+%% endblock body
diff --git a/libs/gfx/Makefile b/libs/gfx/Makefile
index 4511495..8ffe38a 100644
--- a/libs/gfx/Makefile
+++ b/libs/gfx/Makefile
@@ -3,7 +3,8 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
GENSOURCES=GP_Line.gen.c GP_HLine.gen.c GP_LineAA.gen.c GP_PutPixelAA.gen.c - GP_HLineAA.gen.c GP_VLineAA.gen.c GP_FillCircle.gen.c GP_VLine.gen.c
+ GP_HLineAA.gen.c GP_VLineAA.gen.c GP_FillCircle.gen.c GP_VLine.gen.c + GP_FillEllipse.gen.c
LIBNAME=gfx
include $(TOPDIR)/gen.mk
http://repo.or.cz/w/gfxprim.git/commit/92a84bb8701fb5d421bac2b277debdb8056d…
commit 92a84bb8701fb5d421bac2b277debdb8056d68e4
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 12:13:18 2013 +0200
gfx: FillCircle: Add GPL header, sort out includes.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/gfx/GP_FillCircle.gen.c.t b/libs/gfx/GP_FillCircle.gen.c.t
index 90c18c7..ac4c6ce 100644
--- a/libs/gfx/GP_FillCircle.gen.c.t
+++ b/libs/gfx/GP_FillCircle.gen.c.t
@@ -1,13 +1,39 @@
+/*****************************************************************************
+ * 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 Jiri "BlueBear" Dluhos *
+ * <jiri.bluebear.dluhos(a)gmail.com> *
+ * *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
-{% block descr %}Circle filling algorithm{% endblock %}
+{% block descr %}A filled circle drawing algorithm.{% endblock %}
%% block body
#include "core/GP_GetPutPixel.h"
+#include "core/GP_Transform.h"
#include "core/GP_FnPerBpp.h"
-#include "gfx/GP_Circle.h"
#include "gfx/GP_HLine.h"
+#include "gfx/GP_Circle.h"
/*
* A filled circle drawing algorithm.
http://repo.or.cz/w/gfxprim.git/commit/3b46f61b9b1698b2711c93e746464db13a48…
commit 3b46f61b9b1698b2711c93e746464db13a486e62
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 11:45:17 2013 +0200
tests: gfx: Add FillEllipse testsuite.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/gfx/FillEllipse.c b/tests/gfx/FillEllipse.c
new file mode 100644
index 0000000..84bb7d7
--- /dev/null
+++ b/tests/gfx/FillEllipse.c
@@ -0,0 +1,367 @@
+/*****************************************************************************
+ * 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 <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <core/GP_Context.h>
+#include <gfx/GP_Ellipse.h>
+
+#include "tst_test.h"
+
+#include "common.h"
+
+struct testcase {
+ /* cicle description */
+ GP_Coord x;
+ GP_Coord y;
+ GP_Size a;
+ GP_Size b;
+
+ /* expected result */
+ GP_Size w, h;
+ const char pixmap[];
+};
+
+static int test_ellipse(const struct testcase *t)
+{
+ GP_Context *c;
+ int err;
+
+ c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8);
+
+ if (c == NULL) {
+ tst_err("Failed to allocate context");
+ return TST_UNTESTED;
+ }
+
+ /* zero the pixels buffer */
+ memset(c->pixels, 0, c->w * c->h);
+
+ GP_FillEllipse(c, t->x, t->y, t->a, t->b, 1);
+
+ err = compare_buffers(t->pixmap, c);
+
+ if (err)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+static struct testcase testcase_ellipse_a0_b0 = {
+ .x = 2,
+ .y = 2,
+ .a = 0,
+ .b = 0,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a1_b0 = {
+ .x = 2,
+ .y = 2,
+ .a = 1,
+ .b = 0,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a0_b1 = {
+ .x = 2,
+ .y = 2,
+ .a = 0,
+ .b = 1,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a1_b1 = {
+ .x = 2,
+ .y = 2,
+ .a = 1,
+ .b = 1,
+
+ .w = 5,
+ .h = 5,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 1, 1, 1, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a2_b1 = {
+ .x = 3,
+ .y = 3,
+ .a = 2,
+ .b = 1,
+
+ .w = 7,
+ .h = 7,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 1, 1, 0, 0,
+ 0, 1, 1, 1, 1, 1, 0,
+ 0, 0, 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a1_b2 = {
+ .x = 3,
+ .y = 3,
+ .a = 1,
+ .b = 2,
+
+ .w = 7,
+ .h = 7,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 1, 1, 1, 0, 0,
+ 0, 0, 1, 1, 1, 0, 0,
+ 0, 0, 1, 1, 1, 0, 0,
+ 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a2_b2 = {
+ .x = 3,
+ .y = 3,
+ .a = 2,
+ .b = 2,
+
+ .w = 7,
+ .h = 7,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 1, 1, 0, 0,
+ 0, 1, 1, 1, 1, 1, 0,
+ 0, 1, 1, 1, 1, 1, 0,
+ 0, 1, 1, 1, 1, 1, 0,
+ 0, 0, 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a1_b3 = {
+ .x = 4,
+ .y = 4,
+ .a = 1,
+ .b = 3,
+
+ .w = 9,
+ .h = 9,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a3_b2 = {
+ .x = 4,
+ .y = 4,
+ .a = 3,
+ .b = 2,
+
+ .w = 9,
+ .h = 9,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a3_b3 = {
+ .x = 4,
+ .y = 4,
+ .a = 3,
+ .b = 3,
+
+ .w = 9,
+ .h = 9,
+
+ .pixmap = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
+ 0, 0, 1, 1, 1, 1, 1, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0,
+ 0, 0, 1, 1, 1, 1, 1, 0, 0,
+ 0, 0, 0, 1, 1, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a6_b6_clip = {
+ .x = 0,
+ .y = 0,
+ .a = 6,
+ .b = 6,
+
+ .w = 8,
+ .h = 8,
+
+ .pixmap = {
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 1, 0,
+ 1, 1, 1, 1, 1, 1, 0, 0,
+ 1, 1, 1, 1, 1, 1, 0, 0,
+ 1, 1, 1, 1, 1, 0, 0, 0,
+ 1, 1, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ }
+};
+
+static struct testcase testcase_ellipse_a5_b5_clip = {
+ .x = 0,
+ .y = 5,
+ .a = 5,
+ .b = 5,
+
+ .w = 11,
+ .h = 11,
+
+ .pixmap = {
+ 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
+ }
+};
+
+const struct tst_suite tst_suite = {
+ .suite_name = "FillEllipse Testsuite",
+ .tests = {
+ {.name = "FillEllipse a=0 b=0",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a0_b0},
+
+ {.name = "FillEllipse a=1 b=0",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a1_b0},
+
+ {.name = "FillEllipse a=0 b=1",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a0_b1},
+
+ {.name = "FillEllipse a=1 b=1",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a1_b1},
+
+ {.name = "FillEllipse a=2 b=1",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a2_b1},
+
+ {.name = "FillEllipse a=1 b=2",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a1_b2},
+
+ {.name = "FillEllipse a=2 b=2",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a2_b2},
+
+ {.name = "FillEllipse a=1 b=3",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a1_b3},
+
+ {.name = "FillEllipse a=3 b=2",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a3_b2},
+
+ {.name = "FillEllipse a=3 b=3",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a3_b3},
+
+ {.name = "FillEllipse a=5 b=5 clipped",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a5_b5_clip},
+
+ {.name = "FillEllipse a=6 b=6 clipped",
+ .tst_fn = test_ellipse,
+ .data = &testcase_ellipse_a6_b6_clip},
+
+ {.name = NULL}
+ }
+};
diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile
index cf845f6..2094107 100644
--- a/tests/gfx/Makefile
+++ b/tests/gfx/Makefile
@@ -5,11 +5,12 @@ CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
GENSOURCES=APICoverage.gen.c
APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon Ellipse HLine- VLine PutPixelAA HLineAA LineAA APICoverage.gen
+ VLine PutPixelAA HLineAA LineAA APICoverage.gen FillEllipse
Circle: common.o
FillCircle: common.o
Ellipse: common.o
+FillEllipse: common.o
Line: common.o
CircleSeg: common.o
Polygon: common.o
diff --git a/tests/gfx/test_list.txt b/tests/gfx/test_list.txt
index 8070210..ff64600 100644
--- a/tests/gfx/test_list.txt
+++ b/tests/gfx/test_list.txt
@@ -8,6 +8,7 @@ Line
Circle
FillCircle
Ellipse
+FillEllipse
CircleSeg
Polygon
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_Circle.c | 7 +-
libs/gfx/GP_Ellipse.c | 25 -----
libs/gfx/GP_FillCircle.gen.c.t | 30 ++++++-
.../FillEllipse.algo.h => GP_FillEllipse.gen.c.t} | 93 ++++++++++++------
libs/gfx/GP_Line.gen.c.t | 4 +-
libs/gfx/Makefile | 3 +-
libs/gfx/algo/Line.algo.h | 81 ----------------
tests/gfx/{Ellipse.c => FillEllipse.c} | 102 ++++++++++----------
tests/gfx/Line.c | 8 +-
tests/gfx/Makefile | 3 +-
tests/gfx/test_list.txt | 1 +
tests/loaders/PNG.c | 82 +++++++++++++++-
.../loaders/data/png/valid/100x100-white-adam7.png | Bin 0 -> 346 bytes
13 files changed, 232 insertions(+), 207 deletions(-)
rename libs/gfx/{algo/FillEllipse.algo.h => GP_FillEllipse.gen.c.t} (56%)
delete mode 100644 libs/gfx/algo/Line.algo.h
copy tests/gfx/{Ellipse.c => FillEllipse.c} (78%)
create mode 100644 tests/loaders/data/png/valid/100x100-white-adam7.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
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 c7c32efcf6deac514ea58f8adef8185afc0a3788 (commit)
from 3966bfc09a6af79182519c6083f6beb085ef26e0 (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/c7c32efcf6deac514ea58f8adef8185afc0a…
commit c7c32efcf6deac514ea58f8adef8185afc0a3788
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 10 11:36:09 2013 +0200
loaders: PNG: Fix Adam7 interlacing handling.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index b1b725d..ce03c85 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.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> *
* *
*****************************************************************************/
@@ -106,7 +106,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
int depth, color_type, interlace_type;
GP_PixelType pixel_type = GP_PIXEL_UNKNOWN;
GP_Context *res;
- int err;
+ int err, passes = 1;
double gamma;
png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
@@ -148,6 +148,9 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
color_type & PNG_COLOR_MASK_ALPHA ? " with alpha channel" : "",
(unsigned int)w, (unsigned int)h, depth, gamma);
+ if (interlace_type == PNG_INTERLACE_ADAM7)
+ passes = png_set_interlace_handling(png);
+
switch (color_type) {
case PNG_COLOR_TYPE_GRAY:
switch (depth) {
@@ -233,19 +236,26 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
png_set_packswap(png);
uint32_t y;
-
- /* start the actuall reading */
- for (y = 0; y < h; y++) {
- png_bytep row = GP_PIXEL_ADDR(res, 0, y);
- png_read_row(png, row, NULL);
-
- if (GP_ProgressCallbackReport(callback, y, h, w)) {
- GP_DEBUG(1, "Operation aborted");
- err = ECANCELED;
- goto err3;
+ int p;
+
+ /*
+ * Do the actuall reading.
+ *
+ * The passes are needed for adam7 interlacing.
+ */
+ for (p = 0; p < passes; p++) {
+ for (y = 0; y < h; y++) {
+ png_bytep row = GP_PIXEL_ADDR(res, 0, y);
+ png_read_row(png, row, NULL);
+
+ if (GP_ProgressCallbackReport(callback, y + h * p, h * passes, w)) {
+ GP_DEBUG(1, "Operation aborted");
+ err = ECANCELED;
+ goto err3;
+ }
}
}
-
+
png_destroy_read_struct(&png, &png_info, NULL);
GP_ProgressCallbackDone(callback);
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_PNG.c | 36 +++++++++++++++++++++++-------------
1 files changed, 23 insertions(+), 13 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
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 3966bfc09a6af79182519c6083f6beb085ef26e0 (commit)
from f39dce582400e88f7b034f0612d2c4352dac43f2 (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/3966bfc09a6af79182519c6083f6beb085ef…
commit 3966bfc09a6af79182519c6083f6beb085ef26e0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu May 9 23:36:58 2013 +0200
doc: Update index.html
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/index.html b/doc/index.html
index 034386f..905c1b7 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -28,10 +28,12 @@
</div>
<div id="menu">
<ul class="menu-tree">
- <li class="menu-tree-item"><a href="index.html">Home</a></li>
- <li class="menu-tree-item"><a href="api.html">API</a></li>
- <li class="menu-tree-item"><a href="examples.html">Code Examples</a></li>
- <li class="menu-tree-item"><a href="http://repo.or.cz/w/gfxprim.git">GIT</a></li>
+ <li class="menu-tree-item"><a href="general.html">C API</a></li>
+ <li class="menu-tree-item"><a href="core_python.html">Pyton API</a></li>
+ <li class="menu-tree-item"><a href="http://www.ucw.cz/mailman/listinfo/gfxprim">Mailing List</a></li>
+ <li class="menu-tree-item"><a href="https://github.com/gfxprim/gfxprim">GIT (GitHub)</a></li>
+ <li class="menu-tree-item"><a href="http://repo.or.cz/w/gfxprim.git">GIT (repo.or.cz)</a></li>
+ <li class="menu-tree-item"><a href="releases/gfxprim_1.0.0-rc0.tar.bz2">Download 1.0.0-rc0</a></li>
</ul>
</div>
<div id="content">
@@ -46,21 +48,26 @@
</p>
<h3>About</h3>
<p>
- Once upon the time <i>GFXprim</i> had started as an simple attempt to
- replace SDL_gfx which was unusable at the time we started. Soon it outgrew
- the initial purpose and yielded into library that could be used as
- replacement for SDL library. In contrast with SDL <i>GFXprim</i> is
+ Once upon the time <i>GFXprim</i> has started as a simple attempt to
+ replace SDL_gfx which was unusable then. Soon it outgrew the initial
+ purpose and yielded into a library that could be used as a replacement
+ for the family of SDL libraries. In contrast with SDL <i>GFXprim</i> is
not aiming for abstracting the operating system interface. Instead of
- that <i>GFXprim</i> provides means for keeping the system dependent
- parts in well defined and isolated parts.
+ that <i>GFXprim</i> provides means for keeping the system dependent parts
+ in well defined and isolated parts.
</p>
<p>
- One of the key points of the library is code generation. Most of the
+ One of the key points of the library are code generators. Most of the
graphics operations are written using <a href="http://jinja.pocoo.org/">jinja</a>
- templating engine which is used to generate specialized C code. So,
+ templating engine which is used to create specialized C code. So,
for an example, once you add pixel definition into configuration file,
creating specialized filters, loaders and conversions to other pixel
- formats is just a matter of typing "make && make clean".
+ formats is just a matter of typing "make rebuild".
+ </p>
+ <h3>Documentation</h3>
+ <p>
+ For more information about features and API look at the
+ <a href="general.html">documentation</a>.
</p>
<h3>News</h3>
<p>
@@ -73,21 +80,12 @@
We do have a <a href="http://www.ucw.cz/mailman/listinfo/gfxprim">mailing list</a>
and although there is not much of discussion now, we are there and listening.
</p>
- <h3>Documentation</h3>
- <p>
- For more information about internal structure and features look at the
- <a href="api.html">API Description</a>.
- </p>
- <p>
- There are also some nice C and Python
- <a href="examples.html">Code Examples</a>.
- </p>
</div>
<div id="cleaner"> </div>
<div id="footer">
- <a href="http://repo.or.cz/w/gfxprim.git">git</a> |
- <a href="http://atrey.karlin.mff.cuni.cz/~gavento/GfxPrimWiki/">wiki</a> |
- <a href="http://www.ucw.cz/mailman/listinfo/gfxprim">mailing list</a>
+ <a href="http://repo.or.cz/w/gfxprim.git">repo.or.cz</a> |
+ <a href="https://github.com/gfxprim/gfxprim">GitHub</a> |
+ <a href="http://www.ucw.cz/mailman/listinfo/gfxprim">Mailing List</a>
</div>
</div>
</body>
-----------------------------------------------------------------------
Summary of changes:
doc/index.html | 48 +++++++++++++++++++++++-------------------------
1 files changed, 23 insertions(+), 25 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
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 f39dce582400e88f7b034f0612d2c4352dac43f2 (commit)
from e791f1daa4c76016f0b45d3c827d253d4e1c7543 (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/f39dce582400e88f7b034f0612d2c4352dac…
commit f39dce582400e88f7b034f0612d2c4352dac43f2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu May 9 23:35:50 2013 +0200
install: Fix make install for empty prefix.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/Makefile b/Makefile
index 1ffbe41..a2b327d 100644
--- a/Makefile
+++ b/Makefile
@@ -30,9 +30,9 @@ LIB_LOC=/usr/lib/
install:
ifdef VERBOSE
- ./install.sh $(prefix) $(libdir) $(bindir) $(includedir)
+ ./install.sh "$(prefix)" $(libdir) $(bindir) $(includedir)
else
- @./install.sh $(prefix) $(libdir) $(bindir) $(includedir)
+ @./install.sh "$(prefix)" $(libdir) $(bindir) $(includedir)
endif
tar:
-----------------------------------------------------------------------
Summary of changes:
Makefile | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0