freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][master] * graph/gblender.c (gblender_set_


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][master] * graph/gblender.c (gblender_set_gamma_table): Reintroduce linear loops.
Date: Wed, 17 Aug 2022 14:03:16 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType Demo Programs

Commits:

  • fafe3433
    by Alexei Podtelezhnikov at 2022-08-17T14:03:14+00:00
    * graph/gblender.c (gblender_set_gamma_table): Reintroduce linear loops.

1 changed file:

Changes:

  • graph/gblender.c
    ... ... @@ -72,44 +72,25 @@ gblender_set_gamma_table( double gamma_value,
    72 72
       if ( gamma_value <= 0 )  /* special case for sRGB */
    
    73 73
       {
    
    74 74
         double  d;
    
    75
    -    int     linear = 0;
    
    76 75
     
    
    77 76
     
    
    78 77
         /* voltage to linear; power function using finite differences */
    
    79
    -    for ( p = gmax, ii = 255; ii >= 0; ii--, p -= d )
    
    78
    +    for ( p = gmax, ii = 255; ii > 10; ii--, p -= d )
    
    80 79
         {
    
    81 80
           gamma_ramp[ii] = (unsigned short)( p + 0.5 );
    
    82
    -
    
    83
    -      if ( linear )
    
    84
    -        continue;
    
    85
    -
    
    86 81
           d = 2.4 * p / ( ii + 255. * 0.055 );  /* derivative */
    
    87
    -
    
    88
    -      if ( ii == 10 )  /* same as d < p / ii */
    
    89
    -      {
    
    90
    -        d = p / ii;
    
    91
    -        linear = 1;
    
    92
    -      }
    
    93 82
         }
    
    94
    -
    
    95
    -    linear = 0;
    
    83
    +    for ( d = p / ii; ii >= 0; ii--, p -= d )
    
    84
    +      gamma_ramp[ii] = (unsigned short)( p + 0.5 );
    
    96 85
     
    
    97 86
         /* linear to voltage; power function using finite differences */
    
    98
    -    for ( p = 255., ii = gmax; ii >= 0; ii--, p -= d )
    
    87
    +    for ( p = 255., ii = gmax; p > 10.02; ii--, p -= d )
    
    99 88
         {
    
    100 89
           gamma_ramp_inv[ii] = (unsigned char)( p + 0.5 );
    
    101
    -
    
    102
    -      if ( linear )
    
    103
    -        continue;
    
    104
    -
    
    105 90
           d = ( p + 255. * 0.055 ) / ( 2.4 * ii );  /* derivative */
    
    106
    -
    
    107
    -      if ( p < 10.02 )  /* same as d > p / ii */
    
    108
    -      {
    
    109
    -        d = p / ii;
    
    110
    -        linear = 1;
    
    111
    -      }
    
    112 91
         }
    
    92
    +    for ( d = p / ii; ii >= 0; ii--, p -= d )
    
    93
    +      gamma_ramp_inv[ii] = (unsigned short)( p + 0.5 );
    
    113 94
       }
    
    114 95
       else
    
    115 96
       {
    


  • reply via email to

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