freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master fafe343: * graph/gblender.c (gblender_set_gamma


From: Werner Lemberg
Subject: [freetype2-demos] master fafe343: * graph/gblender.c (gblender_set_gamma_table): Reintroduce linear loops.
Date: Wed, 17 Aug 2022 10:03:25 -0400 (EDT)

branch: master
commit fafe3433ae00c1d5d53f346c863f8d4c6cad4a73
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>

    * graph/gblender.c (gblender_set_gamma_table): Reintroduce linear loops.
---
 graph/gblender.c | 31 ++++++-------------------------
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/graph/gblender.c b/graph/gblender.c
index 596afbf..33860c5 100644
--- a/graph/gblender.c
+++ b/graph/gblender.c
@@ -72,44 +72,25 @@ gblender_set_gamma_table( double           gamma_value,
   if ( gamma_value <= 0 )  /* special case for sRGB */
   {
     double  d;
-    int     linear = 0;
 
 
     /* voltage to linear; power function using finite differences */
-    for ( p = gmax, ii = 255; ii >= 0; ii--, p -= d )
+    for ( p = gmax, ii = 255; ii > 10; ii--, p -= d )
     {
       gamma_ramp[ii] = (unsigned short)( p + 0.5 );
-
-      if ( linear )
-        continue;
-
       d = 2.4 * p / ( ii + 255. * 0.055 );  /* derivative */
-
-      if ( ii == 10 )  /* same as d < p / ii */
-      {
-        d = p / ii;
-        linear = 1;
-      }
     }
-
-    linear = 0;
+    for ( d = p / ii; ii >= 0; ii--, p -= d )
+      gamma_ramp[ii] = (unsigned short)( p + 0.5 );
 
     /* linear to voltage; power function using finite differences */
-    for ( p = 255., ii = gmax; ii >= 0; ii--, p -= d )
+    for ( p = 255., ii = gmax; p > 10.02; ii--, p -= d )
     {
       gamma_ramp_inv[ii] = (unsigned char)( p + 0.5 );
-
-      if ( linear )
-        continue;
-
       d = ( p + 255. * 0.055 ) / ( 2.4 * ii );  /* derivative */
-
-      if ( p < 10.02 )  /* same as d > p / ii */
-      {
-        d = p / ii;
-        linear = 1;
-      }
     }
+    for ( d = p / ii; ii >= 0; ii--, p -= d )
+      gamma_ramp_inv[ii] = (unsigned short)( p + 0.5 );
   }
   else
   {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]