Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
April 2013
- 2 participants
- 36 discussions
[repo.or.cz] gfxprim.git branch master updated: 93fe2dde68b7eb9a2d22c4006e5c9d03c4e2485c
by metan 19 Apr '13
by metan 19 Apr '13
19 Apr '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 93fe2dde68b7eb9a2d22c4006e5c9d03c4e2485c (commit)
via 5f991644977d8e9bda991e1b79efba06fc05adff (commit)
via 057139e9ba8617156f214005b143846b6110f28d (commit)
from f075f1935eff2f786cc3b481d1ec7037f6654a9a (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/93fe2dde68b7eb9a2d22c4006e5c9d03c4e2…
commit 93fe2dde68b7eb9a2d22c4006e5c9d03c4e2485c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 19 18:24:13 2013 +0200
doc: update python loaders docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/loaders_python.txt b/doc/loaders_python.txt
index 4ac158b..992cd07 100644
--- a/doc/loaders_python.txt
+++ b/doc/loaders_python.txt
@@ -16,6 +16,12 @@ import gfxprim.loaders as loaders
Loads an image from a file.
+This is a general purpose loader function that automatically detects the file
+format.
+
+The format is detected from file extension first and if this fails signature
+base method is used.
+
May raise 'OSError' with errno set to 'EPERM', 'EISDIR', 'ENOENT' or any other
'errno' set by 'open(2)', 'read(2)', 'seek(2)'.
@@ -26,3 +32,42 @@ May raise 'OSError' with errno set to 'EIO' when file is damaged.
May raise 'OSError' with errno set to 'ECANCELED' when action was interrupted
by callback.
+
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.loaders as loaders
+
+ img.loaders.Save(path, callback=None)
+
+ img.loaders.SavePNG(path, callback=None)
+
+ img.loaders.SaveJPG(path, callback=None)
+
+ img.loaders.SaveBMP(path, callback=None)
+-------------------------------------------------------------------------------
+
+Save image to a file.
+
+For the Save() method the file format is derived from the extension.
+
+May raise 'OSError' with errno set to 'EPERM', 'EISDIR', 'ENOENT' or any other
+'errno' set by 'open(2)', 'write(2)', 'seek(2)'.
+
+May raise 'OSError' with errno set to 'ENOSYS' on unsupported pixel type for
+a given format.
+
+May raise 'OSError' with errno set to 'EIO' when file is damaged.
+
+May raise 'OSError' with errno set to 'ECANCELED' when action was interrupted
+by callback.
+
+[source,python]
+-------------------------------------------------------------------------------
+import gfxprim.loaders as loaders
+
+ loaders.ListLoaders()
+
+-------------------------------------------------------------------------------
+
+Prints all loaders and their capabilites into the 'stdout'.
http://repo.or.cz/w/gfxprim.git/commit/5f991644977d8e9bda991e1b79efba06fc05…
commit 5f991644977d8e9bda991e1b79efba06fc05adff
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 19 18:20:57 2013 +0200
demos: py_simple: Make use of loaders submodule.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/py_simple/dither.py b/demos/py_simple/dither.py
index 470d601..e40221e 100755
--- a/demos/py_simple/dither.py
+++ b/demos/py_simple/dither.py
@@ -15,7 +15,7 @@ def main():
# Use Floyd-Steinberg dithering
res = filters.FilterFloydSteinberg_RGB888_Alloc(img, core.C.PIXEL_G1, None)
# Save result into grayscale png
- loaders.SavePNG(res, "out.png", None)
+ res.loaders.SavePNG("out.png")
if __name__ == '__main__':
main()
http://repo.or.cz/w/gfxprim.git/commit/057139e9ba8617156f214005b143846b6110…
commit 057139e9ba8617156f214005b143846b6110f28d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 19 18:20:12 2013 +0200
pywrap: loaders: Add SaveXXX functions to submodule.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/loaders/__init__.py b/pylib/gfxprim/loaders/__init__.py
index 621099a..a9878fa 100644
--- a/pylib/gfxprim/loaders/__init__.py
+++ b/pylib/gfxprim/loaders/__init__.py
@@ -1,12 +1,10 @@
from . import c_loaders
-
def Load(filename, callback=None):
"Load image from given file, guessing the type."
c = c_loaders.GP_LoadImage(filename, callback)
return c
-
def _init(module):
"Extend Context with loaders submodule"
@@ -26,6 +24,30 @@ def _init(module):
Generally, not all pixel types work with all formats.
"""
c_loaders.GP_SaveImage(self.ctx, filename, callback)
+
+ @extend(LoadersSubmodule)
+ def SavePNG(self, filename, callback=None):
+ """Save the image as PNG.
+
+ Generally, not all pixel types work with all formats.
+ """
+ c_loaders.GP_SavePNG(self.ctx, filename, callback)
+
+ @extend(LoadersSubmodule)
+ def SaveJPG(self, filename, callback=None):
+ """Save the image as JPEG.
+
+ Generally, not all pixel types work with all formats.
+ """
+ c_loaders.GP_SaveJPG(self.ctx, filename, callback)
+
+ @extend(LoadersSubmodule)
+ def SaveBMP(self, filename, callback=None):
+ """Save the image as BMP.
+
+ Generally, not all pixel types work with all formats.
+ """
+ c_loaders.GP_SaveBMP(self.ctx, filename, callback)
# Imports from the SWIG module
import re
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/dither.py | 2 +-
doc/loaders_python.txt | 45 +++++++++++++++++++++++++++++++++++++
pylib/gfxprim/loaders/__init__.py | 26 +++++++++++++++++++-
3 files changed, 70 insertions(+), 3 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: f075f1935eff2f786cc3b481d1ec7037f6654a9a
by metan 19 Apr '13
by metan 19 Apr '13
19 Apr '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 f075f1935eff2f786cc3b481d1ec7037f6654a9a (commit)
from 80d98abae1846cff3ffcd16edf2b00c87ad19020 (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/f075f1935eff2f786cc3b481d1ec7037f665…
commit f075f1935eff2f786cc3b481d1ec7037f6654a9a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 19 00:12:12 2013 +0200
build: First attempt for 'make install' for python bindigs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/Makefile b/Makefile
index 3da6589..bfd39a6 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,11 @@ include $(TOPDIR)/pre.mk
TOP_MAKE=1
+ifneq ($(MAKECMDGOALS),install)
SUBDIRS=include libs tests pylib demos build
+else
+SUBDIRS=pylib
+endif
libs: include
build: libs
diff --git a/configure b/configure
index fed17b4..af9f8fc 100755
--- a/configure
+++ b/configure
@@ -5,6 +5,7 @@
import os
import sys
from optparse import OptionParser
+from subprocess import check_output
def header_exists(cfg, filename):
fpath = cfg['include_path'][0] + '/' + filename
@@ -37,6 +38,16 @@ def c_compiler_exists(cfg):
"Checking for working compiler (%s) ... " %
cfg["CC"][0])
+def python_version(cfg):
+ sys.stderr.write("Cddhecking for python-config Python version ... ")
+
+ res = str(check_output("%s --ldflags" % cfg['PYTHON_CONFIG'][0], shell=True))
+ res = res[res.find('-lpython')+8:]
+ res = res[:3]
+
+ sys.stderr.write("%sn" % res)
+ return res
+
def python_module_installed(cfg, module):
sys.stderr.write("Checking for python module %s ... " % module)
@@ -85,6 +96,13 @@ class libraries:
# Print summary
#
def print_summary(self):
+ sys.stderr.write("Settings and variablesn")
+ sys.stderr.write("----------------------n")
+
+ for i in cfg:
+ sys.stderr.write("%14s : %sn" % (i, cfg[i][0]))
+ sys.stderr.write(" - %snn" % cfg[i][1])
+
sys.stderr.write("Libraries to link againstn")
sys.stderr.write("-------------------------n")
@@ -96,7 +114,7 @@ class libraries:
else:
sys.stderr.write(" : Disabledn")
- sys.stderr.write(" - %snn" % i[1])
+ sys.stderr.write(" - %snn" % i[1])
#
# Enable/Disable library
#
@@ -184,6 +202,9 @@ def basic_checks(cfg):
check_for_swig(cfg)
check_for_python_config(cfg)
+
+ cfg['PYTHON_VER'][0] = python_version(cfg)
+
sys.stderr.write("n")
#
@@ -255,7 +276,9 @@ if __name__ == '__main__':
'PYTHON_BIN' : ['python', 'Path/name of python interpreter'],
'SWIG' : ['swig', 'Simplified Wrapper and Interface Generator'],
'PYTHON_CONFIG' : ['python-config', 'Python config helper'],
- 'include_path' : ['/usr/include', 'Path to the system headers']}
+ 'PYTHON_VER' : ['', 'Python version (derived from python config)'],
+ 'include_path' : ['/usr/include', 'Path to the system headers'],
+ 'prefix' : ['/usr', 'Installation prefix']}
#
# Library detection/enable disable
diff --git a/post.mk b/post.mk
index 881a42f..c217f97 100644
--- a/post.mk
+++ b/post.mk
@@ -5,11 +5,12 @@ ifndef SUBDIRS
SUBDIRS=
endif
-.PHONY: $(SUBDIRS) all clean rebuild help doc
+.PHONY: $(SUBDIRS) all clean rebuild help doc install
all: $(SUBDIRS)
clean: $(SUBDIRS)
rebuild: $(SUBDIRS)
+install: $(SUBDIRS)
help:
@echo "*** Available targets ***"
diff --git a/pyinst.mk b/pyinst.mk
new file mode 100644
index 0000000..cc4484a
--- /dev/null
+++ b/pyinst.mk
@@ -0,0 +1,26 @@
+#
+# Install python libraries into right place
+#
+# Note that LIBNAME is be empty for root gfxprim python package
+#
+ifdef SWIG
+ifdef PYTHON_CONFIG
+
+PY_INSTALL_PREFIX=$(prefix)/lib/python$(PYTHON_VER)/gfxprim/$(LIBNAME)
+
+ifdef DESTDIR
+PY_INSTALL_PREFIX:=$(DESTDIR)$(PY_INSTALL_PREFIX)
+endif
+
+install: $(INSTALL_FILES)
+ifdef VERBOSE
+ install -d "$(PY_INSTALL_PREFIX)"
+ for i in $(INSTALL_FILES); do install "$$i" "$(PY_INSTALL_PREFIX)"; done
+else
+ @echo "DEST $(PY_INSTALL_PREFIX)"
+ @install -d "$(PY_INSTALL_PREFIX)"
+ @for i in $(INSTALL_FILES); do echo " -> $$i"; install "$$i" "$(PY_INSTALL_PREFIX)"; done
+endif
+
+endif
+endif
diff --git a/pylib/gfxprim/Makefile b/pylib/gfxprim/Makefile
index a2b9700..98d224e 100644
--- a/pylib/gfxprim/Makefile
+++ b/pylib/gfxprim/Makefile
@@ -1,4 +1,10 @@
TOPDIR=../..
SUBDIRS=core loaders backends gfx filters text input grabbers
CLEAN+=*.pyc
+
+include $(TOPDIR)/pre.mk
+
+INSTALL_FILES=__init__.py utils.py
+
+include $(TOPDIR)/pyinst.mk
include $(TOPDIR)/post.mk
diff --git a/pylib/gfxprim/backends/Makefile b/pylib/gfxprim/backends/Makefile
index ac02d2a..fd62f34 100644
--- a/pylib/gfxprim/backends/Makefile
+++ b/pylib/gfxprim/backends/Makefile
@@ -5,6 +5,9 @@ INCLUDE=core
LDFLAGS+=$(shell $(TOPDIR)/gfxprim-config --libs-backends)
include $(TOPDIR)/pre.mk
+
+INSTALL_FILES+=_extend_backend.py
+
include $(TOPDIR)/pywrap.mk
include $(TOPDIR)/post.mk
diff --git a/pylib/gfxprim/core/Makefile b/pylib/gfxprim/core/Makefile
index 3be0466..ada5a6c 100644
--- a/pylib/gfxprim/core/Makefile
+++ b/pylib/gfxprim/core/Makefile
@@ -6,6 +6,8 @@ include $(TOPDIR)/pywrap.mk
$(SWIG_C): ../common.i
+INSTALL_FILES+=C.py
+
include $(TOPDIR)/post.mk
include ../silence_swig_warnings.mk
diff --git a/pylib/gfxprim/gfx/Makefile b/pylib/gfxprim/gfx/Makefile
index 69a74e4..b0e7e60 100644
--- a/pylib/gfxprim/gfx/Makefile
+++ b/pylib/gfxprim/gfx/Makefile
@@ -3,6 +3,9 @@ LIBNAME=gfx
INCLUDE=core
include $(TOPDIR)/pre.mk
+
+INSTALL_FILES+=C.py
+
include $(TOPDIR)/pywrap.mk
include $(TOPDIR)/post.mk
diff --git a/pylib/gfxprim/text/Makefile b/pylib/gfxprim/text/Makefile
index 1f097e6..2ae37f9 100644
--- a/pylib/gfxprim/text/Makefile
+++ b/pylib/gfxprim/text/Makefile
@@ -3,6 +3,9 @@ LIBNAME=text
INCLUDE=core
include $(TOPDIR)/pre.mk
+
+INSTALL_FILES+=C.py
+
include $(TOPDIR)/pywrap.mk
include $(TOPDIR)/post.mk
diff --git a/pywrap.mk b/pywrap.mk
index 3cac52a..1cd89e5 100644
--- a/pywrap.mk
+++ b/pywrap.mk
@@ -2,15 +2,16 @@ ifndef LIBNAME
$(error LIBNAME not defined, fix your library Makefile)
endif
-SWIG_SRC=$(LIBNAME).i
-SWIG_C=$(LIBNAME)_wrap.c
-SWIG_PY=c_$(LIBNAME).py
-SWIG_LIB=_c_$(LIBNAME).so
-
ifdef SWIG
ifdef PYTHON_CONFIG
INCLUDES+=$(addprefix -I$(TOPDIR)/include/, $(INCLUDE))
+PY_SUFFIX=$(shell $(PYTHON_CONFIG) --extension-suffix)
+
+SWIG_SRC=$(LIBNAME).i
+SWIG_C=$(LIBNAME)_wrap.c
+SWIG_PY=c_$(LIBNAME).py
+SWIG_LIB=_c_$(LIBNAME)$(PY_SUFFIX)
ALL+=$(SWIG_LIB) $(SWIG_PY)
@@ -36,7 +37,12 @@ else # VERBOSE
@$(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) $(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
endif # VERBOSE
-endif # PYTHON_CONFIG
-endif # SWIG
+# Install python libraries into right places
+INSTALL_FILES+=__init__.py $(SWIG_PY) $(SWIG_LIB)
+
+include $(TOPDIR)/pyinst.mk
CLEAN+=$(SWIG_C) $(SWIG_PY) $(SWIG_LIB) *.pyc
+
+endif # PYTHON_CONFIG
+endif # SWIG
-----------------------------------------------------------------------
Summary of changes:
Makefile | 4 ++++
configure | 27 +++++++++++++++++++++++++--
post.mk | 3 ++-
pyinst.mk | 26 ++++++++++++++++++++++++++
pylib/gfxprim/Makefile | 6 ++++++
pylib/gfxprim/backends/Makefile | 3 +++
pylib/gfxprim/core/Makefile | 2 ++
pylib/gfxprim/gfx/Makefile | 3 +++
pylib/gfxprim/text/Makefile | 3 +++
pywrap.mk | 20 +++++++++++++-------
10 files changed, 87 insertions(+), 10 deletions(-)
create mode 100644 pyinst.mk
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 80d98abae1846cff3ffcd16edf2b00c87ad19020
by metan 15 Apr '13
by metan 15 Apr '13
15 Apr '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 80d98abae1846cff3ffcd16edf2b00c87ad19020 (commit)
via 2a96bbcf1e62de2aeff0ac728c71477fccc18e6d (commit)
via 7d0e2bb5dcedab5c81890c3dbed2aa2e2856c81a (commit)
via d754038d2b333494cfe8c53abf98f9771bfa5289 (commit)
from a30c88774de677c922827ac3f8f1032db96ec044 (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/80d98abae1846cff3ffcd16edf2b00c87ad1…
commit 80d98abae1846cff3ffcd16edf2b00c87ad19020
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Apr 15 21:18:30 2013 +0200
demos: py_simple: Remove broken plot.py.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/py_simple/plot.py b/demos/py_simple/plot.py
deleted file mode 100755
index d58e574..0000000
--- a/demos/py_simple/plot.py
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env python
-import gfxprim.core as core
-import gfxprim.backends as backends
-import gfxprim.gfx as gfx
-import sys
-from math import *
-
-W = 640
-H = 480
-EPS = 0.05
-
-env = {}
-env['sin'] = sin
-env['cos'] = cos
-env['sqrt'] = sqrt
-
-def compute(func, x, y_min, y_max):
- env['x'] = x
- try:
- ret = eval(func, env)
- except ZeroDivisionError:
- return -1
-
- return - H * ret / (y_max - y_min) + (H * y_max) / (y_max - y_min)
-
-def x_to_x(x, x_min, x_max):
- return (x_max - x_min) * x / W + x_min
-
-class plotter(object):
- def __init__(self, func, x_min, x_max, y_min, y_max):
- self.x = 0.0
- self.y = compute(func, x_to_x(self.x, x_min, x_max), y_min, y_max)
- self.y_min = y_min
- self.y_max = y_max
- self.x_min = x_min
- self.x_max = x_max
- self.func = func
- def next(self):
- x = x_to_x(self.x + 1, self.x_min, self.x_max)
- new_y = compute(self.func, x, self.y_min, self.y_max)
-
- inc = 1.0
-
- while (abs(new_y - self.y) > 1 and inc > EPS):
- x = x_to_x(self.x + inc, self.x_min, self.x_max)
- new_y = compute(self.func, x, self.y_min, self.y_max)
- inc /= 2
-
- self.x += inc
- self.y = new_y
-
- print(self.x, self.y)
-
-
-def main():
- bk = backends.BackendSDLInit(W, H, 0, 0, "Plot AA")
- assert bk
- print(bk)
- print("Modify source for parameters,")
- print("Kill to terminate ;-)")
- print("Usage: function x_min x_max y_min y_max")
- black = bk.context.RGBToPixel(0, 0, 0)
-
- x_min = float(sys.argv[2])
- x_max = float(sys.argv[3])
- y_min = float(sys.argv[4])
- y_max = float(sys.argv[5])
- p = plotter(sys.argv[1], x_min, x_max, y_min, y_max)
-
- r = 255
- g = 0
- b = 0
-
- while p.x < W:
- x = int((p.x + 0.5) * 0x100)
- y = int((p.y + 0.5) * 0x100)
- gfx.PutPixelAA(bk.context, x, y, bk.context.RGBToPixel(int(r), int(g), int(b)))
- bk.Flip()
- p.next()
-
- while True:
- pass
-
-if __name__ == '__main__':
- main()
http://repo.or.cz/w/gfxprim.git/commit/2a96bbcf1e62de2aeff0ac728c71477fccc1…
commit 2a96bbcf1e62de2aeff0ac728c71477fccc18e6d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Apr 15 21:14:23 2013 +0200
build: pywrap.mk: Two fixes.
* Rebuild the so libs when configure was runned.
(path to the python config could changed)
* Remove redundand -I (I'm suprised it compiled fine before)
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pywrap.mk b/pywrap.mk
index 4518b71..3cac52a 100644
--- a/pywrap.mk
+++ b/pywrap.mk
@@ -18,6 +18,8 @@ ALL+=$(SWIG_LIB) $(SWIG_PY)
$(SWIG_PY): $(SWIG_C)
@
+$(SWIG_LIB): $(TOPDIR)/config.gen.mk
+
$(SWIG_C): $(SWIG_SRC)
ifdef VERBOSE
$(SWIG) $(SWIGOPTS) -python $(INCLUDES) $<
@@ -28,10 +30,10 @@ endif # VERBOSE
$(SWIG_LIB): $(SWIG_C)
ifdef VERBOSE
- $(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
+ $(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) $(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
else # VERBOSE
@echo "LD $@"
- @$(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) -I$(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
+ @$(CC) $< $(CFLAGS) -D_GNU_SOURCE=1 $(LDFLAGS) $(PYTHON_INCLUDE) --shared -lGP $(LDLIBS) -L$(TOPDIR)/build/ -o $@
endif # VERBOSE
endif # PYTHON_CONFIG
http://repo.or.cz/w/gfxprim.git/commit/7d0e2bb5dcedab5c81890c3dbed2aa2e2856…
commit 7d0e2bb5dcedab5c81890c3dbed2aa2e2856c81a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Apr 15 21:11:56 2013 +0200
pywrap: core: CallbackProxy: Reword error message.
The error happens in general case, not only on parse error.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i
index 2657327..afca013 100644
--- a/pylib/gfxprim/core/core.i
+++ b/pylib/gfxprim/core/core.i
@@ -43,9 +43,9 @@ static int GP_ProgressCallbackProxy(GP_ProgressCallback *self)
res = PyEval_CallObject(obj, args);
- /* Parse Error */
+ /* Parse Error, Interruption, etc. */
if (res == NULL) {
- GP_WARN("Parse error while calling callback, aborting");
+ GP_WARN("Error while calling callback, aborting");
return 1;
}
http://repo.or.cz/w/gfxprim.git/commit/d754038d2b333494cfe8c53abf98f9771bfa…
commit d754038d2b333494cfe8c53abf98f9771bfa5289
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Apr 15 21:11:12 2013 +0200
demos: py_simple: Fixes.
* Fix compatibility with python 2.6
* Various small fixes.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/py_simple/backends.py b/demos/py_simple/backends.py
index 6c53116..f6d9e40 100755
--- a/demos/py_simple/backends.py
+++ b/demos/py_simple/backends.py
@@ -28,7 +28,7 @@ def main():
backend_string = sys.argv[1]
if len(sys.argv) > 2:
- print("Usage: {} [backend init string]".format(sys.argv[0]))
+ print("Usage: %s [backend init string]" % sys.argv[0])
sys.exit(1)
# Create backend window
diff --git a/demos/py_simple/gfx.py b/demos/py_simple/gfx.py
index 2c9aef3..9d82a1b 100755
--- a/demos/py_simple/gfx.py
+++ b/demos/py_simple/gfx.py
@@ -136,17 +136,16 @@ def next(bk, i):
return i
def main():
- print(dir(gfx))
-
# Create X11 window
bk = backends.BackendX11Init(None, 0, 0, 320, 240, "GFX demo", 0)
assert(bk)
- print(dir(bk.context.gfx))
bk.Flip()
i = 0
+ print("Press SPACE to draw different shape, ESC to exit")
+
# Event loop
while True:
ev = bk.WaitEvent()
diff --git a/demos/py_simple/progress_callback.py b/demos/py_simple/progress_callback.py
index d743c23..4055f1a 100755
--- a/demos/py_simple/progress_callback.py
+++ b/demos/py_simple/progress_callback.py
@@ -7,7 +7,8 @@ import gfxprim.loaders as loaders
import gfxprim.filters as filters
def progress_callback(callback):
- sys.stdout.write("rLoading {:3.2f}%".format(callback))
+ sys.stdout.write("rLoading %3.2f%%" % callback)
+ sys.stdout.flush()
return 0
def main():
@@ -19,15 +20,15 @@ def main():
try:
img = loaders.Load(sys.argv[1], callback)
- print()
- except RuntimeError as detail:
- print("Failed to load image '{}': {}".format(sys.argv[1], detail))
+ print('')
+ except OSError as detail:
+ print("Failed to load image '%s': %s" % (sys.argv[1], detail))
exit(1)
try:
img = filters.FilterGaussianBlurAlloc(img, 50, 50, callback)
- print()
- except RuntimeError:
+ print('')
+ except OSError:
print("Filter Aborted")
if __name__ == '__main__':
diff --git a/demos/py_simple/rotate90.py b/demos/py_simple/rotate90.py
index 4a77835..099fb51 100755
--- a/demos/py_simple/rotate90.py
+++ b/demos/py_simple/rotate90.py
@@ -16,7 +16,7 @@ def main():
# Load Image
src = loaders.Load(sys.argv[1])
# Rotate by 90 degrees
- res = filters.FilterRotate90Alloc(src)
+ res = filters.FilterRotate90Alloc(src, None)
# Save Image
res.loaders.Save(sys.argv[2])
diff --git a/demos/py_simple/x11_windows.py b/demos/py_simple/x11_windows.py
index bb656d3..1766087 100755
--- a/demos/py_simple/x11_windows.py
+++ b/demos/py_simple/x11_windows.py
@@ -17,13 +17,13 @@ def redraw(bk, id):
c.gfx.Fill(black)
align = text.C.ALIGN_CENTER | text.C.VALIGN_CENTER
- c.text.Text(None, c.w//2, c.h//2, align, white, black, "{} - {}x{}".format(id, c.w, c.h))
+ c.text.Text(None, c.w//2, c.h//2, align, white, black, "%s - %sx%s" % (id, c.w, c.h))
bk.Flip()
def parse_events(bk, id):
- print("------ Window {} -------".format(id))
+ print("------ Window %s -------" % (id))
while True:
ev = bk.GetEvent()
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/backends.py | 2 +-
demos/py_simple/gfx.py | 5 +-
demos/py_simple/plot.py | 85 ----------------------------------
demos/py_simple/progress_callback.py | 13 +++--
demos/py_simple/rotate90.py | 2 +-
demos/py_simple/x11_windows.py | 4 +-
pylib/gfxprim/core/core.i | 4 +-
pywrap.mk | 6 ++-
8 files changed, 19 insertions(+), 102 deletions(-)
delete mode 100755 demos/py_simple/plot.py
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: a30c88774de677c922827ac3f8f1032db96ec044
by metan 12 Apr '13
by metan 12 Apr '13
12 Apr '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 a30c88774de677c922827ac3f8f1032db96ec044 (commit)
from 0123bcf14843855c6d2b0d33d32f2b6bbc76354c (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/a30c88774de677c922827ac3f8f1032db96e…
commit a30c88774de677c922827ac3f8f1032db96ec044
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 12 19:16:00 2013 +0200
filters: GP_ResizeLinearLF: Fix.
Fix typo that caused the previous speed increase and small artefacts.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t
index 0004180..06f584a 100644
--- a/libs/filters/GP_ResizeLinear.gen.c.t
+++ b/libs/filters/GP_ResizeLinear.gen.c.t
@@ -43,39 +43,39 @@
*
* The xoff is offset of the first pixel.
*/
-%% macro sample_x(pt, suff)
+%%- macro sample_x(pt, suff)
{
- uint32_t mx = x0;
- uint32_t i;
+ uint32_t mx = x0;
+ uint32_t i;
- pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x0, y0);
+ pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, mx, y0);
- %% for c in pt.chanslist
- {{ c[0] }}{{ suff }} = (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * xoff[x]) >> 9;
- %% endfor
+ %% for c in pt.chanslist
+ {{ c[0] }}{{ suff }} = (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * xoff[x]) >> 9;
+ %% endfor
- for (i = (1<<14) - xoff[x]; i > xpix_dist; i -= xpix_dist) {
- if (mx < src->w - 1)
- mx++;
+ for (i = (1<<14) - xoff[x]; i > xpix_dist; i -= xpix_dist) {
+ if (mx < src->w - 1)
+ mx++;
- pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x0, y0);
+ pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, mx, y0);
- %% for c in pt.chanslist
- {{ c[0] }}{{ suff }} += (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * xpix_dist) >> 9;
- %% endfor
- }
+ %% for c in pt.chanslist
+ {{ c[0] }}{{ suff }} += (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * xpix_dist) >> 9;
+ %% endfor
+ }
- if (i > 0) {
- if (mx < src->w - 1)
- mx++;
+ if (i > 0) {
+ if (mx < src->w - 1)
+ mx++;
- pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x0, y0);
+ pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, mx, y0);
- %% for c in pt.chanslist
- {{ c[0] }}{{ suff }} += (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * i) >> 9;
- %% endfor
- }
-}
+ %% for c in pt.chanslist
+ {{ c[0] }}{{ suff }} += (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * i) >> 9;
+ %% endfor
+ }
+ }
%% endmacro
%% for pt in pixeltypes
-----------------------------------------------------------------------
Summary of changes:
libs/filters/GP_ResizeLinear.gen.c.t | 48 +++++++++++++++++-----------------
1 files changed, 24 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
[repo.or.cz] gfxprim.git branch master updated: 0123bcf14843855c6d2b0d33d32f2b6bbc76354c
by metan 12 Apr '13
by metan 12 Apr '13
12 Apr '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 0123bcf14843855c6d2b0d33d32f2b6bbc76354c (commit)
from e596f127b5823f055be5adcca6670be1cfc8b410 (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/0123bcf14843855c6d2b0d33d32f2b6bbc76…
commit 0123bcf14843855c6d2b0d33d32f2b6bbc76354c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 12 18:48:00 2013 +0200
filters: GP_ResizeLinearLF: Templatize.
This templatizes the linear resampling with low pass.
The sampling by x is now template macro, which forced
inlining of the code which produces three times faster code.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t
index d5ccd6d..0004180 100644
--- a/libs/filters/GP_ResizeLinear.gen.c.t
+++ b/libs/filters/GP_ResizeLinear.gen.c.t
@@ -42,46 +42,44 @@
* The xpix_dist is distance of two sampled pixels in source image coordinates.
*
* The xoff is offset of the first pixel.
- *
- * The r, g, b are used to store resulting values.
*/
-static inline void linear_lp_sample_x(const GP_Context *src,
- uint32_t x, uint32_t y,
- uint32_t xpix_dist, uint32_t xoff,
- uint32_t *r, uint32_t *g, uint32_t *b)
+%% macro sample_x(pt, suff)
{
- GP_Pixel pix;
+ uint32_t mx = x0;
uint32_t i;
- pix = GP_GetPixel_Raw_24BPP(src, x, y);
+ pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x0, y0);
- *r = (GP_Pixel_GET_R_RGB888(pix) * xoff) >> 9;
- *g = (GP_Pixel_GET_G_RGB888(pix) * xoff) >> 9;
- *b = (GP_Pixel_GET_B_RGB888(pix) * xoff) >> 9;
+ %% for c in pt.chanslist
+ {{ c[0] }}{{ suff }} = (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * xoff[x]) >> 9;
+ %% endfor
- for (i = (1<<14) - xoff; i > xpix_dist; i -= xpix_dist) {
- if (x < src->w - 1)
- x++;
+ for (i = (1<<14) - xoff[x]; i > xpix_dist; i -= xpix_dist) {
+ if (mx < src->w - 1)
+ mx++;
- pix = GP_GetPixel_Raw_24BPP(src, x, y);
+ pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x0, y0);
- *r += (GP_Pixel_GET_R_RGB888(pix) * xpix_dist) >> 9;
- *g += (GP_Pixel_GET_G_RGB888(pix) * xpix_dist) >> 9;
- *b += (GP_Pixel_GET_B_RGB888(pix) * xpix_dist) >> 9;
+ %% for c in pt.chanslist
+ {{ c[0] }}{{ suff }} += (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * xpix_dist) >> 9;
+ %% endfor
}
if (i > 0) {
- if (x < src->w - 1)
- x++;
+ if (mx < src->w - 1)
+ mx++;
+
+ pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x0, y0);
- pix = GP_GetPixel_Raw_24BPP(src, x, y);
-
- *r += (GP_Pixel_GET_R_RGB888(pix) * i) >> 9;
- *g += (GP_Pixel_GET_G_RGB888(pix) * i) >> 9;
- *b += (GP_Pixel_GET_B_RGB888(pix) * i) >> 9;
+ %% for c in pt.chanslist
+ {{ c[0] }}{{ suff }} += (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * i) >> 9;
+ %% endfor
}
}
+%% endmacro
+%% for pt in pixeltypes
+%% if not pt.is_unknown() and not pt.is_palette()
/*
* Linear interpolation with low-pass filtering, used for fast downscaling
* on both x and y.
@@ -105,8 +103,8 @@ static inline void linear_lp_sample_x(const GP_Context *src,
*
* The implementation is inspired by imlib2 downscaling algorithm.
*/
-static int interpolate_linear_lp_xy(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
+static int GP_FilterResizeLinearLFInt_{{ pt.name }}_Raw(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
{
uint32_t xmap[dst->w + 1];
uint32_t ymap[dst->h + 1];
@@ -114,7 +112,8 @@ static int interpolate_linear_lp_xy(const GP_Context *src, GP_Context *dst,
uint16_t yoff[dst->h + 1];
uint32_t x, y;
uint32_t i, j;
-
+ GP_Pixel pix;
+
/* Pre-compute mapping for interpolation */
uint32_t xstep = ((src->w - 1) << 16) / (dst->w - 1);
uint32_t xpix_dist = ((dst->w - 1) << 14) / (src->w - 1);
@@ -137,35 +136,33 @@ static int interpolate_linear_lp_xy(const GP_Context *src, GP_Context *dst,
/* Interpolate */
for (y = 0; y < dst->h; y++) {
for (x = 0; x < dst->w; x++) {
- uint32_t r, g, b;
- uint32_t r1, g1, b1;
+ %% for c in pt.chanslist
+ uint32_t {{ c[0] }}, {{ c[0] }}1;
+ %% endfor
+
uint32_t x0, y0;
x0 = xmap[x];
y0 = ymap[y];
- linear_lp_sample_x(src, x0, y0,
- xpix_dist, xoff[x],
- &r, &g, &b);
+ {{ sample_x(pt, '') }}
+
+ %% for c in pt.chanslist
+ {{ c[0] }} = ({{ c[0] }} * yoff[y]) >> 14;
+ %% endfor
- r = (r * yoff[y]) >> 14;
- g = (g * yoff[y]) >> 14;
- b = (b * yoff[y]) >> 14;
-
for (j = (1<<14) - yoff[y]; j > ypix_dist; j -= ypix_dist) {
x0 = xmap[x];
if (y0 < src->h - 1)
y0++;
-
- linear_lp_sample_x(src, x0, y0,
- xpix_dist, xoff[x],
- &r1, &g1, &b1);
+
+ {{ sample_x(pt, '1') }}
- r += (r1 * ypix_dist) >> 14;
- g += (g1 * ypix_dist) >> 14;
- b += (b1 * ypix_dist) >> 14;
+ %% for c in pt.chanslist
+ {{ c[0] }} += ({{ c[0] }}1 * ypix_dist) >> 14;
+ %% endfor
}
if (j > 0) {
@@ -173,22 +170,20 @@ static int interpolate_linear_lp_xy(const GP_Context *src, GP_Context *dst,
if (y0 < src->h - 1)
y0++;
-
- linear_lp_sample_x(src, x0, y0,
- xpix_dist, xoff[x],
- &r1, &g1, &b1);
- r += (r1 * j) >> 14;
- g += (g1 * j) >> 14;
- b += (b1 * j) >> 14;
- }
+ {{ sample_x(pt, '1') }}
- r = (r + (1<<4))>>5;
- g = (g + (1<<4))>>5;
- b = (b + (1<<4))>>5;
+ %% for c in pt.chanslist
+ {{ c[0] }} += ({{ c[0] }}1 * j) >> 14;
+ %% endfor
+ }
- GP_PutPixel_Raw_24BPP(dst, x, y,
- GP_Pixel_CREATE_RGB888(r, g, b));
+ %% for c in pt.chanslist
+ {{ c[0] }} = ({{ c[0] }} + (1<<4))>>5;
+ %% endfor
+
+ GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y,
+ GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "") }}));
}
if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
@@ -198,6 +193,8 @@ static int interpolate_linear_lp_xy(const GP_Context *src, GP_Context *dst,
GP_ProgressCallbackDone(callback);
return 0;
}
+%% endif
+%% endfor
%% for pt in pixeltypes
%% if not pt.is_unknown() and not pt.is_palette()
@@ -319,13 +316,20 @@ int GP_FilterResizeLinearLFInt_Raw(const GP_Context *src, GP_Context *dst,
if (x_rat < 1.00 && y_rat < 1.00) {
- /* Fix. */
- if (src->pixel_type != GP_PIXEL_RGB888)
- return -1;
-
GP_DEBUG(1, "Downscaling image %ux%u -> %ux%u %2.2f %2.2f",
src->w, src->h, dst->w, dst->h, x_rat, y_rat);
- return interpolate_linear_lp_xy(src, dst, callback);
+
+ switch (src->pixel_type) {
+ %% for pt in pixeltypes
+ %% if not pt.is_unknown() and not pt.is_palette()
+ case GP_PIXEL_{{ pt.name }}:
+ return GP_FilterResizeLinearLFInt_{{ pt.name }}_Raw(src, dst, callback);
+ break;
+ %% endif
+ %% endfor
+ default:
+ return -1;
+ }
}
//TODO: x_rat > 1.00 && y_rat < 1.00
-----------------------------------------------------------------------
Summary of changes:
libs/filters/GP_ResizeLinear.gen.c.t | 128 +++++++++++++++++----------------
1 files changed, 66 insertions(+), 62 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: e596f127b5823f055be5adcca6670be1cfc8b410
by metan 12 Apr '13
by metan 12 Apr '13
12 Apr '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 e596f127b5823f055be5adcca6670be1cfc8b410 (commit)
via 6dd81cb58fa89ccd2c06ff17f16c9e58f79c6769 (commit)
from 88e2e7b22ee4ece7ef3f2b8ae41cdeae8a66c4ac (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/e596f127b5823f055be5adcca6670be1cfc8…
commit e596f127b5823f055be5adcca6670be1cfc8b410
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 12 17:24:31 2013 +0200
build: Update list of exported symbols.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Core_symbols.txt b/build/syms/Core_symbols.txt
index 0dfdb17..c04e144 100644
--- a/build/syms/Core_symbols.txt
+++ b/build/syms/Core_symbols.txt
@@ -1,4 +1,5 @@
GP_PixelTypes
+GP_PixelHasFlags
GP_ContextAlloc
GP_ContextResize
diff --git a/build/syms/Filters_symbols.txt b/build/syms/Filters_symbols.txt
index 8343ae0..f523674 100644
--- a/build/syms/Filters_symbols.txt
+++ b/build/syms/Filters_symbols.txt
@@ -76,8 +76,6 @@ GP_FilterHistogramAlloc
GP_FilterHistogram_Raw
GP_FilterInterpolate_Cubic
-GP_FilterInterpolate_LinearInt
-GP_FilterInterpolate_LinearLFInt
GP_FilterInvert
GP_FilterInvert_Raw
@@ -141,6 +139,14 @@ GP_FilterPoint_Raw
GP_FilterResize
GP_FilterResize_Raw
+GP_FilterResizeLinearInt
+GP_FilterResizeLinearIntAlloc
+GP_FilterResizeLinearInt_Raw
+
+GP_FilterResizeLinearLFInt
+GP_FilterResizeLinearLFIntAlloc
+GP_FilterResizeLinearLFInt_Raw
+
GP_FilterResizeCubicInt
GP_FilterResizeCubicIntAlloc
GP_FilterResizeCubicInt_Raw
http://repo.or.cz/w/gfxprim.git/commit/6dd81cb58fa89ccd2c06ff17f16c9e58f79c…
commit 6dd81cb58fa89ccd2c06ff17f16c9e58f79c6769
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 12 16:35:38 2013 +0200
all: Add mising GPL headers.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Blit.h b/include/core/GP_Blit.h
index cacfa8b..693d73b 100644
--- a/include/core/GP_Blit.h
+++ b/include/core/GP_Blit.h
@@ -17,7 +17,7 @@
* Boston, MA 02110-1301 USA *
* *
* Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * Copyright (C) 2011,2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2011-2012 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 760eb74..4672708 100644
--- a/include/core/GP_Convert.gen.h.t
+++ b/include/core/GP_Convert.gen.h.t
@@ -1,8 +1,30 @@
+/*****************************************************************************
+ * 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) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.h.t"
{% block descr %}Convert PixelType values macros and functions{% endblock %}
-
%% macro GP_Pixel_TYPE_TO_TYPE(pt1, pt2)
/*** {{ pt1.name }} -> {{ pt2.name }} ***
* macro reads p1 ({{ pt1.name }} at bit-offset o1)
diff --git a/include/core/GP_Convert_Scale.gen.h.t b/include/core/GP_Convert_Scale.gen.h.t
index a7dae41..db3373b 100644
--- a/include/core/GP_Convert_Scale.gen.h.t
+++ b/include/core/GP_Convert_Scale.gen.h.t
@@ -1,3 +1,26 @@
+/*****************************************************************************
+ * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * Copyright (C) 2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.h.t"
{% block descr %}Fast value scaling macros{% endblock %}
diff --git a/include/core/GP_FnPerBpp.gen.h.t b/include/core/GP_FnPerBpp.gen.h.t
index 13a1f84..a53fbd5 100644
--- a/include/core/GP_FnPerBpp.gen.h.t
+++ b/include/core/GP_FnPerBpp.gen.h.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * 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) 2011-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends 'base.h.t'
{% block description %}All FnPerBpp macros{% endblock %}
diff --git a/include/core/GP_GammaCorrection.gen.h.t b/include/core/GP_GammaCorrection.gen.h.t
index b2d0b26..76df078 100644
--- a/include/core/GP_GammaCorrection.gen.h.t
+++ b/include/core/GP_GammaCorrection.gen.h.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.h.t"
{% block descr %}Gamma corrections.{% endblock %}
diff --git a/include/core/GP_GammaPixel.gen.h.t b/include/core/GP_GammaPixel.gen.h.t
index 3c8f832..cefb5cc 100644
--- a/include/core/GP_GammaPixel.gen.h.t
+++ b/include/core/GP_GammaPixel.gen.h.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.h.t"
{% block descr %}Gamma correction for pixels.{% endblock %}
diff --git a/include/core/GP_GetPutPixel.gen.h.t b/include/core/GP_GetPutPixel.gen.h.t
index f04ea33..46325db 100644
--- a/include/core/GP_GetPutPixel.gen.h.t
+++ b/include/core/GP_GetPutPixel.gen.h.t
@@ -1,3 +1,26 @@
+/*****************************************************************************
+ * 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) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.h.t"
%% block descr
diff --git a/include/core/GP_MixPixels.gen.h.t b/include/core/GP_MixPixels.gen.h.t
index 67fdf31..41e9c3a 100644
--- a/include/core/GP_MixPixels.gen.h.t
+++ b/include/core/GP_MixPixels.gen.h.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * 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) 2011-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.h.t"
%% block descr
diff --git a/include/core/GP_Pixel.gen.h.t b/include/core/GP_Pixel.gen.h.t
index a71c461..f0bddab 100644
--- a/include/core/GP_Pixel.gen.h.t
+++ b/include/core/GP_Pixel.gen.h.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.h.t"
%% block descr
diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t
index 0216cfc..d743fc4 100644
--- a/libs/core/GP_Blit.gen.c.t
+++ b/libs/core/GP_Blit.gen.c.t
@@ -1,3 +1,26 @@
+/*****************************************************************************
+ * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * Copyright (C) 2011-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
{% block descr %}Specialized blit functions and macros.{% endblock %}
diff --git a/libs/core/GP_Convert.gen.c.t b/libs/core/GP_Convert.gen.c.t
index 86560b5..ef004e4 100644
--- a/libs/core/GP_Convert.gen.c.t
+++ b/libs/core/GP_Convert.gen.c.t
@@ -1,3 +1,26 @@
+/*****************************************************************************
+ * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * Copyright (C) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
{% block descr %}Convert PixelType values macros and functions{% endblock %}
diff --git a/libs/core/GP_GammaCorrection.gen.c.t b/libs/core/GP_GammaCorrection.gen.c.t
index 4b1a23e..72883b2 100644
--- a/libs/core/GP_GammaCorrection.gen.c.t
+++ b/libs/core/GP_GammaCorrection.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
{% block descr %}Gamma correction tables for Gamma = 2.2{% endblock %}
diff --git a/libs/core/GP_WritePixel.c b/libs/core/GP_WritePixel.c
index 0cd1cc7..e80d1e8 100644
--- a/libs/core/GP_WritePixel.c
+++ b/libs/core/GP_WritePixel.c
@@ -343,7 +343,6 @@ void GP_WritePixels_4BPP_BE(void *start, uint8_t off,
void GP_WritePixels_8BPP(void *start, size_t count, unsigned int value)
{
-
memset(start, value, count);
}
diff --git a/libs/filters/GP_Addition.gen.c.t b/libs/filters/GP_Addition.gen.c.t
index f89ebd4..fa58da6 100644
--- a/libs/filters/GP_Addition.gen.c.t
+++ b/libs/filters/GP_Addition.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.arithmetic.c.t"
%% block descr
diff --git a/libs/filters/GP_Brightness.gen.c.t b/libs/filters/GP_Brightness.gen.c.t
index 7db0fd5..2a02268 100644
--- a/libs/filters/GP_Brightness.gen.c.t
+++ b/libs/filters/GP_Brightness.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * 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) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.point.c.t"
%% block descr
diff --git a/libs/filters/GP_Contrast.gen.c.t b/libs/filters/GP_Contrast.gen.c.t
index dda0b2d..c8dae6f 100644
--- a/libs/filters/GP_Contrast.gen.c.t
+++ b/libs/filters/GP_Contrast.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * 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) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.point.c.t"
%% block descr
diff --git a/libs/filters/GP_Difference.gen.c.t b/libs/filters/GP_Difference.gen.c.t
index cf60b97..e6df21b 100644
--- a/libs/filters/GP_Difference.gen.c.t
+++ b/libs/filters/GP_Difference.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.arithmetic.c.t"
%% block descr
diff --git a/libs/filters/GP_HilbertPeano.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t
index f718105..37a79d7 100644
--- a/libs/filters/GP_HilbertPeano.gen.c.t
+++ b/libs/filters/GP_HilbertPeano.gen.c.t
@@ -1,4 +1,3 @@
-
/*****************************************************************************
* This file is part of gfxprim library. *
* *
diff --git a/libs/filters/GP_Invert.gen.c.t b/libs/filters/GP_Invert.gen.c.t
index ed4ce98..ef9598e 100644
--- a/libs/filters/GP_Invert.gen.c.t
+++ b/libs/filters/GP_Invert.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * 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) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.point.c.t"
%% block descr
diff --git a/libs/filters/GP_Max.gen.c.t b/libs/filters/GP_Max.gen.c.t
index 6e8813d..9cbd2b8 100644
--- a/libs/filters/GP_Max.gen.c.t
+++ b/libs/filters/GP_Max.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.arithmetic.c.t"
%% block descr
diff --git a/libs/filters/GP_Min.gen.c.t b/libs/filters/GP_Min.gen.c.t
index b27d303..99c5dd9 100644
--- a/libs/filters/GP_Min.gen.c.t
+++ b/libs/filters/GP_Min.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.arithmetic.c.t"
%% block descr
diff --git a/libs/filters/GP_Multiply.gen.c.t b/libs/filters/GP_Multiply.gen.c.t
index 3bfe7a3..01d33c3 100644
--- a/libs/filters/GP_Multiply.gen.c.t
+++ b/libs/filters/GP_Multiply.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.arithmetic.c.t"
%% block descr
diff --git a/libs/filters/GP_Noise.gen.c.t b/libs/filters/GP_Noise.gen.c.t
index 7afca65..e48d72c 100644
--- a/libs/filters/GP_Noise.gen.c.t
+++ b/libs/filters/GP_Noise.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * 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) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.point.c.t"
{% block descr %}Noise filter -- Adds noise to an image.{% endblock %}
diff --git a/libs/filters/GP_Point.gen.c.t b/libs/filters/GP_Point.gen.c.t
index 1e9af26..74c96b2 100644
--- a/libs/filters/GP_Point.gen.c.t
+++ b/libs/filters/GP_Point.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * 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) 2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "filter.point.c.t"
%% block descr
-----------------------------------------------------------------------
Summary of changes:
build/syms/Core_symbols.txt | 1 +
build/syms/Filters_symbols.txt | 10 ++++++++--
include/core/GP_Blit.h | 2 +-
include/core/GP_Convert.gen.h.t | 24 +++++++++++++++++++++++-
include/core/GP_Convert_Scale.gen.h.t | 23 +++++++++++++++++++++++
include/core/GP_FnPerBpp.gen.h.t | 22 ++++++++++++++++++++++
include/core/GP_GammaCorrection.gen.h.t | 22 ++++++++++++++++++++++
include/core/GP_GammaPixel.gen.h.t | 22 ++++++++++++++++++++++
include/core/GP_GetPutPixel.gen.h.t | 23 +++++++++++++++++++++++
include/core/GP_MixPixels.gen.h.t | 22 ++++++++++++++++++++++
include/core/GP_Pixel.gen.h.t | 22 ++++++++++++++++++++++
libs/core/GP_Blit.gen.c.t | 23 +++++++++++++++++++++++
libs/core/GP_Convert.gen.c.t | 23 +++++++++++++++++++++++
libs/core/GP_GammaCorrection.gen.c.t | 22 ++++++++++++++++++++++
libs/core/GP_WritePixel.c | 1 -
libs/filters/GP_Addition.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_Brightness.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_Contrast.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_Difference.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_HilbertPeano.gen.c.t | 1 -
libs/filters/GP_Invert.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_Max.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_Min.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_Multiply.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_Noise.gen.c.t | 22 ++++++++++++++++++++++
libs/filters/GP_Point.gen.c.t | 22 ++++++++++++++++++++++
26 files changed, 477 insertions(+), 6 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 88e2e7b22ee4ece7ef3f2b8ae41cdeae8a66c4ac
by metan 11 Apr '13
by metan 11 Apr '13
11 Apr '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 88e2e7b22ee4ece7ef3f2b8ae41cdeae8a66c4ac (commit)
via 1fa7dec70246aaa6e693baa3598e6cf8f46669ca (commit)
from c5577daf85d4668a1599d1131d5539b56108e188 (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/88e2e7b22ee4ece7ef3f2b8ae41cdeae8a66…
commit 88e2e7b22ee4ece7ef3f2b8ae41cdeae8a66c4ac
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Apr 11 19:15:49 2013 +0200
filters: ResizeLinear: Templatize linear downsampling.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/filters/GP_Resize.c b/libs/filters/GP_Resize.c
index 022ba99..8641321 100644
--- a/libs/filters/GP_Resize.c
+++ b/libs/filters/GP_Resize.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> *
* *
*****************************************************************************/
@@ -88,6 +88,63 @@ GP_Context *GP_FilterResizeCubicIntAlloc(const GP_Context *src,
return res;
}
+/* See GP_ResizeLinear.gen.c */
+int GP_FilterResizeLinearInt_Raw(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+int GP_FilterResizeLinearLFInt_Raw(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+int GP_FilterResizeLinearInt(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ GP_ASSERT(src->pixel_type == dst->pixel_type);
+
+ return GP_FilterResizeLinearInt_Raw(src, dst, callback);
+}
+
+int GP_FilterResizeLinearLFInt(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ GP_ASSERT(src->pixel_type == dst->pixel_type);
+
+ return GP_FilterResizeLinearInt_Raw(src, dst, callback);
+}
+
+GP_Context *GP_FilterResizeLinearIntAlloc(const GP_Context *src,
+ GP_Size w, GP_Size h,
+ GP_ProgressCallback *callback)
+{
+ GP_Context *res = GP_ContextAlloc(w, h, src->pixel_type);
+
+ if (res == NULL)
+ return NULL;
+
+ if (GP_FilterResizeCubicInt_Raw(src, res, callback)) {
+ GP_ContextFree(res);
+ return NULL;
+ }
+
+ return res;
+}
+
+GP_Context *GP_FilterResizeLinearLFIntAlloc(const GP_Context *src,
+ GP_Size w, GP_Size h,
+ GP_ProgressCallback *callback)
+{
+ GP_Context *res = GP_ContextAlloc(w, h, src->pixel_type);
+
+ if (res == NULL)
+ return NULL;
+
+ if (GP_FilterResizeLinearLFInt_Raw(src, res, callback)) {
+ GP_ContextFree(res);
+ return NULL;
+ }
+
+ return res;
+}
+
static const char *interp_types[] = {
"Nearest Neighbour",
"Linear (Int)",
@@ -155,6 +212,9 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst,
float col_r[src->h], col_g[src->h], col_b[src->h];
uint32_t i, j;
+ if (src->pixel_type != GP_PIXEL_RGB888)
+ return 1;
+
GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f",
src->w, src->h, dst->w, dst->h,
1.00 * dst->w / src->w, 1.00 * dst->h / src->h);
@@ -282,275 +342,6 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst,
return 0;
}
-/*
- * Sample row.
- *
- * The x and y are starting coordinates in source image.
- *
- * The xpix_dist is distance of two sampled pixels in source image coordinates.
- *
- * The xoff is offset of the first pixel.
- *
- * The r, g, b are used to store resulting values.
- */
-static inline void linear_lp_sample_x(const GP_Context *src,
- uint32_t x, uint32_t y,
- uint32_t xpix_dist, uint32_t xoff,
- uint32_t *r, uint32_t *g, uint32_t *b)
-{
- GP_Pixel pix;
- uint32_t i;
-
- pix = GP_GetPixel_Raw_24BPP(src, x, y);
-
- *r = (GP_Pixel_GET_R_RGB888(pix) * xoff) >> 9;
- *g = (GP_Pixel_GET_G_RGB888(pix) * xoff) >> 9;
- *b = (GP_Pixel_GET_B_RGB888(pix) * xoff) >> 9;
-
- for (i = (1<<14) - xoff; i > xpix_dist; i -= xpix_dist) {
- if (x < src->w - 1)
- x++;
-
- pix = GP_GetPixel_Raw_24BPP(src, x, y);
-
- *r += (GP_Pixel_GET_R_RGB888(pix) * xpix_dist) >> 9;
- *g += (GP_Pixel_GET_G_RGB888(pix) * xpix_dist) >> 9;
- *b += (GP_Pixel_GET_B_RGB888(pix) * xpix_dist) >> 9;
- }
-
- if (i > 0) {
- if (x < src->w - 1)
- x++;
-
- pix = GP_GetPixel_Raw_24BPP(src, x, y);
-
- *r += (GP_Pixel_GET_R_RGB888(pix) * i) >> 9;
- *g += (GP_Pixel_GET_G_RGB888(pix) * i) >> 9;
- *b += (GP_Pixel_GET_B_RGB888(pix) * i) >> 9;
- }
-}
-
-/*
- * Linear interpolation with low-pass filtering, used for fast downscaling
- * on both x and y.
- *
- * Basically we do weighted arithmetic mean of the pixels:
- *
- * [x, y], [x + 1, y], [x + 2, y] ... [x + k, y]
- * [x, y + 1]
- * [x, y + 2] .
- * . . .
- * . . .
- * . .
- * [x, y + l] .... [x + k, y + l]
- *
- *
- * The parameter k respectively l is determined by the distance between
- * sampled coordinates on x respectively y.
- *
- * The pixels are weighted by how much they are 'hit' by the rectangle defined
- * by the sampled pixel.
- *
- * The implementation is inspired by imlib2 downscaling algorithm.
- */
-static int interpolate_linear_lp_xy(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- uint32_t xmap[dst->w + 1];
- uint32_t ymap[dst->h + 1];
- uint16_t xoff[dst->w + 1];
- uint16_t yoff[dst->h + 1];
- uint32_t x, y;
- uint32_t i, j;
-
- /* Pre-compute mapping for interpolation */
- uint32_t xstep = ((src->w - 1) << 16) / (dst->w - 1);
- uint32_t xpix_dist = ((dst->w - 1) << 14) / (src->w - 1);
-
- for (i = 0; i < dst->w + 1; i++) {
- uint32_t val = i * xstep;
- xmap[i] = val >> 16;
- xoff[i] = ((255 - ((val >> 8) & 0xff)) * xpix_dist)>>8;
- }
-
- uint32_t ystep = ((src->h - 1) << 16) / (dst->h - 1);
- uint32_t ypix_dist = ((dst->h - 1) << 14) / (src->h - 1);
-
- for (i = 0; i < dst->h + 1; i++) {
- uint32_t val = i * ystep;
- ymap[i] = val >> 16;
- yoff[i] = ((255 - ((val >> 8) & 0xff)) * ypix_dist)>>8;
- }
-
- /* Interpolate */
- for (y = 0; y < dst->h; y++) {
- for (x = 0; x < dst->w; x++) {
- uint32_t r, g, b;
- uint32_t r1, g1, b1;
- uint32_t x0, y0;
-
- x0 = xmap[x];
- y0 = ymap[y];
-
- linear_lp_sample_x(src, x0, y0,
- xpix_dist, xoff[x],
- &r, &g, &b);
-
- r = (r * yoff[y]) >> 14;
- g = (g * yoff[y]) >> 14;
- b = (b * yoff[y]) >> 14;
-
- for (j = (1<<14) - yoff[y]; j > ypix_dist; j -= ypix_dist) {
-
- x0 = xmap[x];
-
- if (y0 < src->h - 1)
- y0++;
-
- linear_lp_sample_x(src, x0, y0,
- xpix_dist, xoff[x],
- &r1, &g1, &b1);
-
- r += (r1 * ypix_dist) >> 14;
- g += (g1 * ypix_dist) >> 14;
- b += (b1 * ypix_dist) >> 14;
- }
-
- if (j > 0) {
- x0 = xmap[x];
-
- if (y0 < src->h - 1)
- y0++;
-
- linear_lp_sample_x(src, x0, y0,
- xpix_dist, xoff[x],
- &r1, &g1, &b1);
-
- r += (r1 * j) >> 14;
- g += (g1 * j) >> 14;
- b += (b1 * j) >> 14;
- }
-
- r = (r + (1<<4))>>5;
- g = (g + (1<<4))>>5;
- b = (b + (1<<4))>>5;
-
- GP_PutPixel_Raw_24BPP(dst, x, y,
- GP_Pixel_CREATE_RGB888(r, g, b));
- }
-
- if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
- return 1;
- }
-
- GP_ProgressCallbackDone(callback);
- return 0;
-}
-
-int GP_FilterInterpolate_LinearInt(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- uint32_t xmap[dst->w + 1];
- uint32_t ymap[dst->h + 1];
- uint8_t xoff[dst->w + 1];
- uint8_t yoff[dst->h + 1];
- uint32_t x, y, i;
-
- GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f",
- src->w, src->h, dst->w, dst->h,
- 1.00 * dst->w / src->w, 1.00 * dst->h / src->h);
-
- /* Pre-compute mapping for interpolation */
- uint32_t xstep = ((src->w - 1) << 16) / (dst->w - 1);
-
- for (i = 0; i < dst->w + 1; i++) {
- uint32_t val = i * xstep;
- xmap[i] = val >> 16;
- xoff[i] = (val >> 8) & 0xff;
- }
-
- uint32_t ystep = ((src->h - 1) << 16) / (dst->h - 1);
-
- for (i = 0; i < dst->h + 1; i++) {
- uint32_t val = i * ystep;
- ymap[i] = val >> 16;
- yoff[i] = (val >> 8) & 0xff;
- }
-
- /* Interpolate */
- for (y = 0; y < dst->h; y++) {
- for (x = 0; x < dst->w; x++) {
- GP_Pixel pix00, pix01, pix10, pix11;
- uint32_t r0, r1, g0, g1, b0, b1;
- GP_Coord x0, x1, y0, y1;
-
- x0 = xmap[x];
- x1 = xmap[x] + 1;
-
- if (x1 >= (GP_Coord)src->w)
- x1 = src->w - 1;
-
- y0 = ymap[y];
- y1 = ymap[y] + 1;
-
- if (y1 >= (GP_Coord)src->h)
- y1 = src->h - 1;
-
- pix00 = GP_GetPixel_Raw_24BPP(src, x0, y0);
- pix10 = GP_GetPixel_Raw_24BPP(src, x1, y0);
- pix01 = GP_GetPixel_Raw_24BPP(src, x0, y1);
- pix11 = GP_GetPixel_Raw_24BPP(src, x1, y1);
-
- r0 = GP_Pixel_GET_R_RGB888(pix00) * (255 - xoff[x]);
- g0 = GP_Pixel_GET_G_RGB888(pix00) * (255 - xoff[x]);
- b0 = GP_Pixel_GET_B_RGB888(pix00) * (255 - xoff[x]);
-
- r0 += GP_Pixel_GET_R_RGB888(pix10) * xoff[x];
- g0 += GP_Pixel_GET_G_RGB888(pix10) * xoff[x];
- b0 += GP_Pixel_GET_B_RGB888(pix10) * xoff[x];
-
- r1 = GP_Pixel_GET_R_RGB888(pix01) * (255 - xoff[x]);
- g1 = GP_Pixel_GET_G_RGB888(pix01) * (255 - xoff[x]);
- b1 = GP_Pixel_GET_B_RGB888(pix01) * (255 - xoff[x]);
-
- r1 += GP_Pixel_GET_R_RGB888(pix11) * xoff[x];
- g1 += GP_Pixel_GET_G_RGB888(pix11) * xoff[x];
- b1 += GP_Pixel_GET_B_RGB888(pix11) * xoff[x];
-
- r0 = (r1 * yoff[y] + r0 * (255 - yoff[y]) + (1<<15)) >> 16;
- g0 = (g1 * yoff[y] + g0 * (255 - yoff[y]) + (1<<15)) >> 16;
- b0 = (b1 * yoff[y] + b0 * (255 - yoff[y]) + (1<<15)) >> 16;
-
- GP_PutPixel_Raw_24BPP(dst, x, y,
- GP_Pixel_CREATE_RGB888(r0, g0, b0));
- }
-
- if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
- return 1;
- }
-
- GP_ProgressCallbackDone(callback);
- return 0;
-}
-
-int GP_FilterInterpolate_LinearLFInt(const GP_Context *src, GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- float x_rat = 1.00 * dst->w / src->w;
- float y_rat = 1.00 * dst->h / src->h;
-
- if (x_rat < 1.00 && y_rat < 1.00) {
- GP_DEBUG(1, "Downscaling image %ux%u -> %ux%u %2.2f %2.2f",
- src->w, src->h, dst->w, dst->h, x_rat, y_rat);
- return interpolate_linear_lp_xy(src, dst, callback);
- }
-
- //TODO: x_rat > 1.00 && y_rat < 1.00
- //TODO: x_rat < 1.00 && y_rat > 1.00
-
- return GP_FilterInterpolate_LinearInt(src, dst, callback);
-}
-
int GP_FilterResize_Raw(const GP_Context *src, GP_Context *dst,
GP_InterpolationType type,
GP_ProgressCallback *callback)
@@ -559,9 +350,9 @@ int GP_FilterResize_Raw(const GP_Context *src, GP_Context *dst,
case GP_INTERP_NN:
return GP_FilterResizeNN_Raw(src, dst, callback);
case GP_INTERP_LINEAR_INT:
- return GP_FilterInterpolate_LinearInt(src, dst, callback);
+ return GP_FilterResizeLinearInt_Raw(src, dst, callback);
case GP_INTERP_LINEAR_LF_INT:
- return GP_FilterInterpolate_LinearLFInt(src, dst, callback);
+ return GP_FilterResizeLinearLFInt_Raw(src, dst, callback);
case GP_INTERP_CUBIC:
return GP_FilterInterpolate_Cubic(src, dst, callback);
case GP_INTERP_CUBIC_INT:
@@ -578,10 +369,6 @@ GP_Context *GP_FilterResize(const GP_Context *src, GP_Context *dst,
{
GP_Context sub, *res;
- /* TODO: Templatize */
- if (src->pixel_type != GP_PIXEL_RGB888)
- return NULL;
-
if (dst == NULL) {
res = GP_ContextAlloc(w, h, src->pixel_type);
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t
new file mode 100644
index 0000000..d5ccd6d
--- /dev/null
+++ b/libs/filters/GP_ResizeLinear.gen.c.t
@@ -0,0 +1,337 @@
+/*****************************************************************************
+ * 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 "filter.c.t"
+
+{% block descr %}Linear resampling{% endblock %}
+
+%% block body
+
+#include "core/GP_Context.h"
+#include "core/GP_GetPutPixel.h"
+#include "core/GP_Gamma.h"
+
+#include "core/GP_Debug.h"
+
+#include "GP_Resize.h"
+
+/*
+ * Sample row.
+ *
+ * The x and y are starting coordinates in source image.
+ *
+ * The xpix_dist is distance of two sampled pixels in source image coordinates.
+ *
+ * The xoff is offset of the first pixel.
+ *
+ * The r, g, b are used to store resulting values.
+ */
+static inline void linear_lp_sample_x(const GP_Context *src,
+ uint32_t x, uint32_t y,
+ uint32_t xpix_dist, uint32_t xoff,
+ uint32_t *r, uint32_t *g, uint32_t *b)
+{
+ GP_Pixel pix;
+ uint32_t i;
+
+ pix = GP_GetPixel_Raw_24BPP(src, x, y);
+
+ *r = (GP_Pixel_GET_R_RGB888(pix) * xoff) >> 9;
+ *g = (GP_Pixel_GET_G_RGB888(pix) * xoff) >> 9;
+ *b = (GP_Pixel_GET_B_RGB888(pix) * xoff) >> 9;
+
+ for (i = (1<<14) - xoff; i > xpix_dist; i -= xpix_dist) {
+ if (x < src->w - 1)
+ x++;
+
+ pix = GP_GetPixel_Raw_24BPP(src, x, y);
+
+ *r += (GP_Pixel_GET_R_RGB888(pix) * xpix_dist) >> 9;
+ *g += (GP_Pixel_GET_G_RGB888(pix) * xpix_dist) >> 9;
+ *b += (GP_Pixel_GET_B_RGB888(pix) * xpix_dist) >> 9;
+ }
+
+ if (i > 0) {
+ if (x < src->w - 1)
+ x++;
+
+ pix = GP_GetPixel_Raw_24BPP(src, x, y);
+
+ *r += (GP_Pixel_GET_R_RGB888(pix) * i) >> 9;
+ *g += (GP_Pixel_GET_G_RGB888(pix) * i) >> 9;
+ *b += (GP_Pixel_GET_B_RGB888(pix) * i) >> 9;
+ }
+}
+
+/*
+ * Linear interpolation with low-pass filtering, used for fast downscaling
+ * on both x and y.
+ *
+ * Basically we do weighted arithmetic mean of the pixels:
+ *
+ * [x, y], [x + 1, y], [x + 2, y] ... [x + k, y]
+ * [x, y + 1]
+ * [x, y + 2] .
+ * . . .
+ * . . .
+ * . .
+ * [x, y + l] .... [x + k, y + l]
+ *
+ *
+ * The parameter k respectively l is determined by the distance between
+ * sampled coordinates on x respectively y.
+ *
+ * The pixels are weighted by how much they are 'hit' by the rectangle defined
+ * by the sampled pixel.
+ *
+ * The implementation is inspired by imlib2 downscaling algorithm.
+ */
+static int interpolate_linear_lp_xy(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ uint32_t xmap[dst->w + 1];
+ uint32_t ymap[dst->h + 1];
+ uint16_t xoff[dst->w + 1];
+ uint16_t yoff[dst->h + 1];
+ uint32_t x, y;
+ uint32_t i, j;
+
+ /* Pre-compute mapping for interpolation */
+ uint32_t xstep = ((src->w - 1) << 16) / (dst->w - 1);
+ uint32_t xpix_dist = ((dst->w - 1) << 14) / (src->w - 1);
+
+ for (i = 0; i < dst->w + 1; i++) {
+ uint32_t val = i * xstep;
+ xmap[i] = val >> 16;
+ xoff[i] = ((255 - ((val >> 8) & 0xff)) * xpix_dist)>>8;
+ }
+
+ uint32_t ystep = ((src->h - 1) << 16) / (dst->h - 1);
+ uint32_t ypix_dist = ((dst->h - 1) << 14) / (src->h - 1);
+
+ for (i = 0; i < dst->h + 1; i++) {
+ uint32_t val = i * ystep;
+ ymap[i] = val >> 16;
+ yoff[i] = ((255 - ((val >> 8) & 0xff)) * ypix_dist)>>8;
+ }
+
+ /* Interpolate */
+ for (y = 0; y < dst->h; y++) {
+ for (x = 0; x < dst->w; x++) {
+ uint32_t r, g, b;
+ uint32_t r1, g1, b1;
+ uint32_t x0, y0;
+
+ x0 = xmap[x];
+ y0 = ymap[y];
+
+ linear_lp_sample_x(src, x0, y0,
+ xpix_dist, xoff[x],
+ &r, &g, &b);
+
+ r = (r * yoff[y]) >> 14;
+ g = (g * yoff[y]) >> 14;
+ b = (b * yoff[y]) >> 14;
+
+ for (j = (1<<14) - yoff[y]; j > ypix_dist; j -= ypix_dist) {
+
+ x0 = xmap[x];
+
+ if (y0 < src->h - 1)
+ y0++;
+
+ linear_lp_sample_x(src, x0, y0,
+ xpix_dist, xoff[x],
+ &r1, &g1, &b1);
+
+ r += (r1 * ypix_dist) >> 14;
+ g += (g1 * ypix_dist) >> 14;
+ b += (b1 * ypix_dist) >> 14;
+ }
+
+ if (j > 0) {
+ x0 = xmap[x];
+
+ if (y0 < src->h - 1)
+ y0++;
+
+ linear_lp_sample_x(src, x0, y0,
+ xpix_dist, xoff[x],
+ &r1, &g1, &b1);
+
+ r += (r1 * j) >> 14;
+ g += (g1 * j) >> 14;
+ b += (b1 * j) >> 14;
+ }
+
+ r = (r + (1<<4))>>5;
+ g = (g + (1<<4))>>5;
+ b = (b + (1<<4))>>5;
+
+ GP_PutPixel_Raw_24BPP(dst, x, y,
+ GP_Pixel_CREATE_RGB888(r, g, b));
+ }
+
+ if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
+ return 1;
+ }
+
+ GP_ProgressCallbackDone(callback);
+ return 0;
+}
+
+%% for pt in pixeltypes
+%% if not pt.is_unknown() and not pt.is_palette()
+
+static int GP_FilterResizeLinearInt_{{ pt.name }}_Raw(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ uint32_t xmap[dst->w + 1];
+ uint32_t ymap[dst->h + 1];
+ uint8_t xoff[dst->w + 1];
+ uint8_t yoff[dst->h + 1];
+ uint32_t x, y, i;
+
+ GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f",
+ src->w, src->h, dst->w, dst->h,
+ 1.00 * dst->w / src->w, 1.00 * dst->h / src->h);
+
+ /* Pre-compute mapping for interpolation */
+ uint32_t xstep = ((src->w - 1) << 16) / (dst->w - 1);
+
+ for (i = 0; i < dst->w + 1; i++) {
+ uint32_t val = i * xstep;
+ xmap[i] = val >> 16;
+ xoff[i] = (val >> 8) & 0xff;
+ }
+
+ uint32_t ystep = ((src->h - 1) << 16) / (dst->h - 1);
+
+ for (i = 0; i < dst->h + 1; i++) {
+ uint32_t val = i * ystep;
+ ymap[i] = val >> 16;
+ yoff[i] = (val >> 8) & 0xff;
+ }
+
+ /* Interpolate */
+ for (y = 0; y < dst->h; y++) {
+ for (x = 0; x < dst->w; x++) {
+ GP_Pixel pix00, pix01, pix10, pix11;
+ GP_Coord x0, x1, y0, y1;
+ %% for c in pt.chanslist
+ uint32_t {{ c[0] }}, {{ c[0] }}0, {{ c[0] }}1;
+ %% endfor
+
+ x0 = xmap[x];
+ x1 = xmap[x] + 1;
+
+ if (x1 >= (GP_Coord)src->w)
+ x1 = src->w - 1;
+
+ y0 = ymap[y];
+ y1 = ymap[y] + 1;
+
+ if (y1 >= (GP_Coord)src->h)
+ y1 = src->h - 1;
+
+ pix00 = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x0, y0);
+ pix10 = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x1, y0);
+ pix01 = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x0, y1);
+ pix11 = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x1, y1);
+
+ %% for c in pt.chanslist
+ {{ c[0] }}0 = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix00) * (255 - xoff[x]);
+ %% endfor
+
+ %% for c in pt.chanslist
+ {{ c[0] }}0 += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix10) * xoff[x];
+ %% endfor
+
+ %% for c in pt.chanslist
+ {{ c[0] }}1 = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix01) * (255 - xoff[x]);
+ %% endfor
+
+ %% for c in pt.chanslist
+ {{ c[0] }}1 += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix11) * xoff[x];
+ %% endfor
+
+ %% for c in pt.chanslist
+ {{ c[0] }} = ({{ c[0] }}1 * yoff[y] + {{ c[0] }}0 * (255 - yoff[y]) + (1<<15)) >> 16;
+ %% endfor
+
+ GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y,
+ GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "") }}));
+ }
+
+ if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
+ return 1;
+ }
+
+ GP_ProgressCallbackDone(callback);
+ return 0;
+}
+
+%% endif
+%% endfor
+
+int GP_FilterResizeLinearInt_Raw(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ switch (src->pixel_type) {
+ %% for pt in pixeltypes
+ %% if not pt.is_unknown() and not pt.is_palette()
+ case GP_PIXEL_{{ pt.name }}:
+ return GP_FilterResizeLinearInt_{{ pt.name }}_Raw(src, dst, callback);
+ break;
+ %% endif
+ %% endfor
+ default:
+ return -1;
+ }
+}
+
+int GP_FilterResizeLinearLFInt_Raw(const GP_Context *src, GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ float x_rat = 1.00 * dst->w / src->w;
+ float y_rat = 1.00 * dst->h / src->h;
+
+ printf("%f %fn", x_rat, y_rat);
+
+ if (x_rat < 1.00 && y_rat < 1.00) {
+
+ /* Fix. */
+ if (src->pixel_type != GP_PIXEL_RGB888)
+ return -1;
+
+ GP_DEBUG(1, "Downscaling image %ux%u -> %ux%u %2.2f %2.2f",
+ src->w, src->h, dst->w, dst->h, x_rat, y_rat);
+ return interpolate_linear_lp_xy(src, dst, callback);
+ }
+
+ //TODO: x_rat > 1.00 && y_rat < 1.00
+ //TODO: x_rat < 1.00 && y_rat > 1.00
+
+ return GP_FilterResizeLinearInt_Raw(src, dst, callback);
+}
+
+%% endblock body
diff --git a/libs/filters/Makefile b/libs/filters/Makefile
index 1773151..e331b59 100644
--- a/libs/filters/Makefile
+++ b/libs/filters/Makefile
@@ -9,7 +9,8 @@ POINT_FILTERS=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c GP_Max.gen.c GP_Multiply.gen.c
-RESAMPLING_FILTERS=GP_ResizeNN.gen.c GP_Cubic.gen.c GP_ResizeCubic.gen.c
+RESAMPLING_FILTERS=GP_ResizeNN.gen.c GP_Cubic.gen.c GP_ResizeCubic.gen.c+ GP_ResizeLinear.gen.c
GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_FloydSteinberg.gen.c GP_HilbertPeano.gen.c $(POINT_FILTERS) $(ARITHMETIC_FILTERS) $(STATS_FILTERS) $(RESAMPLING_FILTERS)
http://repo.or.cz/w/gfxprim.git/commit/1fa7dec70246aaa6e693baa3598e6cf8f466…
commit 1fa7dec70246aaa6e693baa3598e6cf8f46669ca
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Apr 11 16:55:14 2013 +0200
spiv: Exit if no images were passed.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 5a92232..fcb7ed5 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -833,7 +833,13 @@ int main(int argc, char *argv[])
return 1;
}
}
-
+
+ if (optind >= argc) {
+ fprintf(stderr, "Requires path to at least one imagenn");
+ print_help();
+ return 1;
+ }
+
GP_SetDebugLevel(debug_level);
signal(SIGINT, sighandler);
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 8 +-
libs/filters/GP_Resize.c | 339 +++++++---------------------------
libs/filters/GP_ResizeLinear.gen.c.t | 337 +++++++++++++++++++++++++++++++++
libs/filters/Makefile | 3 +-
4 files changed, 409 insertions(+), 278 deletions(-)
create mode 100644 libs/filters/GP_ResizeLinear.gen.c.t
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: c5577daf85d4668a1599d1131d5539b56108e188
by metan 11 Apr '13
by metan 11 Apr '13
11 Apr '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 c5577daf85d4668a1599d1131d5539b56108e188 (commit)
via 40d5d39bf35b82553d101497238393b04f86f55e (commit)
from f9ab072d9aeefcd9888506fe0a9f30757c9e9a76 (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/c5577daf85d4668a1599d1131d5539b56108…
commit c5577daf85d4668a1599d1131d5539b56108e188
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Apr 11 16:38:50 2013 +0200
core: Add GP_PixelHasFlags() + tests.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index a60707f..ff2d710 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -91,6 +91,16 @@ typedef struct GP_PixelTypeChannel {
#define GP_PIXELTYPE_MAX_CHANNELS 8
/*
+ * Pixel type flags for various pixel properties.
+ */
+typedef enum GP_PixelFlags {
+ GP_PIXEL_HAS_ALPHA = 0x01,
+ GP_PIXEL_IS_RGB = 0x02,
+ GP_PIXEL_IS_PALETTE = 0x04,
+ GP_PIXEL_IS_GRAYSCALE = 0x10,
+} GP_PixelFlags;
+
+/*
* Description of one PixelType
* Assumes name with at most 15 chars
* Assumes at most 8 channels
@@ -101,6 +111,7 @@ typedef struct GP_PixelTypeDescription {
uint8_t size; /* Size in bits */
GP_BIT_ENDIAN bit_endian; /* Order of pixels in a byte */
uint8_t numchannels; /* Number of channels */
+ GP_PixelFlags flags;
/* String describing the bit-representaton (as in "RRRRRGGGGGGBBBBB")*/
const char bitmap[GP_PIXEL_BITS + 1];
/* Individual channels */
@@ -187,9 +198,13 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
uint8_t bits_per_pixel);
/*
- * Function to determine pixel attributes.
+ * Functions to determine pixel attributes.
+ *
+ * Call as:
+ *
+ * if (GP_PixelHasFlags(pixel_type, GP_PIXEL_IS_RGB | GP_PIXEL_HAS_ALPHA))
+ * ...
*/
-int GP_PixelHasAlpha(GP_PixelType pixel_type);
-
+int GP_PixelHasFlags(GP_PixelType pixel_type, GP_PixelFlags flags);
#endif /* CORE_GP_PIXEL_H */
diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c
index b1ccad5..a210892 100644
--- a/libs/core/GP_Pixel.c
+++ b/libs/core/GP_Pixel.c
@@ -163,15 +163,9 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
return GP_PIXEL_UNKNOWN;
}
-int GP_PixelHasAlpha(GP_PixelType pixel_type)
+int GP_PixelHasFlags(GP_PixelType pixel_type, GP_PixelFlags flags)
{
- unsigned int i;
-
- GP_CHECK_VALID_PIXELTYPE(pixel_type);
-
- for (i = 0; i < GP_PixelTypes[pixel_type].numchannels; i++)
- if (!strcmp(GP_PixelTypes[pixel_type].channels[i].name, "A"))
- return 1;
+ GP_PixelFlags my_flags = GP_PixelTypes[pixel_type].flags;
- return 0;
+ return flags == (my_flags & flags);
}
diff --git a/libs/core/GP_Pixel.gen.c.t b/libs/core/GP_Pixel.gen.c.t
index 8374856..7fad071 100644
--- a/libs/core/GP_Pixel.gen.c.t
+++ b/libs/core/GP_Pixel.gen.c.t
@@ -1,3 +1,26 @@
+/*****************************************************************************
+ * 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) 2011-2012 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * Copyright (C) 2011-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
%% block descr
@@ -9,6 +32,13 @@ Pixel type definitions and functions
#include "GP_Pixel.h"
#include "GP_GetSetBits.h"
+%%- macro getflags(pt)
+{% if pt.is_alpha() %} | GP_PIXEL_HAS_ALPHA{% endif -%}
+{% 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 -%}
+%%- endmacro
+
/*
* Description of all known pixel types
*/
@@ -21,6 +51,7 @@ const GP_PixelTypeDescription const GP_PixelTypes [GP_PIXEL_MAX] = {
.bit_endian = {{ pt.pixelsize.bit_endian_const }},
.numchannels = {{ len(pt.chanslist) }},
.bitmap = "{{ pt.bits|join("") }}",
+ .flags = 0{{ getflags(pt) }},
.channels = {
%% for c in pt.chanslist
{ .name = "{{ c[0] }}", .offset = {{ c[1] }}, .size = {{ c[2] }} },
diff --git a/tests/core/Makefile b/tests/core/Makefile
index 91185c2..757416b 100644
--- a/tests/core/Makefile
+++ b/tests/core/Makefile
@@ -2,11 +2,11 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
-CSOURCES=Context.c
+CSOURCES=Context.c Pixel.c
GENSOURCES+=WritePixel_testsuite.gen.c GetPutPixel.gen.c
-APPS=WritePixel_testsuite.gen Context GetPutPixel.gen
+APPS=WritePixel_testsuite.gen Pixel Context GetPutPixel.gen
include ../tests.mk
diff --git a/tests/core/Pixel.c b/tests/core/Pixel.c
new file mode 100644
index 0000000..e334a16
--- /dev/null
+++ b/tests/core/Pixel.c
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * 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> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ Very basic GP_Pixel tests.
+
+ */
+#include <errno.h>
+
+#include <core/GP_Pixel.h>
+
+#include "tst_test.h"
+
+static int pixel_flags(void)
+{
+ int fail = 0;
+
+ if (!GP_PixelHasFlags(GP_PIXEL_RGB888, GP_PIXEL_IS_RGB)) {
+ tst_msg("RGB888 is RGB failed");
+ fail++;
+ }
+
+ if (GP_PixelHasFlags(GP_PIXEL_G1, GP_PIXEL_IS_RGB)) {
+ tst_msg("G1 is RGB succeeded");
+ fail++;
+ }
+
+ if (!GP_PixelHasFlags(GP_PIXEL_RGBA8888, GP_PIXEL_HAS_ALPHA)) {
+ tst_msg("RGBA8888 has Alpha failed");
+ fail++;
+ }
+
+ if (!GP_PixelHasFlags(GP_PIXEL_RGBA8888,
+ GP_PIXEL_HAS_ALPHA | GP_PIXEL_IS_RGB)) {
+ tst_msg("RGBA8888 has Alpha and is RGB failed");
+ fail++;
+ }
+
+ if (fail)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Pixel Testsuite",
+ .tests = {
+ {.name = "Pixel Flags",
+ .tst_fn = pixel_flags},
+ {.name = NULL},
+ }
+};
diff --git a/tests/core/test_list.txt b/tests/core/test_list.txt
index 458f6e4..c4f6bb7 100644
--- a/tests/core/test_list.txt
+++ b/tests/core/test_list.txt
@@ -1,4 +1,5 @@
# Core testsuite
WritePixel_testsuite.gen
Context
+Pixel
GetPutPixel.gen
http://repo.or.cz/w/gfxprim.git/commit/40d5d39bf35b82553d101497238393b04f86…
commit 40d5d39bf35b82553d101497238393b04f86f55e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Apr 11 14:24:26 2013 +0200
doc: compilation: Add instructions for debian.
Thanks Milan Vancura for the list.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/compilation.txt b/doc/compilation.txt
index 741b878..cb025e0 100644
--- a/doc/compilation.txt
+++ b/doc/compilation.txt
@@ -66,7 +66,7 @@ into your system. Python bindings are not installable at the moment.
OpenSUSE
~~~~~~~~
-Here are commands to install required packages on
+Instruction to install required packages on
link:http://www.opensuse.org/[OpenSUSE].
.Install basic tools
@@ -100,3 +100,39 @@ zypper in gcc make python-Jinja2 libjpeg-devel libpng-devel giflib-devel
freetype-devel libX11-devel libXext-devel swig python-devel
-------------------------------------------------------------------------------
+Debian
+~~~~~~
+
+Instruction to install required packages on link:http://www.debian.org[Debian]
+and other debian based distributions.
+
+.Install basic tools
+-------------------------------------------------------------------------------
+apt-get install gcc make python-jinja2
+-------------------------------------------------------------------------------
+
+.Install jpeg and png devel libraries
+-------------------------------------------------------------------------------
+apt-get install libjpeg-dev libpng-dev libgif-dev
+-------------------------------------------------------------------------------
+
+.Install FreeType devel library
+-------------------------------------------------------------------------------
+apt-get install libfreetype6-dev
+-------------------------------------------------------------------------------
+
+.Install X11 devel library
+-------------------------------------------------------------------------------
+apt-get install libx11-dev libxext-dev
+-------------------------------------------------------------------------------
+
+.Install swig
+-------------------------------------------------------------------------------
+apt-get install swig python-dev
+-------------------------------------------------------------------------------
+
+.All in the one for the lazy
+-------------------------------------------------------------------------------
+apt-get install gcc make python-jinja2 libjpeg-dev libpng-dev libgif-dev
+ libfreetype6-dev libx11-dev libxext-dev swig python-dev
+-------------------------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
doc/compilation.txt | 38 ++++++++++++++-
include/core/GP_Pixel.h | 21 +++++++-
libs/core/GP_Pixel.c | 12 +---
libs/core/GP_Pixel.gen.c.t | 31 ++++++++++++
tests/core/Makefile | 4 +-
tests/{drivers/linux_input.c => core/Pixel.c} | 66 ++++++++++++++-----------
tests/core/test_list.txt | 1 +
7 files changed, 129 insertions(+), 44 deletions(-)
copy tests/{drivers/linux_input.c => core/Pixel.c} (66%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: f9ab072d9aeefcd9888506fe0a9f30757c9e9a76
by metan 10 Apr '13
by metan 10 Apr '13
10 Apr '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 f9ab072d9aeefcd9888506fe0a9f30757c9e9a76 (commit)
via dcb1062650a4926ced12a094a86d0a7590b5f67b (commit)
via 0424a9f874f03edea2f10b52204ef3e6198126cd (commit)
via 71f8dfeb78b75bc456ac761eaf74ea143548561a (commit)
via 882c1204e0a05f9e82e8af79b2959569de0e5399 (commit)
via 91e5cbbaa1e757faac1b3edd9144d749000de97a (commit)
via c53b91525478de6a140d4355da7d62e6957d2727 (commit)
from feff7abe0be63662f56d82aa080f3c7c8be9d194 (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/f9ab072d9aeefcd9888506fe0a9f30757c9e…
commit f9ab072d9aeefcd9888506fe0a9f30757c9e9a76
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Apr 10 17:33:55 2013 +0200
core: Pixel: Add GP_PixelHasAlpha().
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index c9f0ab4..a60707f 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -186,4 +186,10 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
uint32_t asize, uint32_t aoff,
uint8_t bits_per_pixel);
+/*
+ * Function to determine pixel attributes.
+ */
+int GP_PixelHasAlpha(GP_PixelType pixel_type);
+
+
#endif /* CORE_GP_PIXEL_H */
diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c
index b14d5b0..b1ccad5 100644
--- a/libs/core/GP_Pixel.c
+++ b/libs/core/GP_Pixel.c
@@ -162,3 +162,16 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
return GP_PIXEL_UNKNOWN;
}
+
+int GP_PixelHasAlpha(GP_PixelType pixel_type)
+{
+ unsigned int i;
+
+ GP_CHECK_VALID_PIXELTYPE(pixel_type);
+
+ for (i = 0; i < GP_PixelTypes[pixel_type].numchannels; i++)
+ if (!strcmp(GP_PixelTypes[pixel_type].channels[i].name, "A"))
+ return 1;
+
+ return 0;
+}
http://repo.or.cz/w/gfxprim.git/commit/dcb1062650a4926ced12a094a86d0a7590b5…
commit dcb1062650a4926ced12a094a86d0a7590b5f67b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Apr 10 17:32:17 2013 +0200
core: ContextConvert: Fill the allocated buffer.
Since alpha channel blits started to work,
the image will be alpha blended with random
mess in the allocated buffer. Fix it by
filling the buffer with zeroes first which
restores the previous behavior.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c
index 633cb2e..a7855c7 100644
--- a/libs/core/GP_Context.c
+++ b/libs/core/GP_Context.c
@@ -213,9 +213,16 @@ GP_Context *GP_ContextConvertAlloc(const GP_Context *src,
int h = GP_ContextH(src);
GP_Context *ret = GP_ContextAlloc(w, h, dst_pixel_type);
-
+
if (ret == NULL)
return NULL;
+
+ /*
+ * Fill the buffer with zeroes, otherwise it will
+ * contain random data which will generate mess
+ * when converting image with alpha channel.
+ */
+ memset(ret->pixels, 0, ret->bytes_per_row * ret->h);
GP_Blit(src, 0, 0, w, h, ret, 0, 0);
@@ -228,6 +235,13 @@ GP_Context *GP_ContextConvert(const GP_Context *src, GP_Context *dst)
int w = GP_ContextW(src);
int h = GP_ContextH(src);
+ /*
+ * Fill the buffer with zeroes, otherwise it will
+ * contain random data which will generate mess
+ * when converting image with alpha channel.
+ */
+ memset(dst->pixels, 0, dst->bytes_per_row * dst->h);
+
GP_Blit(src, 0, 0, w, h, dst, 0, 0);
return dst;
http://repo.or.cz/w/gfxprim.git/commit/0424a9f874f03edea2f10b52204ef3e61981…
commit 0424a9f874f03edea2f10b52204ef3e6198126cd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Apr 10 16:44:50 2013 +0200
core: Blit: Implement blit with alpha channel.
This is first version, more to come.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_MixPixels2.gen.h.t b/include/core/GP_MixPixels2.gen.h.t
new file mode 100644
index 0000000..5810a66
--- /dev/null
+++ b/include/core/GP_MixPixels2.gen.h.t
@@ -0,0 +1,83 @@
+/*****************************************************************************
+ * 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.h.t"
+
+%%- block descr
+Macros to mix two pixels. The source must have alpha channel.
+%%- endblock
+
+%% block body
+
+#include "core/GP_GammaCorrection.h"
+#include "core/GP_Pixel.h"
+
+//TODO: Fix blit where both source and destination have alpha channel
+
+%% for src in pixeltypes
+%% if not src.is_unknown() and not src.is_palette()
+%% for dst in pixeltypes
+%% if not dst.is_unknown() and not dst.is_palette()
+%% if src.is_alpha()
+
+static inline GP_Pixel GP_MixPixels_{{ src.name }}_{{ dst.name }}(GP_Pixel src, GP_Pixel dst)
+{
+ /* Extract the alpha channel */
+ unsigned int alpha = GP_Pixel_GET_A_{{ src.name }}(src);
+
+ /* Convert the pixel to RGB888, mix the values */
+ GP_Pixel src_rgb = 0, dst_rgb = 0, res = 0;
+
+ GP_Pixel_{{ src.name }}_TO_RGB888(src, src_rgb);
+ GP_Pixel_{{ dst.name }}_TO_RGB888(dst, dst_rgb);
+
+ int sr, sg, sb;
+ int dr, dg, db;
+
+ sr = GP_Pixel_GET_R_RGB888(src_rgb);
+ sg = GP_Pixel_GET_G_RGB888(src_rgb);
+ sb = GP_Pixel_GET_B_RGB888(src_rgb);
+
+ dr = GP_Pixel_GET_R_RGB888(dst_rgb);
+ dg = GP_Pixel_GET_G_RGB888(dst_rgb);
+ db = GP_Pixel_GET_B_RGB888(dst_rgb);
+
+%% set a_max = 2 ** src.chans['A'][2] - 1
+
+ dr = (dr * ({{ a_max }} - alpha) + sr * alpha + {{ a_max // 2 }}) / {{ a_max }};
+ dg = (dg * ({{ a_max }} - alpha) + sg * alpha + {{ a_max // 2 }}) / {{ a_max }};
+ db = (db * ({{ a_max }} - alpha) + sb * alpha + {{ a_max // 2 }}) / {{ a_max }};
+
+ dst_rgb = GP_Pixel_CREATE_RGB888(dr, dg, db);
+
+ GP_Pixel_RGB888_TO_{{ dst.name }}(dst_rgb, res);
+
+ return res;
+}
+
+%% endif
+%% endif
+%% endfor
+%% endif
+%% endfor
+
+%% endblock
diff --git a/include/core/Makefile b/include/core/Makefile
index 0dac795..6267d32 100644
--- a/include/core/Makefile
+++ b/include/core/Makefile
@@ -5,7 +5,7 @@ include $(TOPDIR)/pre.mk
GENHEADERS=GP_Convert_Scale.gen.h GP_Pixel.gen.h GP_GetPutPixel.gen.h GP_Convert.gen.h GP_FnPerBpp.gen.h GP_MixPixels.gen.h GP_GammaCorrection.gen.h GP_GammaPixel.gen.h - GP_WritePixel.gen.h
+ GP_WritePixel.gen.h GP_MixPixels2.gen.h
include $(TOPDIR)/gen.mk
include $(TOPDIR)/post.mk
diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t
index ccb924a..0216cfc 100644
--- a/libs/core/GP_Blit.gen.c.t
+++ b/libs/core/GP_Blit.gen.c.t
@@ -13,6 +13,7 @@
#include "core/GP_Convert.h"
#include "core/GP_Convert.gen.h"
#include "core/GP_Convert_Scale.gen.h"
+#include "core/GP_MixPixels2.gen.h"
/*
* TODO: this is used for same pixel but different offset, could still be optimized
@@ -97,10 +98,10 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src,
* more than 50% and the size footprint for two for cycles is really small.
*/
%% for src in pixeltypes
-%% if not src.is_unknown() and not src.is_palette()
-%% for dst in pixeltypes
-%% if not dst.is_unknown() and not dst.is_palette()
-%% if dst.name != src.name
+%% if not src.is_unknown() and not src.is_palette()
+%% for dst in pixeltypes
+%% if not dst.is_unknown() and not dst.is_palette()
+%% if dst.name != src.name
/*
* Blits {{ src.name }} to {{ dst.name }}
*/
@@ -108,22 +109,32 @@ static void blitXYXY_Raw_{{ src.name }}_{{ dst.name }}(const GP_Context *src,
GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
GP_Context *dst, GP_Coord x2, GP_Coord y2)
{
- GP_Coord x, y;
+ GP_Coord x, y, dx, dy;
- for (y = y0; y <= y1; y++)
+ for (y = y0; y <= y1; y++) {
for (x = x0; x <= x1; x++) {
- GP_Pixel p1, p2 = 0;
+ dx = x2 + (x - x0);
+ dy = y2 + (y - y0);
+
+ GP_Pixel p1, p2 = 0, p3 = 0;
+
p1 = GP_GetPixel_Raw_{{ src.pixelsize.suffix }}(src, x, y);
+%% if src.is_alpha()
+ p2 = GP_GetPixel_Raw_{{ dst.pixelsize.suffix }}(dst, dx, dy);
+ p3 = GP_MixPixels_{{ src.name }}_{{ dst.name }}(p1, p2);
+%% else
GP_Pixel_{{ src.name }}_TO_RGB888(p1, p2);
- GP_Pixel_RGB888_TO_{{ dst.name }}(p2, p1);
- GP_PutPixel_Raw_{{ dst.pixelsize.suffix }}(dst, x2 + (x - x0), y2 + (y - y0), p1);
+ GP_Pixel_RGB888_TO_{{ dst.name }}(p2, p3);
+%% endif
+ GP_PutPixel_Raw_{{ dst.pixelsize.suffix }}(dst, dx, dy, p3);
}
+ }
}
-%% endif
-%% endif
-%% endfor
-%% endif
+%% endif
+%% endif
+%% endfor
+%% endif
%% endfor
void GP_BlitXYXY_Raw_Fast(const GP_Context *src,
http://repo.or.cz/w/gfxprim.git/commit/71f8dfeb78b75bc456ac761eaf74ea143548…
commit 71f8dfeb78b75bc456ac761eaf74ea143548561a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Apr 10 16:16:19 2013 +0200
demos: py_simple: Add demo for alpha channel blit.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/py_simple/ball_blue.png b/demos/py_simple/ball_blue.png
new file mode 100644
index 0000000..2d6c566
Binary files /dev/null and b/demos/py_simple/ball_blue.png differ
diff --git a/demos/py_simple/ball_green.png b/demos/py_simple/ball_green.png
new file mode 100644
index 0000000..6ed05b7
Binary files /dev/null and b/demos/py_simple/ball_green.png differ
diff --git a/demos/py_simple/ball_red.png b/demos/py_simple/ball_red.png
new file mode 100644
index 0000000..bf2bde9
Binary files /dev/null and b/demos/py_simple/ball_red.png differ
diff --git a/demos/py_simple/blit.py b/demos/py_simple/blit.py
new file mode 100755
index 0000000..14fa361
--- /dev/null
+++ b/demos/py_simple/blit.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+
+import sys
+from time import sleep
+
+import gfxprim.core as core
+import gfxprim.loaders as loaders
+import gfxprim.backends as backends
+import gfxprim.input as input
+
+class Ball:
+ def __init__(self, x, y, dx, dy, path, bg_img):
+ self.ball = loaders.Load(path)
+ assert(self.ball)
+
+ self.x = x
+ self.y = y
+ self.dx = dx
+ self.dy = dy
+
+ self.bg_img = bg_img
+
+ def draw(self, bk):
+ self.ball.Blit(0, 0, bk.context, self.x, self.y, self.ball.w, self.ball.h)
+
+ def move(self, bk):
+ old_x = self.x;
+ old_y = self.y;
+
+ self.bg_img.Blit(old_x, old_y, bk.context, old_x, old_y, self.ball.w, self.ball.h)
+
+ self.x += self.dx
+ self.y += self.dy
+
+ if (self.x <= 0 or self.x >= self.bg_img.w - self.ball.w):
+ self.dx = -self.dx
+
+ if (self.y <= 0 or self.y >= self.bg_img.h - self.ball.h):
+ self.dy = -self.dy
+
+ self.ball.Blit(0, 0, bk.context, self.x, self.y, self.ball.w, self.ball.h)
+ bk.UpdateRect(min(old_x, self.x), min(self.y, old_y),
+ max(old_x, self.x) + self.ball.w - 1,
+ max(old_y, self.y) + self.ball.h - 1)
+
+def main():
+ if len(sys.argv) != 2:
+ print("Takes an image as an argument")
+ sys.exit(1)
+
+ # Load Backgroudn Image and ball sprite
+ bg = loaders.Load(sys.argv[1])
+ assert(bg)
+
+ ball1 = Ball(bg.w//2, bg.h//2, -3, -3, 'ball_red.png', bg)
+ ball2 = Ball(bg.w//2, bg.h//2, -2, 3, 'ball_green.png', bg)
+ ball3 = Ball(bg.w//2, bg.h//2, 2, -3, 'ball_blue.png', bg)
+
+ # Create X11 window
+ bk = backends.BackendX11Init(None, 0, 0, bg.w, bg.h, sys.argv[1], 0)
+ assert(bk)
+ bg.Blit(0, 0, bk.context, 0, 0, bg.w, bg.h)
+
+ bk.Flip()
+
+ # Event loop
+ while True:
+
+ while True:
+ ev = bk.PollEvent()
+
+ if (ev is None):
+ break
+
+ input.EventDump(ev)
+
+ if (ev.type == input.EV_KEY and ev.val.val == input.KEY_ESC):
+ sys.exit(0)
+ elif (ev.type == input.EV_SYS):
+ if (ev.code == input.EV_SYS_QUIT):
+ sys.exit(0)
+
+ sleep(0.005)
+
+ ball1.move(bk);
+ ball2.move(bk);
+ ball3.move(bk);
+
+if __name__ == '__main__':
+ main()
http://repo.or.cz/w/gfxprim.git/commit/882c1204e0a05f9e82e8af79b2959569de0e…
commit 882c1204e0a05f9e82e8af79b2959569de0e5399
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Apr 10 15:32:28 2013 +0200
doc: Slight update in the python backend docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/backends_python.txt b/doc/backends_python.txt
index 32d5d9f..48f5e01 100644
--- a/doc/backends_python.txt
+++ b/doc/backends_python.txt
@@ -91,8 +91,10 @@ import gfxprim.backends as backends
bk.context.gfx.Fill(bk.context.RGBToPixel(0, 0, 0));
# If backend is buffered, changes are not propagated unless the screen is
- # updated via Flip() or UpdateRect()
+ # updated via Flip()
bk.Flip()
+ # or UpdateRect()
+ bk.UpdaterRect(x0, y0, x1, y1)
-------------------------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/91e5cbbaa1e757faac1b3edd9144d749000d…
commit 91e5cbbaa1e757faac1b3edd9144d749000de97a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Apr 10 15:27:40 2013 +0200
pywrap: backends: Change UpdateRect API
The UpdateRect() now takes four numbers rather than array.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/backends/_extend_backend.py b/pylib/gfxprim/backends/_extend_backend.py
index adaf96a..7ab8d07 100644
--- a/pylib/gfxprim/backends/_extend_backend.py
+++ b/pylib/gfxprim/backends/_extend_backend.py
@@ -20,9 +20,9 @@ def extend_backend(_backend):
return c_backends.GP_BackendFlip(self)
@extend(_backend)
- def UpdateRect(self, rect):
+ def UpdateRect(self, x0, y0, x1, y1):
"Update a rectangle on a buffered backend."
- return c_backends.GP_BackendUpdateRect(self, rect[0], rect[1], rect[2], rect[3])
+ return c_backends.GP_BackendUpdateRect(self, x0, y0, x1, y1)
@extend(_backend)
def Poll(self):
http://repo.or.cz/w/gfxprim.git/commit/c53b91525478de6a140d4355da7d62e6957d…
commit c53b91525478de6a140d4355da7d62e6957d2727
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Apr 9 16:14:38 2013 +0200
core: tests: Test for invalid context pixel type.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index c0b13f3..c9f0ab4 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -112,8 +112,10 @@ typedef struct GP_PixelTypeDescription {
*/
extern const GP_PixelTypeDescription const GP_PixelTypes[GP_PIXEL_MAX];
+#define GP_VALID_PIXELTYPE(type) (((type) > 0) && ((type) < GP_PIXEL_MAX))
+
#define GP_CHECK_VALID_PIXELTYPE(type) - GP_CHECK(((type) > 0) && ((type) < GP_PIXEL_MAX), "Invalid PixelType %d", (type))
+ GP_CHECK(GP_VALID_PIXELTYPE(type), "Invalid PixelType %d", (type))
/*
* Convert pixel type to name.
diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c
index 6279890..633cb2e 100644
--- a/libs/core/GP_Context.c
+++ b/libs/core/GP_Context.c
@@ -41,14 +41,16 @@ static uint32_t get_bpr(uint32_t bpp, uint32_t w)
GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type)
{
- GP_CHECK_VALID_PIXELTYPE(type);
GP_Context *context;
- uint32_t bpp = GP_PixelSize(type);
- uint32_t bpr = get_bpr(bpp, w);
+ uint32_t bpp;
+ uint32_t bpr;
void *pixels;
- GP_DEBUG(1, "Allocating context %u x %u - %s",
- w, h, GP_PixelTypeName(type));
+ if (!GP_VALID_PIXELTYPE(type)) {
+ GP_WARN("Invalid pixel type %u", type);
+ errno = EINVAL;
+ return NULL;
+ }
if (w <= 0 || h <= 0) {
GP_WARN("Trying to allocate context with zero width and/or height");
@@ -56,6 +58,12 @@ GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type)
return NULL;
}
+ GP_DEBUG(1, "Allocating context %u x %u - %s",
+ w, h, GP_PixelTypeName(type));
+
+ bpp = GP_PixelSize(type);
+ bpr = get_bpr(bpp, w);
+
pixels = malloc(bpr * h);
context = malloc(sizeof(GP_Context));
diff --git a/tests/core/Context.c b/tests/core/Context.c
index fbabf17..5715717 100644
--- a/tests/core/Context.c
+++ b/tests/core/Context.c
@@ -243,6 +243,44 @@ static int context_zero_h(void)
return TST_SUCCESS;
}
+static int context_invalid_pixeltype1(void)
+{
+ GP_Context *c;
+
+ c = GP_ContextAlloc(100, 100, -1);
+
+ if (c != NULL) {
+ tst_msg("Context with invalid pixel type (-1) succesfully allocated");
+ return TST_FAILED;
+ }
+
+ if (errno != EINVAL) {
+ tst_msg("Expected errno set to EINVAL");
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+static int context_invalid_pixeltype2(void)
+{
+ GP_Context *c;
+
+ c = GP_ContextAlloc(100, 100, GP_PIXEL_MAX + 1000);
+
+ if (c != NULL) {
+ tst_msg("Context with invalid pixel type (-1) succesfully allocated");
+ return TST_FAILED;
+ }
+
+ if (errno != EINVAL) {
+ tst_msg("Expected errno set to EINVAL");
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
const struct tst_suite tst_suite = {
.suite_name = "Context Testsuite",
.tests = {
@@ -257,6 +295,10 @@ const struct tst_suite tst_suite = {
.tst_fn = context_zero_w},
{.name = "Context Create h = 0",
.tst_fn = context_zero_h},
+ {.name = "Context Create pixel_type = -1",
+ .tst_fn = context_invalid_pixeltype1},
+ {.name = "Context Create invalid pixel_type",
+ .tst_fn = context_invalid_pixeltype2},
{.name = NULL},
}
};
-----------------------------------------------------------------------
Summary of changes:
demos/py_simple/ball_blue.png | Bin 0 -> 1151 bytes
demos/py_simple/ball_green.png | Bin 0 -> 1182 bytes
demos/py_simple/ball_red.png | Bin 0 -> 1144 bytes
demos/py_simple/blit.py | 90 ++++++++++++++++++++
doc/backends_python.txt | 4 +-
.../core/GP_MixPixels2.gen.h.t | 82 ++++++++++--------
include/core/GP_Pixel.h | 10 ++-
include/core/Makefile | 2 +-
libs/core/GP_Blit.gen.c.t | 37 +++++---
libs/core/GP_Context.c | 34 ++++++--
libs/core/GP_Pixel.c | 13 +++
pylib/gfxprim/backends/_extend_backend.py | 4 +-
tests/core/Context.c | 42 +++++++++
13 files changed, 257 insertions(+), 61 deletions(-)
create mode 100644 demos/py_simple/ball_blue.png
create mode 100644 demos/py_simple/ball_green.png
create mode 100644 demos/py_simple/ball_red.png
create mode 100755 demos/py_simple/blit.py
copy libs/gfx/GP_PutPixelAA.gen.c.t => include/core/GP_MixPixels2.gen.h.t (53%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: feff7abe0be63662f56d82aa080f3c7c8be9d194
by metan 09 Apr '13
by metan 09 Apr '13
09 Apr '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 feff7abe0be63662f56d82aa080f3c7c8be9d194 (commit)
via 5e0e6305889ab3f26302bf5c2b31aa83d0a1ec45 (commit)
from 59b7db7636f17da18520d71c091dd9c23694ea91 (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/feff7abe0be63662f56d82aa080f3c7c8be9…
commit feff7abe0be63662f56d82aa080f3c7c8be9d194
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Apr 9 15:09:43 2013 +0200
gfx: Ellipse: Fix special case for a == 0 || b == 0
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/gfx/algo/Ellipse.algo.h b/libs/gfx/algo/Ellipse.algo.h
index f10fbb0..a964e86 100644
--- a/libs/gfx/algo/Ellipse.algo.h
+++ b/libs/gfx/algo/Ellipse.algo.h
@@ -19,7 +19,7 @@
* 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> *
* *
*****************************************************************************/
@@ -80,6 +80,19 @@ static void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int b2 = b*b; int x, y, error; ++ if (a == 0) { + for (y = -b; y <= (int)b; y++) + PUTPIXEL(context, xcenter, ycenter + y, pixval); + return; + } ++ if (b == 0) { + for (x = -a; x <= (int)a; x++) + PUTPIXEL(context, xcenter + x, ycenter, pixval); + return; + } + for (x = 0, error = -b2*a, y = b; y >= 0; y--) { while (error < 0) {
http://repo.or.cz/w/gfxprim.git/commit/5e0e6305889ab3f26302bf5c2b31aa83d0a1…
commit 5e0e6305889ab3f26302bf5c2b31aa83d0a1ec45
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Apr 9 14:47:26 2013 +0200
core: WritePixel: Fix 24 BPP with count == 0.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/core/GP_WritePixel.c b/libs/core/GP_WritePixel.c
index 916f9ef..0cd1cc7 100644
--- a/libs/core/GP_WritePixel.c
+++ b/libs/core/GP_WritePixel.c
@@ -376,6 +376,9 @@ void GP_WritePixels_24BPP(void *start, size_t count, unsigned int value)
{
uint8_t *bytep = (uint8_t *) start;
+ if (count == 0)
+ return;
+
/* How much bytes we are offset against the 32-bit boundary. */
int shift = ((intptr_t) bytep) % 4;
-----------------------------------------------------------------------
Summary of changes:
libs/core/GP_WritePixel.c | 3 +++
libs/gfx/algo/Ellipse.algo.h | 15 ++++++++++++++-
2 files changed, 17 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0