freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][master] * graph/win32/grwin32.c (gr_win32


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][master] * graph/win32/grwin32.c (gr_win32_surface_init): Polish gray mode.
Date: Sat, 21 Jan 2023 18:41:33 +0000

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

Commits:

  • dbb7650b
    by Alexei Podtelezhnikov at 2023-01-21T18:41:31+00:00
    * graph/win32/grwin32.c (gr_win32_surface_init): Polish gray mode.

1 changed file:

Changes:

  • graph/win32/grwin32.c
    ... ... @@ -432,7 +432,6 @@ gr_win32_surface_init( grWin32Surface* surface,
    432 432
     {
    
    433 433
       MSG  msg;
    
    434 434
     
    
    435
    -  surface->root.bitmap.grays = bitmap->grays;
    
    436 435
     
    
    437 436
       /* Set default mode */
    
    438 437
       if ( bitmap->mode == gr_pixel_mode_none )
    
    ... ... @@ -447,7 +446,8 @@ gr_win32_surface_init( grWin32Surface* surface,
    447 446
         switch ( bpp )
    
    448 447
         {
    
    449 448
         case 8:
    
    450
    -      surface->root.bitmap.mode = gr_pixel_mode_gray;
    
    449
    +      surface->root.bitmap.mode  = gr_pixel_mode_gray;
    
    450
    +      surface->root.bitmap.grays = 256;
    
    451 451
           break;
    
    452 452
         case 16:
    
    453 453
           surface->root.bitmap.mode = gr_pixel_mode_rgb565;
    
    ... ... @@ -461,7 +461,10 @@ gr_win32_surface_init( grWin32Surface* surface,
    461 461
         }
    
    462 462
       }
    
    463 463
       else
    
    464
    +  {
    
    464 465
         surface->root.bitmap.mode  = bitmap->mode;
    
    466
    +    surface->root.bitmap.grays = bitmap->grays;
    
    467
    +  }
    
    465 468
     
    
    466 469
       if ( !gr_win32_surface_resize( surface, bitmap->width, bitmap->rows ) )
    
    467 470
         return 0;
    
    ... ... @@ -484,17 +487,16 @@ gr_win32_surface_init( grWin32Surface* surface,
    484 487
     
    
    485 488
       case gr_pixel_mode_gray:
    
    486 489
         surface->bmiHeader.biBitCount = 8;
    
    487
    -    surface->bmiHeader.biClrUsed  = bitmap->grays;
    
    490
    +    surface->bmiHeader.biClrUsed  = surface->root.bitmap.grays;
    
    488 491
         {
    
    489
    -      int   count = bitmap->grays;
    
    490
    -      int   x;
    
    492
    +      int       x, count = surface->root.bitmap.grays - 1;
    
    491 493
           RGBQUAD*  color = surface->bmiColors;
    
    492 494
     
    
    493
    -      for ( x = 0; x < count; x++, color++ )
    
    495
    +      for ( x = 0; x <= count; x++, color++ )
    
    494 496
           {
    
    495 497
             color->rgbRed   =
    
    496 498
             color->rgbGreen =
    
    497
    -        color->rgbBlue  = (unsigned char)(x*255/(count-1));
    
    499
    +        color->rgbBlue  = (BYTE)( x * 255 / count );
    
    498 500
             color->rgbReserved = 0;
    
    499 501
           }
    
    500 502
         }
    


  • reply via email to

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