[babl] docs: update alpha docs



commit 5bcddad4eb90ce0070db1714ccacb6d4c72e631b
Author: Øyvind Kolås <pippin gimp org>
Date:   Sun Aug 18 15:28:52 2019 +0200

    docs: update alpha docs

 docs/Glossary-static.html                             | 11 ++++-------
 ...tricAlpha-static.html => UnifiedAlpha-static.html} | 19 ++++++++++++++++---
 docs/index-static.html.in                             |  2 +-
 docs/meson.build                                      |  7 +++----
 docs/toc                                              |  2 +-
 5 files changed, 25 insertions(+), 16 deletions(-)
---
diff --git a/docs/Glossary-static.html b/docs/Glossary-static.html
index 7d7364d55..7f91b7769 100644
--- a/docs/Glossary-static.html
+++ b/docs/Glossary-static.html
@@ -39,7 +39,7 @@ keep the vocabulary small.</p>
 own associated alpha. This representation is useful for avoiding color from
 empty pixels bleeding into surroundings. It is also able to represent emittance
 in addition to opacity.
-Babl uses <a href='SymmetricAlpha'>Symmetric alpha transformations</a> between <a 
href='#separate_alpha'>separate alpha</a> and associated alpha.</dd>
+Babl uses <a href='UnifiedAlpha'>Unified alpha transformations</a> between <a 
href='#separate_alpha'>separate alpha</a> and associated alpha.</dd>
 
 
     <dt><a name='BablFish' href='#BablFish'>BablFish</a></dt>
@@ -72,16 +72,13 @@ relevant spaces - the ICC profile for the space.</dt>
     <dt><a name='luminance' href='#luminance'>Luminance</a></dt>
     <dd>The photometric measure of luminious intensity of per unit area of light. The luminance in babl is 
proportional to luminance - though it doesn't use the SI unit of candela per square meter.</dd>
 
-    <dt><a name='non_associated_alpha' href='#non_associated_alpha'>Non-associated alpha</a></dt>
-    <dd>deprecated term, see separate alpha</dd>
-
     <dt><a name='premultiplied_alpha' href='#premultiplied_alpha'>Premultiplied alpha</a></dt>
     <dd>deprecated term, see associated alpha</dd>
 
-    <dt><a name='separate_alpha' href='#separate_alpha'>Separate alpha</a></dt>
-    <dd>This representation of pixels has alpha as a fully separate component,
+    <dt><a name='straight_alpha' href='#straight_alpha'>Straight alpha</a></dt>
+    <dd>Straight or separate alpha has alpha as a fully separate component,
 that can be adjusted without affecting the color.
-Babl uses <a href='SymmetricAlpha'>Symmetric alpha transformations</a> between separate and <a 
href='#associated_alpha'>associated alpha</a>.</dd>
+Babl uses <a href='Unifiedlpha'>symetric alpha transformations</a> between straight and <a 
href='#associated_alpha'>associated alpha</a>.</dd>
 
     <dt><a name='trc' href='#trc'>TRC</a></dt>
 
diff --git a/docs/SymmetricAlpha-static.html b/docs/UnifiedAlpha-static.html
similarity index 84%
rename from docs/SymmetricAlpha-static.html
rename to docs/UnifiedAlpha-static.html
index 959f0db7c..9b948065f 100644
--- a/docs/SymmetricAlpha-static.html
+++ b/docs/UnifiedAlpha-static.html
@@ -6,7 +6,7 @@
 -->
 <html>
   <head>
-    <title>Symmetric Alpha - babl</title>
+    <title>Unified Alpha - babl</title>
     <meta http-equiv="content-type" content="text/html;charset=utf-8" />
     <link rel="icon" href="graphics/babl-16x16.png" type="image/png" />
     <link rel="shortcut icon" href="graphics/babl-16x16.png" type="image/png" />
