freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master ea90d7b: [ftgamma] Add box-filtered subpixel pa


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master ea90d7b: [ftgamma] Add box-filtered subpixel pattern.
Date: Sat, 4 Feb 2017 04:08:40 +0000 (UTC)

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

    [ftgamma] Add box-filtered subpixel pattern.
    
    Two alternative patterns now demonstrate the importance of correct
    gamma for both grayscale and subpixel anti-aliasing, where it helps
    normalize thickness in the former and remove color fringes in the
    latter.
    
    * src/ftgamma.*: Updated.
---
 ChangeLog     |   15 +++++++++++++++
 src/ftgamma.1 |   13 ++++++++-----
 src/ftgamma.c |   42 ++++++++++++++++++++++++++++--------------
 3 files changed, 51 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0859393..2ea4600 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2017-02-03  Alexei Podtelezhnikov  <address@hidden>
+
+       [ftgamma] Add box-filtered subpixel pattern.
+
+       Two alternative patterns now demonstrate the importance of correct
+       gamma for both grayscale and subpixel anti-aliasing, where it helps
+       normalize thickness in the former and remove color fringes in the
+       latter.
+
+       * src/ftgamma.*: Updated.
+
+2017-01-30  Alexei Podtelezhnikov  <address@hidden>
+
+       [ftview] Improve gamma ramp appearance.
+
 2017-01-28  Alexei Podtelezhnikov  <address@hidden>
 
        [ftstring] Improve gamma ramp appearance.
diff --git a/src/ftgamma.1 b/src/ftgamma.1
index 98faee2..4be6070 100644
--- a/src/ftgamma.1
+++ b/src/ftgamma.1
@@ -15,7 +15,7 @@ ftgamma \- screen gamma calibration helper
 .
 The
 .B ftgamma
-demo program opens a window showing series of grey stripes filled with
+demo program opens a window showing series of gray stripes filled with
 solid color and checkered pattern of pixels.  Your monitor's gamma value
 roughly corresponds to the horizontal position where the solid and checkered
 stripes are equally bright when seen from some distance.  Three brightness
@@ -25,10 +25,13 @@ slightly different gamma values at different brightness 
levels.  It is also
 possible to examine gamma values for basic colors.
 .
 .PP
-An alternative pattern of slightly slanted anti-aliased lines is provided
-to calibrate gamma for uniform perceived thickness of the lines.  The gamma
-value that corresponds to vanishing moiré pattern is ideal for anti-aliased
-font rendering.
+Two alternative patterns relevant to font rendering are also provided,
+where slightly slanted lines are rendered using grayscale and subpixel
+anti-aliasing.  In the grayscale case, the correct gamma helps to achieve
+uniform perceived thickness of the lines.  The gamma value that corresponds
+to vanishing moiré pattern is ideal for anti-aliased font rendering.
+In the subpixel case, the correct gamma removes color fringes that remain
+even after LCD filtering.
 .
 .PP
 This program does not have any options.
diff --git a/src/ftgamma.c b/src/ftgamma.c
index f3b49f1..84d4e39 100644
--- a/src/ftgamma.c
+++ b/src/ftgamma.c
@@ -18,8 +18,8 @@
   static FTDemo_Display*  display;
 
   static grBitmap   bit1 = { 300, 600, 600, gr_pixel_mode_gray, 256, NULL };
-  static grBitmap   bit2 = { 300, 600, 600, gr_pixel_mode_gray, 256, NULL };
-  static grBitmap*  bit;
+  static grBitmap   bit2 = { 288, 600, 600, gr_pixel_mode_gray, 256, NULL };
+  static int        status = 0;
 
 
   static void
@@ -74,13 +74,12 @@
   {
     int  x = 0;
     int  y = 0;
-    int  h = ( bitmap->rows - 2 * y ) / 3;
+    int  h = ( bitmap->rows - 2 * y ) / 2;
     int  w = bitmap->width - 2 * x;
 
 
     do_ptrn( bitmap, x,    y, w, h );
     do_ptrn( bitmap, x, y+=h, w, h );
-    do_ptrn( bitmap, x, y+=h, w, h );
 
     return 0;
   }
@@ -177,7 +176,7 @@
     grWriteln( "F1, ?       display this help screen" );
     grLn();
     grWriteln( "space       cycle through color");
-    grWriteln( "tab         alternate pattern");
+    grWriteln( "tab         alternate patterns");
     grWriteln( "G           show gamma ramp" );
     grLn();
     grLn();
@@ -282,10 +281,11 @@
                  grBitmap*  in,
                  int        x,
                  int        y,
-                 grColor    color )
+                 grColor    color,
+                int        lcd )
   {
     int  pitch = out->pitch;
-    int  i, j;
+    int  i, ii, j;
 
     unsigned char*  src;
     unsigned char*  dst;
@@ -294,7 +294,8 @@
     if ( color.chroma[0] == 255 )
       for ( src = in->buffer, i = 0; i < in->rows; i++ )
       {
-        dst = out->buffer + ( y + i ) * pitch + 3 * x;
+        ii = ( i + 24 * lcd ) % in->rows;
+        dst = out->buffer + ( y + ii ) * pitch + 3 * x;
         for ( j = 0; j < in->width; j++, src++, dst += 3 )
           *dst = *src;
       }
@@ -302,7 +303,8 @@
     if ( color.chroma[1] == 255 )
       for ( src = in->buffer, i = 0; i < in->rows; i++ )
       {
-        dst = out->buffer + ( y + i ) * pitch + 3 * x + 1;
+        ii = ( i + 12 * lcd ) % in->rows;
+        dst = out->buffer + ( y + ii ) * pitch + 3 * x + 1;
         for ( j = 0; j < in->width; j++, src++, dst += 3 )
           *dst = *src;
       }
@@ -310,7 +312,8 @@
     if ( color.chroma[2] == 255 )
       for ( src = in->buffer, i = 0; i < in->rows; i++ )
       {
-        dst = out->buffer + ( y + i ) * pitch + 3 * x + 2;
+        ii = ( i +  0 * lcd ) % in->rows;
+        dst = out->buffer + ( y + ii ) * pitch + 3 * x + 2;
         for ( j = 0; j < in->width; j++, src++, dst += 3 )
           *dst = *src;
       }
@@ -339,8 +342,9 @@
       break;
 
     case grKeyTab:
-      bit = bit == &bit1 ? &bit2
-                         : &bit1;
+      status++;
+      if ( status > 2 )
+        status = 0;
       break;
 
     case grKEY( 'G' ):
@@ -376,14 +380,24 @@
     grNewBitmap( bit2.mode, bit2.grays, bit2.width, bit2.rows, &bit2 );
     GammaPtrn( &bit2 );
 
-    bit = &bit1;
     event_color_change();
 
     do
     {
       FTDemo_Display_Clear( display );
 
-      Render_Bitmap( display->bitmap, bit, 20, 90, display->fore_color );
+      switch ( status )
+      {
+      case 0:
+        Render_Bitmap( display->bitmap, &bit1, 20, 90, display->fore_color, 0 
);
+        break;
+      case 1:
+        Render_Bitmap( display->bitmap, &bit2, 20, 96, display->fore_color, 0 
);
+        break;
+      case 2:
+        Render_Bitmap( display->bitmap, &bit2, 20, 96, display->fore_color, 1 
);
+        break;
+      }
 
       for ( i = 0; i <= 10; i++ )
       {



reply via email to

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