babl r356 - in trunk: . babl babl/base extensions
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: babl r356 - in trunk: . babl babl/base extensions
- Date: Sun, 16 Nov 2008 12:36:50 +0000 (UTC)
Author: martinn
Date: Sun Nov 16 12:36:50 2008
New Revision: 356
URL: http://svn.gnome.org/viewvc/babl?rev=356&view=rev
Log:
* babl/babl.h: Add #define BABL_ALPHA_THRESHOLD which is the alpha
threshold used in the reference implementation for
un-pre-multiplication of color data.
* babl/base/model-rgb.c
* babl/base/model-gray.c
* extensions/gegl-fixups.c: Use the define, a consistent alpha
threshold improves accurucy of conversions.
Modified:
trunk/ChangeLog
trunk/babl/babl.h
trunk/babl/base/model-gray.c
trunk/babl/base/model-rgb.c
trunk/extensions/gegl-fixups.c
Modified: trunk/babl/babl.h
==============================================================================
--- trunk/babl/babl.h (original)
+++ trunk/babl/babl.h Sun Nov 16 12:36:50 2008
@@ -45,6 +45,11 @@
*/
#define BABL_MAGIC 0xbAb100
+/* Alpha threshold used in the reference implementation for
+ * un-pre-multiplication of color data.
+ */
+#define BABL_ALPHA_THRESHOLD 0.0001
+
enum {
BABL_INSTANCE = BABL_MAGIC,
BABL_TYPE,
Modified: trunk/babl/base/model-gray.c
==============================================================================
--- trunk/babl/base/model-gray.c (original)
+++ trunk/babl/base/model-gray.c Sun Nov 16 12:36:50 2008
@@ -308,7 +308,7 @@
double luminance = *(double *) src[0];
double alpha = *(double *) src[1];
- if (alpha > 0.00001)
+ if (alpha > BABL_ALPHA_THRESHOLD)
{
luminance = luminance / alpha;
}
@@ -408,7 +408,7 @@
alpha = *(double *) src[src_bands - 1];
for (band = 0; band < src_bands - 1; band++)
{
- if (alpha > 0.001)
+ if (alpha > BABL_ALPHA_THRESHOLD)
{
*(double *) dst[band] = *(double *) src[band] / alpha;
}
Modified: trunk/babl/base/model-rgb.c
==============================================================================
--- trunk/babl/base/model-rgb.c (original)
+++ trunk/babl/base/model-rgb.c Sun Nov 16 12:36:50 2008
@@ -283,7 +283,7 @@
alpha = *(double *) src[src_bands - 1];
for (band = 0; band < src_bands - 1; band++)
{
- if (alpha > 0.001)
+ if (alpha > BABL_ALPHA_THRESHOLD)
{
*(double *) dst[band] = *(double *) src[band] / alpha;
}
@@ -332,7 +332,7 @@
while (n--)
{
double alpha = ((double *) src)[3];
- if (alpha > 0.0001)
+ if (alpha > BABL_ALPHA_THRESHOLD)
{
((double *) dst)[0] = gamma_2_2_to_linear (((double *) src)[0] / alpha);
((double *) dst)[1] = gamma_2_2_to_linear (((double *) src)[1] / alpha);
Modified: trunk/extensions/gegl-fixups.c
==============================================================================
--- trunk/extensions/gegl-fixups.c (original)
+++ trunk/extensions/gegl-fixups.c Sun Nov 16 12:36:50 2008
@@ -337,7 +337,7 @@
{
float ca = src[i];
int ret;
- if (alpha < 0.0001)
+ if (alpha < BABL_ALPHA_THRESHOLD)
ret = 0;
else
ret = table_F_8g[gggl_float_to_index16 (ca / alpha)];
@@ -393,7 +393,7 @@
while (n--)
{
float alpha = src[3];
- if (alpha < 0.00001)
+ if (alpha < BABL_ALPHA_THRESHOLD)
{
dst[0] = 0;
dst[1] = 0;
@@ -471,7 +471,7 @@
{
float alpha = src[3];
float recip = 1.0/alpha;
- if (alpha < 0.00001)
+ if (alpha < BABL_ALPHA_THRESHOLD)
recip = 0.0;
dst[0] = src[0] * recip;
dst[1] = src[1] * recip;
@@ -498,7 +498,7 @@
{
float alpha = src[3];
float recip = (1.0/alpha);
- if (alpha < 0.00001)
+ if (alpha < BABL_ALPHA_THRESHOLD)
{
dst[0] = dst[1] = dst[2] = dst[3] = 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]