freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][master] [graph] Handle glyphs with 4 or 1


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][master] [graph] Handle glyphs with 4 or 16 grays.
Date: Thu, 02 Mar 2023 14:27:05 +0000

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

Commits:

  • 746d5be5
    by Alexei Podtelezhnikov at 2023-03-02T07:25:47-05:00
    [graph] Handle glyphs with 4 or 16 grays.
    
    * graph/gblblit.c (gblender_glyph_upgray): Convert to 256 grays.
    (gblender_blit_init): Call it if necessary.
    

1 changed file:

Changes:

  • graph/gblblit.c
    ... ... @@ -241,6 +241,29 @@
    241 241
     
    
    242 242
     /* */
    
    243 243
     
    
    244
    +/* works best to convert from 4 or 16 grays to 256 grays,
    
    245
    + * needs aligned buffers and clean padding
    
    246
    + */
    
    247
    +static void
    
    248
    +gblender_glyph_upgray( grBitmap*  glyph )
    
    249
    +{
    
    250
    +  int        i, size = abs( glyph->pitch ) * glyph->rows;
    
    251
    +  uint32_t*  buf = (uint32_t*)glyph->buffer;
    
    252
    +  uint32_t   scale = 255U / ( glyph->grays - 1 );
    
    253
    +
    
    254
    +
    
    255
    +  /* four bytes at a time */
    
    256
    +  for ( i = 0; i <= size - 4; i += 4, buf++ )
    
    257
    +    *buf *= scale;
    
    258
    +
    
    259
    +  /* remaining bytes */
    
    260
    +  for ( ; i < size; i++ )
    
    261
    +    glyph->buffer[i] *= scale;
    
    262
    +
    
    263
    +  glyph->grays = 256;
    
    264
    +}
    
    265
    +
    
    266
    +
    
    244 267
     static int
    
    245 268
     gblender_blit_init( GBlenderBlit           blit,
    
    246 269
                         int                    dst_x,
    
    ... ... @@ -269,6 +292,8 @@ gblender_blit_init( GBlenderBlit blit,
    269 292
       {
    
    270 293
       case gr_pixel_mode_gray:
    
    271 294
         src_format = GBLENDER_SOURCE_GRAY8;
    
    295
    +    if ( glyph->grays != 256 )
    
    296
    +      gblender_glyph_upgray( glyph );
    
    272 297
         if ( blender->channels )
    
    273 298
           gblender_clear( blender );
    
    274 299
         break;
    


  • reply via email to

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