freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 406e388: [ftstring, ftview] Auxiliary gamma rou


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master 406e388: [ftstring, ftview] Auxiliary gamma rounding fixes.
Date: Sun, 20 Dec 2015 03:46:18 +0000

branch: master
commit 406e3888e74060e7fabc73b37539f91acddf2b59
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [ftstring, ftview] Auxiliary gamma rounding fixes.
    
    * src/ftstring.c (event_gamma_change): Updated.
    * src/ftview.c (event_gamma_grid): Updated.
---
 ChangeLog      |    7 +++++++
 src/ftstring.c |    8 ++++----
 src/ftview.c   |    2 +-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 01d0511..fdfd979 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2015-12-18  Alexei Podtelezhnikov  <address@hidden>
 
+       [ftstring, ftview] Auxiliary gamma rounding fixes.
+
+       * src/ftstring.c (event_gamma_change): Updated.
+       * src/ftview.c (event_gamma_grid): Updated.
+
+2015-12-18  Alexei Podtelezhnikov  <address@hidden>
+
        * graph/gblender.c (gblender_set_gamma_table): Rounding, formatting.
 
 2015-12-15  Werner Lemberg  <address@hidden>
diff --git a/src/ftstring.c b/src/ftstring.c
index e0ddcf4..90dc38e 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -49,7 +49,7 @@
 
     FTDemo_String_Context  sc;
 
-    FT_Byte      gamma_ramp[256];
+    FT_Byte      gamma_ramp[256];   /* for show only */
     FT_Matrix    trans_matrix;
     int          font_index;
     char*        header;
@@ -262,11 +262,11 @@
 
     grSetGlyphGamma( status.gamma );
 
-    gamma_inv = 1.0f / status.gamma;
+    gamma_inv = 1. / status.gamma;
 
     for ( i = 0; i < 256; i++ )
-      status.gamma_ramp[i] = (FT_Byte)( pow( (double)i / 255.0f, gamma_inv )
-                                        * 255.0f );
+      status.gamma_ramp[i] = (FT_Byte)( pow( (double)i / 255., gamma_inv )
+                                        * 255. + 0.5 );
   }
 
 
diff --git a/src/ftview.c b/src/ftview.c
index 2cec548..f845899 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -878,7 +878,7 @@
         for ( nx = 0; nx < levels; nx++, dst += 3 * xside )
         {
           double  p   = nx / (double)( levels - 1 );
-          int     gm  = (int)( 255.0 * pow( p, ggamma ) );
+          int     gm  = (int)( 255.0 * pow( p, ggamma ) + 0.5 );
 
 
           memset( dst, gm, (unsigned int)( xside * 3 ) );



reply via email to

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