freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master d909894: [graph/win32] Grayscale fixes.


From: Alexei Podtelezhnikov
Subject: [freetype2-demos] master d909894: [graph/win32] Grayscale fixes.
Date: Wed, 24 Jun 2020 22:44:01 -0400 (EDT)

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

    [graph/win32] Grayscale fixes.
    
    * graph/win32/grwin32.c (gr_win32_surface_init): Straighten mapping.
    (gr_win32_surface_refresh_rectangle): Use `memcpy'.
    
    * graph/grobjs.c (grNewBitmap): Add padding to gray required by GDI.
---
 ChangeLog             | 11 ++++++++++-
 graph/grobjs.c        |  2 +-
 graph/win32/grwin32.c |  9 ++-------
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 892bc68..0edf582 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,13 @@
-2020-06-20  Alexei Podtelezhnikov  <apodtele@gmail.com>
+2020-06-24  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+       [graph/win32] Grayscale fixes.
+
+       * graph/win32/grwin32.c (gr_win32_surface_init): Straighten mapping.
+       (gr_win32_surface_refresh_rectangle): Use `memcpy'.
+
+       * graph/grobjs.c (grNewBitmap): Add padding to gray required by GDI.
+
+2020-06-24  Alexei Podtelezhnikov  <apodtele@gmail.com>
 
        * graph/grobjs.c (grFindColor): Fortify gray luminance.
        * graph/gblblit.c (GRGB*_TO_GRAY8): Synchronize with `grFindColor'.
diff --git a/graph/grobjs.c b/graph/grobjs.c
index 0e932b7..09a9522 100644
--- a/graph/grobjs.c
+++ b/graph/grobjs.c
@@ -183,7 +183,7 @@
       case gr_pixel_mode_pal4  : pitch = (width+3) >> 2; break;
 
       case gr_pixel_mode_pal8  :
-      case gr_pixel_mode_gray  : pitch = width; break;
+      case gr_pixel_mode_gray  : pitch = ( width + 3 ) & ~3; break;
 
       case gr_pixel_mode_rgb555:
       case gr_pixel_mode_rgb565: pitch = width*2; break;
diff --git a/graph/win32/grwin32.c b/graph/win32/grwin32.c
index 9543ef9..c895ed6 100644
--- a/graph/win32/grwin32.c
+++ b/graph/win32/grwin32.c
@@ -217,12 +217,7 @@ gr_win32_surface_refresh_rectangle(
     {
       for ( ; height > 0; height-- )
       {
-        unsigned char*  read       = read_line;
-        unsigned char*  read_limit = read + width;
-        unsigned char*  write      = write_line;
-
-        for ( ; read < read_limit; read++, write++ )
-          *write = *read;
+        memcpy( write_line, read_line, width );
 
         read_line  += read_pitch;
         write_line += write_pitch;
@@ -472,7 +467,7 @@ gr_win32_surface_init( grWin32Surface*  surface,
       {
         color->rgbRed   =
         color->rgbGreen =
-        color->rgbBlue  = (unsigned char)(((count-x)*255)/count);
+        color->rgbBlue  = (unsigned char)(x*255/(count-1));
         color->rgbReserved = 0;
       }
     }



reply via email to

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