freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 5130698 1/2: [ftstring] Use shared `grSetGlyphG


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master 5130698 1/2: [ftstring] Use shared `grSetGlyphGamma'.
Date: Mon, 23 Nov 2015 04:18:19 +0000

branch: master
commit 5130698fb072776881fa29646f6838a69bb267e1
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [ftstring] Use shared `grSetGlyphGamma'.
    
    * src/ftcommon.h (FTDemo_String_Context): Remove `gamma_ramp'.
    * src/ftcommon.c (apply_gamma_ramp): Remove.
    (FTDemo_String_Draw): Do not apply gamma correction here.
    * src/ftstring.c (event_gamma_change): Call `grSetGlyphGamma' here.
    (main): Switch from gray to rgb24; update.
---
 ChangeLog      |   10 ++++++++++
 src/ftcommon.c |   24 ------------------------
 src/ftcommon.h |    1 -
 src/ftstring.c |   23 +++++++++++++----------
 4 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 57ec7e4..efc6037 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2015-11-22  Alexei Podtelezhnikov  <address@hidden>
 
+       [ftstring] Use shared `grSetGlyphGamma'.
+
+       * src/ftcommon.h (FTDemo_String_Context): Remove `gamma_ramp'.
+       * src/ftcommon.c (apply_gamma_ramp): Remove.
+       (FTDemo_String_Draw): Do not apply gamma correction here.
+       * src/ftstring.c (event_gamma_change): Call `grSetGlyphGamma' here.
+       (main): Switch from gray to rgb24; update.
+
+2015-11-22  Alexei Podtelezhnikov  <address@hidden>
+
        [ftstring] Remove gamma toggle.
 
        * src/ftstring.c (event_help, Process_Event): Updated.
diff --git a/src/ftcommon.c b/src/ftcommon.c
index d6844c8..b77c9d7 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -1207,27 +1207,6 @@
   }
 
 
-  static void
-  gamma_ramp_apply( FT_Byte    gamma_ramp[256],
-                    grBitmap*  bitmap )
-  {
-    int       i, j;
-    FT_Byte*  p = (FT_Byte*)bitmap->buffer;
-
-
-    if ( bitmap->pitch < 0 )
-      p += -bitmap->pitch * ( bitmap->rows - 1 );
-
-    for ( i = 0; i < bitmap->rows; i++ )
-    {
-      for ( j = 0; j < bitmap->width; j++ )
-        p[j] = gamma_ramp[p[j]];
-
-      p += bitmap->pitch;
-    }
-  }
-
-
   FT_Error
   FTDemo_String_Draw( FTDemo_Handle*          handle,
                       FTDemo_Display*         display,
@@ -1369,9 +1348,6 @@
                                         &dummy1, &dummy2, &glyf );
         if ( !error )
         {
-          if ( sc->gamma_ramp )
-            gamma_ramp_apply( sc->gamma_ramp, &bit3 );
-
           /* change back to the usual coordinates */
           top = display->bitmap->rows - top;
 
diff --git a/src/ftcommon.h b/src/ftcommon.h
index 48bce9a..1d73d6f 100644
--- a/src/ftcommon.h
+++ b/src/ftcommon.h
@@ -165,7 +165,6 @@
     FT_Fixed    center;            /* 0..1 */
     int         vertical;          /* displayed vertically? */
     FT_Matrix*  matrix;            /* string transformation */
-    FT_Byte*    gamma_ramp;        /* an array of size 256 */
 
   } FTDemo_String_Context;
 
diff --git a/src/ftstring.c b/src/ftstring.c
index 9a7a058..05ec47d 100644
--- a/src/ftstring.c
+++ b/src/ftstring.c
@@ -203,6 +203,8 @@
     else if ( status.gamma < 0.1 )
       status.gamma = 0.1;
 
+    grSetGlyphGamma( status.gamma );
+
     sprintf( status.header_buffer, "gamma changed to %.1f", status.gamma );
     status.header = status.header_buffer;
 
@@ -383,6 +385,7 @@
                    grBitmap*  bitmap )
   {
     int       i, x, y;
+    int       bpp = bitmap->pitch / bitmap->width;
     FT_Byte*  p = (FT_Byte*)bitmap->buffer;
 
 
@@ -393,7 +396,7 @@
     y = ( bitmap->rows + 256 ) / 2;
 
     for (i = 0; i < 256; i++)
-      p[bitmap->pitch * ( y - gamma_ramp[i] ) + ( x + i )] = 80;
+      p[bitmap->pitch * ( y - gamma_ramp[i] ) + bpp * ( x + i )] = 0x80;
   }
 
 
@@ -609,23 +612,25 @@
     if ( handle->num_fonts == 0 )
       PanicZ( "could not open any font file" );
 
-    display = FTDemo_Display_New( gr_pixel_mode_gray,
+    display = FTDemo_Display_New( gr_pixel_mode_rgb24,
                                   status.width, status.height );
-    display->back_color.value = 0;
-    display->fore_color.value = 0xff;
 
     if ( !display )
       PanicZ( "could not allocate display surface" );
 
+    display->back_color = grFindColor( display->bitmap,
+                                       0x00, 0x00, 0x00, 0xff );
+    display->fore_color = grFindColor( display->bitmap,
+                                       0xff, 0xff, 0xff, 0xff );
+
     grSetTitle( display->surface,
                 "FreeType String Viewer - press ? for help" );
 
     event_gamma_change( 0 );
-    status.sc.gamma_ramp = status.gamma_ramp;
     event_font_change( 0 );
     status.header = 0;
 
-    for ( ;; )
+    do
     {
       FTDemo_Display_Clear( display );
 
@@ -686,16 +691,14 @@
         break;
       }
 
-      if ( !error && status.sc.gamma_ramp )
+      if ( !error )
         gamma_ramp_draw( status.gamma_ramp, display->bitmap );
 
       write_header( error );
 
       status.header = 0;
       grListenSurface( display->surface, 0, &event );
-      if ( Process_Event( &event ) )
-        break;
-    }
+    } while ( !Process_Event( &event ) );
 
     printf( "Execution completed successfully.\n" );
 



reply via email to

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