@@ -68,14 +68,27 @@ associated_to_separate_rgba (const float *associated_rgba,
                                    float *separate_rgba)
 {
   float alpha = associated_rgba[3];
-  float clamped_alpha = babl_epsilon_for_zero_float (alpha);
-  float reciprocal_alpha = 1.0f / clamped_alpha;
+  float reciprocal_alpha = 1.0f / babl_epsilon_for_zero_float (alpha);
 
   separate_rgba[0] = associated_rgba[0] * reciprocal_alpha;
   separate_rgba[1] = associated_rgba[1] * reciprocal_alpha;
   separate_rgba[2] = associated_rgba[2] * reciprocal_alpha;
   separate_rgba[3] = alpha;
 }
+
+
+static inline void
+separate_to_associated_rgba (const float *separate_rgba,
+                                   float *associated_rgba)
+{
+  float alpha = associated_rgba[3];
+  float limited_alpha = babl_epsilon_for_zero_float (alpha);
+
+  associated_rgba[0] = separate_rgba[0] * limited_alpha;
+  associated_rgba[1] = separate_rgba[1] * limited_alpha;
+  associated_rgba[2] = separate_rgba[2] * limited_alpha;
+  associated_rgba[3] = alpha;
+}
 </pre>
 
 
diff --git a/docs/index-static.html.in b/docs/index-static.html.in
index df131f1a1..92a9c9ba2 100644
--- a/docs/index-static.html.in
+++ b/docs/index-static.html.in
@@ -55,7 +55,7 @@
       <li>Runtime profiling/validating and code-path optimizing with persistence of profiling data across 
runs, with caching of results.</li>
         <li>Can load <a href='ColorManagement.html'>Color Spaces</a> from ICC v2 and v4 profiles containing 
RGB matrix + TRC and with lcms2 dependency also <a
 href='CMYK.html'>CMYK</a> profiles.</li>
-      <li>Uses <a href='SymmetricAlpha.html'>Symmetric Alpha</a> conversions for conversions between 
separate and associate alpha, avoiding loss of color fidelity due to asymptotic behavior near alpha 0.0 in 
floating point.</li>
+      <li>Uses <a href='UnifiedAlpha.html'>Unified Alpha</a> conversions for conversions between separate 
and associate alpha, avoiding loss of color fidelity due to asymptotic behavior when dividing by 0.0 in 
floating point.</li>
       <li>Portable self contained C code working on win32, linux, bsds and mac
 on 32bit and 64bit systems.</li>
       <li>Stable, small API, with singleton objects returned.</li>
diff --git a/docs/meson.build b/docs/meson.build
index d085b805f..01b6c3093 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -130,12 +130,12 @@ ColorManagement_html = custom_target('ColorManagement.html',
   build_by_default: true,
 )
 
-SymmetricAlpha_html = custom_target('SymmetricAlpha.html',
+UnifiedAlpha_html = custom_target('UnifiedAlpha.html',
   input : [
-    'SymmetricAlpha-static.html',
+    'UnifiedAlpha-static.html',
     'toc',
   ],
-  output: [ 'SymmetricAlpha.html', ],
+  output: [ 'UnifiedAlpha.html', ],
   command: [
     env_bin,
     'cp', '@INPUT0@', '@OUTPUT@',
@@ -144,7 +144,6 @@ SymmetricAlpha_html = custom_target('SymmetricAlpha.html',
   build_by_default: true,
 )
 
-
 run_target('push_web',
   command: [
     'scp', index_html, index_static_html, babl_css, scptarget,
diff --git a/docs/toc b/docs/toc
index ec3685a1b..ffbf61d87 100644
--- a/docs/toc
+++ b/docs/toc
@@ -8,7 +8,7 @@
         <li><a href='Reference.html'>&nbsp;&nbsp;Reference</a></li>
         <li><a href='Glossary.html'>&nbsp;&nbsp;Glossary</a></li>
         <li><a href='ColorManagement.html'>&nbsp;&nbsp;Color Management</a></li>
-        <li><a href='SymmetricAlpha.html'>&nbsp;&nbsp;Symmetric-Alpha</a></li>
+        <li><a href='UnifiedAlpha.html'>&nbsp;&nbsp;Unified-Alpha</a></li>
         <li><a href='CMYK.html'>&nbsp;&nbsp;CMYK</a></li>
         <!--<li><a href='#Background'>Background</a></li>-->
         <li><a href='index.html#Usage'>&nbsp;&nbsp;Usage</a></li>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]