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 bf70bc758e8d915a99250ce0422f05f414785e5d (commit)
from e5db2b1f3508e1630b9af36a397a68ef069a56a2 (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/bf70bc758e8d915a99250ce0422f05f41478…
commit bf70bc758e8d915a99250ce0422f05f414785e5d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jan 8 20:26:11 2012 +0100
gfx: Fix CircleSeg orientation.
diff --git a/libs/gfx/GP_CircleSeg.c b/libs/gfx/GP_CircleSeg.c
index 56179c6..512699e 100644
--- a/libs/gfx/GP_CircleSeg.c
+++ b/libs/gfx/GP_CircleSeg.c
@@ -39,7 +39,7 @@ static uint8_t transform_segments(GP_Context *context, uint8_t seg_flags)
uint8_t seg4 = seg_flags & GP_CIRCLE_SEG4;
if (context->axes_swap)
- GP_SWAP(seg2, seg4);
+ GP_SWAP(seg1, seg3);
if (context->x_swap) {
GP_SWAP(seg1, seg2);
diff --git a/libs/gfx/algo/CircleSeg.algo.h b/libs/gfx/algo/CircleSeg.algo.h
index 9812888..dc176a3 100644
--- a/libs/gfx/algo/CircleSeg.algo.h
+++ b/libs/gfx/algo/CircleSeg.algo.h
@@ -84,25 +84,25 @@ void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, unsigned int r, while (error < 0) { error += 2*x + 1; x++; - if (seg_flags & GP_CIRCLE_SEG3) + if (seg_flags & GP_CIRCLE_SEG2) PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); - if (seg_flags & GP_CIRCLE_SEG4) + if (seg_flags & GP_CIRCLE_SEG1) PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); - if (seg_flags & GP_CIRCLE_SEG2) + if (seg_flags & GP_CIRCLE_SEG3) PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); - if (seg_flags & GP_CIRCLE_SEG1) + if (seg_flags & GP_CIRCLE_SEG4) PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); } /* Enough changes accumulated, go to next line. */ error += -2*y + 1; - if (seg_flags & GP_CIRCLE_SEG3) + if (seg_flags & GP_CIRCLE_SEG2) PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); - if (seg_flags & GP_CIRCLE_SEG4) + if (seg_flags & GP_CIRCLE_SEG1) PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval)
; - if (seg_flags & GP_CIRCLE_SEG2) + if (seg_flags & GP_CIRCLE_SEG3) PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); - if (seg_flags & GP_CIRCLE_SEG1) + if (seg_flags & GP_CIRCLE_SEG4) PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); } }
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_CircleSeg.c | 2 +-
libs/gfx/algo/CircleSeg.algo.h | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 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.")
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 e5db2b1f3508e1630b9af36a397a68ef069a56a2 (commit)
from 566ed587e8f01232c84c2aba46d1861a20cd0c27 (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/e5db2b1f3508e1630b9af36a397a68ef069a…
commit e5db2b1f3508e1630b9af36a397a68ef069a56a2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jan 8 18:53:24 2012 +0100
gfx: Add function for circle segment drawing.
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_CircleSeg.h
similarity index 53%
copy from include/gfx/GP_Gfx.h
copy to include/gfx/GP_CircleSeg.h
index 6503952..fddc5ef 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_CircleSeg.h
@@ -16,41 +16,52 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-/*
+#ifndef GFX_GP_CIRCLE_H
+#define GFX_GP_CIRCLE_H
- This is a main header for gfx part.
+#include "core/GP_Context.h"
+/*
+ * Quadrants in cartesian space the center is set in the middle of the circle.
+ *
+ * First segment is where both x and y are possitive, second is where only y is
+ * possitive, third is for both x and y negative and the last one for only y
+ * negative.
+ *
+ * Note that on computer screen (and in in-memory bitmaps) cordinates for y
+ * grows in the opposite direction to the standard cartesian plane.
+ *
+ * So first segment is actually down right, second is down left, third is up
+ * left, and fourth is up right.
*/
+enum GP_CircleSegments {
+ GP_CIRCLE_SEG1 = 0x01, /* First Quadrant */
+ GP_CIRCLE_SEG2 = 0x02, /* Second Quadrant */
+ GP_CIRCLE_SEG3 = 0x04, /* Third Quadrant */
+ GP_CIRCLE_SEG4 = 0x08, /* Fourth Quadrant */
+};
-#ifndef GP_GFX_H
-#define GP_GFX_H
+/* Circle Segment */
-/* basic definitions and structures */
-#include "core/GP_Context.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_WritePixel.h"
-
-/* public drawing API */
-#include "GP_Fill.h"
-#include "GP_HLine.h"
-#include "GP_VLine.h"
-#include "GP_Line.h"
-#include "GP_Rect.h"
-#include "GP_Triangle.h"
-#include "GP_Tetragon.h"
-#include "GP_Circle.h"
-#include "GP_Ellipse.h"
-#include "GP_Arc.h"
-#include "GP_Polygon.h"
-#include "GP_Symbol.h"
-
-#include "GP_RectAA.h"
-
-#endif /* GP_GFX_H */
+void GP_CircleSeg(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, uint8_t seg_flag, GP_Pixel pixel);
+
+void GP_CircleSeg_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, uint8_t seg_flag, GP_Pixel pixel);
+
+/* Filled Circle Segment */
+
+void GP_FillCircleSeg(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, uint8_t seg_flag, GP_Pixel pixel);
+
+void GP_FillCircleSeg_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, uint8_t seg_flag, GP_Pixel pixel);
+
+#endif /* GFX_GP_CIRCLE_H */
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h
index 6503952..54648a8 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_Gfx.h
@@ -46,6 +46,7 @@
#include "GP_Triangle.h"
#include "GP_Tetragon.h"
#include "GP_Circle.h"
+#include "GP_CircleSeg.h"
#include "GP_Ellipse.h"
#include "GP_Arc.h"
#include "GP_Polygon.h"
diff --git a/libs/gfx/GP_CircleSeg.c b/libs/gfx/GP_CircleSeg.c
new file mode 100644
index 0000000..56179c6
--- /dev/null
+++ b/libs/gfx/GP_CircleSeg.c
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ * 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-2011 Jiri "BlueBear" Dluhos *
+ * <jiri.bluebear.dluhos(a)gmail.com> *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "GP_CircleSeg.h"
+#include "GP_HLine.h"
+
+#include "core/GP_GetPutPixel.h"
+#include "core/GP_FnPerBpp.h"
+
+#include "algo/CircleSeg.algo.h"
+
+static uint8_t transform_segments(GP_Context *context, uint8_t seg_flags)
+{
+ uint8_t seg1 = seg_flags & GP_CIRCLE_SEG1;
+ uint8_t seg2 = seg_flags & GP_CIRCLE_SEG2;
+ uint8_t seg3 = seg_flags & GP_CIRCLE_SEG3;
+ uint8_t seg4 = seg_flags & GP_CIRCLE_SEG4;
+
+ if (context->axes_swap)
+ GP_SWAP(seg2, seg4);
+
+ if (context->x_swap) {
+ GP_SWAP(seg1, seg2);
+ GP_SWAP(seg3, seg4);
+ }
+
+ if (context->y_swap) {
+ GP_SWAP(seg1, seg4);
+ GP_SWAP(seg2, seg3);
+ }
+
+ seg1 = seg1 ? GP_CIRCLE_SEG1 : 0;
+ seg2 = seg2 ? GP_CIRCLE_SEG2 : 0;
+ seg3 = seg3 ? GP_CIRCLE_SEG3 : 0;
+ seg4 = seg4 ? GP_CIRCLE_SEG4 : 0;
+
+ return seg1|seg2|seg3|seg4;
+}
+
+/* Generate drawing functions for various bit depths. */
+GP_DEF_DRAW_FN_PER_BPP(GP_CircleSeg_Raw, DEF_CIRCLE_SEG_FN)
+
+void GP_CircleSeg_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, uint8_t seg_flag, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP_CONTEXT(GP_CircleSeg_Raw, context, context,
+ xcenter, ycenter, r, seg_flag, pixel);
+}
+
+void GP_CircleSeg(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, uint8_t seg_flag, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_TRANSFORM_POINT(context, xcenter, ycenter);
+
+ GP_CircleSeg_Raw(context, xcenter, ycenter, r,
+ transform_segments(context, seg_flag), pixel);
+}
+
+/*
+#include "algo/FillCircle.algo.h"
+
+GP_DEF_FILL_FN_PER_BPP(GP_FillCircle_Raw, DEF_FILLCIRCLE_FN)
+
+void GP_FillCircle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP_CONTEXT(GP_FillCircle_Raw, context, context,
+ xcenter, ycenter, r, pixel);
+}
+
+void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_TRANSFORM_POINT(context, xcenter, ycenter);
+
+ GP_FillCircle_Raw(context, xcenter, ycenter, r, pixel);
+}
+*/
diff --git a/libs/gfx/algo/CircleSeg.algo.h b/libs/gfx/algo/CircleSeg.algo.h
new file mode 100644
index 0000000..9812888
--- /dev/null
+++ b/libs/gfx/algo/CircleSeg.algo.h
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ * 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-2011 Jiri "BlueBear" Dluhos *
+ * <jiri.bluebear.dluhos(a)gmail.com> *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+/*
+ * Circle drawing algorithm.
+ *
+ * The circle is drawn in a top-down manner. We start from the top, and
+ * at each line, we iterate X until we accumulate enough changes to Y
+ * to pass to the next line. In each step, 4 pixels are drawn:
+ * (X, Y), (-X, Y), (X, -Y) and (-X, -Y).
+ *
+ * The math:
+ * From the circle equation, for every point applies:
+ *
+ * x^2 + y^2 = r^2 -> x^2 + y^2 - r^2 = 0
+ *
+ * which has an exact solution for a non-integer x.
+ * For an integer approximation, we want to find x
+ * for which
+ *
+ * x^2 + y^2 - r^2 = error
+ *
+ * where error should be as close to 0 as possible.
+ * We find the x by incrementing its value until
+ * we cross the zero error boundary.
+ *
+ * Optimization:
+ * Significant amount of multiplications can be
+ * saved when calculating error by re-using previous
+ * error values. For error(x+1) we have:
+ *
+ * error(x+1) = (x+1)^2 + y^2 - r^2
+ *
+ * which can be expanded to (expanding (x+1)^2):
+ *
+ * error(x+1) = x^2 + 2*x + 1 + y^2 - r^2
+ *
+ * and after substituting the error(x) we already know:
+ *
+ * error(x+1) = error(x) + 2*x + 1
+ *
+ * The same can be done for calculating
+ * error(y-1) from error(y).
+ */
+
+/*
+ * This macro defines a circle drawing function.
+ * Arguments:
+ * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL)
+ * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL)
+ * PUTPIXEL - a pixel drawing function f(context, x, y, pixval)
+ * FN_NAME - name of the function to be defined
+ */
+#define DEF_CIRCLE_SEG_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) +void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, unsigned int r, + uint8_t seg_flags, PIXVAL_T pixval) +{ + int x, y, error; + for (x = 0, error = -r, y = r; y >= 0; y--) { ++ /* Iterate X until we can pass to the next line. */ + while (error < 0) { + error += 2*x + 1; + x++; + if (seg_flags & GP_CIRCLE_SEG3) + PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); + if (seg_flags & GP_CIRCLE_SEG4) + PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); + if (seg_flags & GP_CIRCLE_SEG2) + PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); + if (seg_flags & GP_CIRCLE_SEG1) + PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); + } ++ /* Enough changes accumulated, go to next line. */ + error += -2*y + 1; + if (seg_flags & GP_CIRCLE_SEG3) + PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); + if (seg_flags & GP_CIRCLE_SEG4) + PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval);
+ if (seg_flags & GP_CIRCLE_SEG2) + PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); + if (seg_flags & GP_CIRCLE_SEG1) + PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); + } +}
-----------------------------------------------------------------------
Summary of changes:
include/gfx/{GP_Triangle.h => GP_CircleSeg.h} | 52 +++++++----
include/gfx/GP_Gfx.h | 1 +
libs/gfx/{GP_Circle.c => GP_CircleSeg.c} | 98 ++++++++++-----------
libs/gfx/algo/{Circle.algo.h => CircleSeg.algo.h} | 30 ++++---
4 files changed, 99 insertions(+), 82 deletions(-)
copy include/gfx/{GP_Triangle.h => GP_CircleSeg.h} (55%)
copy libs/gfx/{GP_Circle.c => GP_CircleSeg.c} (59%)
copy libs/gfx/algo/{Circle.algo.h => CircleSeg.algo.h} (85%)
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.")
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
discards 730f353131afe02ce53c9957b1e80009abba59e4 (commit)
via 566ed587e8f01232c84c2aba46d1861a20cd0c27 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (730f353131afe02ce53c9957b1e80009abba59e4)
N -- N -- N (566ed587e8f01232c84c2aba46d1861a20cd0c27)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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/566ed587e8f01232c84c2aba46d1861a20cd…
commit 566ed587e8f01232c84c2aba46d1861a20cd0c27
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jan 6 20:36:48 2012 +0100
core: Use table for gamma correction.
diff --git a/include/core/GP_GammaCorrection.h b/include/core/GP_GammaCorrection.h
index d36b1a9..d7d9d9c 100644
--- a/include/core/GP_GammaCorrection.h
+++ b/include/core/GP_GammaCorrection.h
@@ -24,6 +24,36 @@
Gamma correction.
+ What is gamma and what is it doing in my computer?
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ First of all gamma is a function, or better there is a gamma function and
+ it's inverse function. Both gamma function and it's inverse are defined on
+ interval [0,1] and are defined as out = in^(gamma) and it's inverse as
+ out = in^(1/gamma).
+
+ The purpose of this function is to compensate nonlinearity of human eye
+ perception. The human eye is more sensitive to dark tones than the light ones
+ so without gamma correction storage and manipulation with image data would
+ either be less efficient in space (in case you decided to use more bits and
+ encode the image lineary) or quantization in darker tones would be more
+ visible resulting in "pixelated" images (aliasing).
+
+ So there is a gamma, the internet seems to suggest that usual values for
+ gamma are 2.5 for old CRT monitors and about 2.2 for LCD ones, ideally you
+ should have color profile for your device (you need special hardware to
+ measure it). So if you are trying to draw linear gradient on the screen
+ you need to generate sequence of numbers accordinly to gamma function
+ (the 50% intensity is around 186 for gamma = 2.2 and 8bit grayscale pixel).
+
+ Moreover image formats tend to save data in nonlinear fashion (some formats
+ include gama value used to for the image) so before you apply filter that
+ manipulates with pixel values, you need to convert it to linear space (adding
+ some more bits to compensate for rounding errors).
+
+ Also it's important to take gamma into accound if you start drawing anti
+ aliased shapes, you can't get right results if you don't consider gamma.
+
*/
#ifndef CORE_GP_GAMMA_CORRECTION_H
@@ -32,16 +62,17 @@
#include <stdint.h>
#include <math.h>
-#define GP_GAMMA 2.2
+extern uint8_t *GP_LinearToGamma_8bit;
/*
* Coverts linear 0 255 value into 0 255 gama value.
*
- * (this is used for Anti Aliased gfx primitives.
+ * (this is used for Anti Aliased gfx primitives.)
*/
-static inline uint8_t GP_GammaToLinear(uint8_t val)
+static inline uint8_t GP_LinearToGamma(uint8_t val)
{
- return pow(1.00 * val/255, 1/GP_GAMMA) * 255 + 0.5;
+
+ return GP_LinearToGamma_8bit[val];
}
#endif /* CORE_GP_GAMMA_CORRECTION_H */
diff --git a/libs/core/GP_GammaCorrection.gen.c.t b/libs/core/GP_GammaCorrection.gen.c.t
new file mode 100644
index 0000000..0fdd467
--- /dev/null
+++ b/libs/core/GP_GammaCorrection.gen.c.t
@@ -0,0 +1,30 @@
+%% extends "base.c.t"
+
+{% block descr %}Gamma correction tables for Gamma = 2.2{% endblock %}
+
+%% block body
+
+/*
+ * Gamma correction tables.
+ *
+ * Copyright (c) 2012 Cyril Hrubis <metan(a)ucw.cz>
+ */
+
+#include <stdint.h>
+
+/*
+ * 8-bit linear to gamma translation table.
+ */
+static uint8_t linear_to_gamma_8bit[] = {
+%% for i in range(0, 256)
+ {{ int(((float(i)/255) ** (1/2.2)) * 255 + 0.5) }}, /* {{i}} */
+%% endfor
+};
+
+/*
+ * Pointer to 8 bit translation table.
+ */
+uint8_t *GP_LinearToGamma_8bit = linear_to_gamma_8bit;
+
+
+%% endblock body
diff --git a/libs/core/Makefile b/libs/core/Makefile
index 3af4933..2baef75 100644
--- a/libs/core/Makefile
+++ b/libs/core/Makefile
@@ -1,5 +1,6 @@
TOPDIR=../..
-GENSOURCES=GP_Pixel.gen.c GP_Blit.gen.c GP_Convert.gen.c
+GENSOURCES=GP_Pixel.gen.c GP_Blit.gen.c GP_Convert.gen.c + GP_GammaCorrection.gen.c
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=core
diff --git a/libs/gfx/GP_RectAA.c b/libs/gfx/GP_RectAA.c
index 69ddd8f..a48d72e 100644
--- a/libs/gfx/GP_RectAA.c
+++ b/libs/gfx/GP_RectAA.c
@@ -53,7 +53,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
/* Special case, vertical 1px line */
if (out_x0 == out_x1) {
- uint8_t mix = GP_GammaToLinear(w);
+ uint8_t mix = GP_LinearToGamma(w);
GP_Coord i;
/* Special case 1px 100% width line */
@@ -71,7 +71,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
/* Special case, horizontal 1px line */
if (out_y0 == out_y1) {
- uint8_t mix = GP_GammaToLinear(h);
+ uint8_t mix = GP_LinearToGamma(h);
GP_Coord i;
/* Special case 1px 100% height line */
@@ -105,7 +105,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
/* if the outer and innter coordinates doesn't match, draw blurred edge */
if (in_y0 != out_y0) {
- uint8_t mix = GP_GammaToLinear(GP_FP_FROM_INT(in_y0) + GP_FP_1_2 - y0);
+ uint8_t mix = GP_LinearToGamma(GP_FP_FROM_INT(in_y0) + GP_FP_1_2 - y0);
GP_Coord i;
for (i = out_x0; i <= out_x1; i++) {
@@ -116,7 +116,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
}
if (in_y1 != out_y1) {
- uint8_t mix = GP_GammaToLinear(y1 - GP_FP_FROM_INT(in_y0) - GP_FP_1_2);
+ uint8_t mix = GP_LinearToGamma(y1 - GP_FP_FROM_INT(in_y0) - GP_FP_1_2);
GP_Coord i;
for (i = out_x0; i <= out_x1; i++) {
@@ -127,7 +127,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
}
if (in_x0 != out_x0) {
- uint8_t mix = GP_GammaToLinear(GP_FP_FROM_INT(in_x0) + GP_FP_1_2 - x0);
+ uint8_t mix = GP_LinearToGamma(GP_FP_FROM_INT(in_x0) + GP_FP_1_2 - x0);
GP_Coord i;
for (i = out_y0; i <= out_y1; i++) {
@@ -138,7 +138,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
}
if (in_x1 != out_x1) {
- uint8_t mix = GP_GammaToLinear(x1 - GP_FP_FROM_INT(in_x1) - GP_FP_1_2);
+ uint8_t mix = GP_LinearToGamma(x1 - GP_FP_FROM_INT(in_x1) - GP_FP_1_2);
GP_Coord i;
for (i = out_y0; i <= out_y1; i++) {
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_GammaCorrection.h | 32 ++++++++++++++++++++++++++++++--
libs/core/GP_GammaCorrection.gen.c.t | 30 ++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 2 deletions(-)
create mode 100644 libs/core/GP_GammaCorrection.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.")