freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [sdf] Use 8 bits for final SDF output i


From: Anuj Verma (@anujv)
Subject: [Git][freetype/freetype][master] [sdf] Use 8 bits for final SDF output instead of 16bits.
Date: Tue, 08 Jun 2021 03:00:09 +0000

Anuj Verma pushed to branch master at FreeType / FreeType

Commits:

8 changed files:

Changes:

  • ChangeLog
    1
    +2021-06-08  Anuj Verma  <anujv@iitbhilai.ac.in>
    
    2
    +
    
    3
    +	[sdf] Use 8 bits for final SDF output instead of 16bits.
    
    4
    +
    
    5
    +	Since 8-bits is enough to represent SDF data we no longer require
    
    6
    +	16-bits for  this purpose. Also, we now normalize the output data
    
    7
    +	to use the entire 8-bit range efficiently. For example: if we use
    
    8
    +	3.5 format with a spread of 1 we basically only use the starting
    
    9
    +	5-bits. By normalizing we can use the entire 8-bit range.
    
    10
    +
    
    11
    +	* include/freetype/freetype.h (FT_Render_Mode): Updated description
    
    12
    +	for `FT_RENDER_MODE_SDF` regarding this change.
    
    13
    +
    
    14
    +	* include/freetype/ftimage.h (FT_Pixel_Mode): Removed
    
    15
    +	`FT_PIXEL_MODE_GRAY16` since no longer required.
    
    16
    +
    
    17
    +	* include/freetype/fttypes.h (FT_F6Dot10): Removed since no longer
    
    18
    +	required.
    
    19
    +
    
    20
    +	* src/sdf/ftsdfrend.c (ft_sdf_render, ft_bsdf_render): Allocate 8-bit
    
    21
    +	bitmap instead of 16-bit buffer.
    
    22
    +
    
    23
    +	* src/sdf/ftsdfcommon.h (map_fixed_to_sdf): Added function to convert
    
    24
    +	16.16 distance value to our desired format.
    
    25
    +
    
    26
    +	* src/sdf/ftsdf.c (sdf_generate_with_overlaps,
    
    27
    +	sdf_generate_bounding_box): Use the new `map_fixed_to_sdf` function
    
    28
    +	and also use 8-bit output buffer.
    
    29
    +
    
    30
    +	* src/sdf/ftbsdf.c (finalize_sdf): Output to a 8-bit buffer instead
    
    31
    +	of 16-bit buffer.
    
    32
    +
    
    1 33
     2021-06-02  Ben Wagner  <bungeman@chromium.org>
    
    2 34
     	    Werner Lemberg  <wl@gnu.org>
    
    3 35
     
    

  • include/freetype/freetype.h
    ... ... @@ -3302,19 +3302,46 @@ FT_BEGIN_HEADER
    3302 3302
        *     pixels and use the @FT_PIXEL_MODE_LCD_V mode.
    
    3303 3303
        *
    
    3304 3304
        *   FT_RENDER_MODE_SDF ::
    
    3305
    -   *     This mode corresponds to 16-bit signed distance fields (SDF)
    
    3305
    +   *     This mode corresponds to 8-bit signed distance fields (SDF)
    
    3306 3306
        *     bitmaps.  Each pixel in a SDF bitmap contains information about the
    
    3307 3307
        *     nearest edge of the glyph outline.  The distances are calculated
    
    3308 3308
        *     from the center of the pixel and are positive if they are filled by
    
    3309
    -   *     the outline (i.e., inside the outline) and negative otherwise.  The
    
    3310
    -   *     output bitmap buffer is represented as 6.10 fixed-point values; use
    
    3311
    -   *     @FT_F6Dot10 and convert accordingly.
    
    3309
    +   *     the outline (i.e., inside the outline) and negative otherwise. Check
    
    3310
    +   *     the note below on how to convert the output values to usable data.
    
    3312 3311
        *
    
    3313 3312
        * @note:
    
    3314 3313
        *   The selected render mode only affects vector glyphs of a font.
    
    3315 3314
        *   Embedded bitmaps often have a different pixel mode like
    
    3316 3315
        *   @FT_PIXEL_MODE_MONO.  You can use @FT_Bitmap_Convert to transform them
    
    3317 3316
        *   into 8-bit pixmaps.
    
    3317
    +   *
    
    3318
    +   *   For @FT_RENDER_MODE_SDF output bitmap buffer contains normalized
    
    3319
    +   *   distance values that are packed into unsigned 8-bit buffer.  To get
    
    3320
    +   *   pixel values in floating point representation use the following
    
    3321
    +   *   conversion:
    
    3322
    +   *
    
    3323
    +   *   ```
    
    3324
    +   *   <load glyph and render using @FT_RENDER_MODE_SDF, then use the
    
    3325
    +   *    output buffer as follows>
    
    3326
    +   *
    
    3327
    +   *   ...
    
    3328
    +   *   FT_Byte buffer = glyph->bitmap->buffer;
    
    3329
    +   *
    
    3330
    +   *   for pixel in buffer
    
    3331
    +   *   {
    
    3332
    +   *     <`sd` is the signed distance and spread is the current `spread`,
    
    3333
    +   *      the default spread is 2 and can be changed>
    
    3334
    +   *
    
    3335
    +   *     float sd = (float)pixel - 128.0f;
    
    3336
    +   *
    
    3337
    +   *     <convert the to pixel values>
    
    3338
    +   *
    
    3339
    +   *     sd = ( sd / 128.0f ) * spread;
    
    3340
    +   *
    
    3341
    +   *     <store `sd` in a buffer or use as required>
    
    3342
    +   *   }
    
    3343
    +   *
    
    3344
    +   *   ```
    
    3318 3345
        */
    
    3319 3346
       typedef enum  FT_Render_Mode_
    
    3320 3347
       {
    

  • include/freetype/ftimage.h
    ... ... @@ -157,13 +157,6 @@ FT_BEGIN_HEADER
    157 157
        *     in font files according to the OpenType specification.  We haven't
    
    158 158
        *     found a single font using this format, however.
    
    159 159
        *
    
    160
    -   *   FT_PIXEL_MODE_GRAY16 ::
    
    161
    -   *     A 16-bit per pixel bitmap used to represent signed distances in a
    
    162
    -   *     signed distance field bitmap as needed by @FT_RENDER_MODE_SDF.
    
    163
    -   *     Values are represented in a 6.10 fixed-point format; this means
    
    164
    -   *     that you have to divide by 1024 to get the actual data generated by
    
    165
    -   *     the SDF rasterizers.
    
    166
    -   *
    
    167 160
        *   FT_PIXEL_MODE_LCD ::
    
    168 161
        *     An 8-bit bitmap, representing RGB or BGR decimated glyph images used
    
    169 162
        *     for display on LCD displays; the bitmap is three times wider than
    
    ... ... @@ -194,7 +187,6 @@ FT_BEGIN_HEADER
    194 187
         FT_PIXEL_MODE_LCD,
    
    195 188
         FT_PIXEL_MODE_LCD_V,
    
    196 189
         FT_PIXEL_MODE_BGRA,
    
    197
    -    FT_PIXEL_MODE_GRAY16,
    
    198 190
     
    
    199 191
         FT_PIXEL_MODE_MAX      /* do not remove */
    
    200 192
     
    

  • include/freetype/fttypes.h
    ... ... @@ -78,7 +78,6 @@ FT_BEGIN_HEADER
    78 78
        *   FT_FWord
    
    79 79
        *   FT_UFWord
    
    80 80
        *   FT_F2Dot14
    
    81
    -   *   FT_F6Dot10
    
    82 81
        *   FT_UnitVector
    
    83 82
        *   FT_F26Dot6
    
    84 83
        *   FT_Data
    
    ... ... @@ -265,17 +264,6 @@ FT_BEGIN_HEADER
    265 264
       typedef signed short  FT_F2Dot14;
    
    266 265
     
    
    267 266
     
    
    268
    -  /**************************************************************************
    
    269
    -   *
    
    270
    -   * @type:
    
    271
    -   *   FT_F6Dot10
    
    272
    -   *
    
    273
    -   * @description:
    
    274
    -   *   A signed 6.10 fixed-point type used for signed distance values.
    
    275
    -   */
    
    276
    -  typedef signed short  FT_F6Dot10;
    
    277
    -
    
    278
    -
    
    279 267
       /**************************************************************************
    
    280 268
        *
    
    281 269
        * @type:
    

  • src/sdf/ftbsdf.c
    ... ... @@ -1092,12 +1092,12 @@
    1092 1092
       finalize_sdf( BSDF_Worker*      worker,
    
    1093 1093
                     const FT_Bitmap*  target )
    
    1094 1094
       {
    
    1095
    -    FT_Error  error = FT_Err_Ok;
    
    1095
    +    FT_Error      error = FT_Err_Ok;
    
    1096 1096
     
    
    1097
    -    FT_Int    w, r;
    
    1098
    -    FT_Int    i, j;
    
    1099
    -    FT_6D10*  t_buffer;
    
    1100
    -    FT_16D16  spread;
    
    1097
    +    FT_Int        w, r;
    
    1098
    +    FT_Int        i, j;
    
    1099
    +    FT_SDFFormat* t_buffer;
    
    1100
    +    FT_16D16      spread;
    
    1101 1101
     
    
    1102 1102
     
    
    1103 1103
         if ( !worker || !target )
    
    ... ... @@ -1108,7 +1108,7 @@
    1108 1108
     
    
    1109 1109
         w        = (int)target->width;
    
    1110 1110
         r        = (int)target->rows;
    
    1111
    -    t_buffer = (FT_6D10*)target->buffer;
    
    1111
    +    t_buffer = (FT_SDFFormat*)target->buffer;
    
    1112 1112
     
    
    1113 1113
         if ( w != worker->width ||
    
    1114 1114
              r != worker->rows  )
    
    ... ... @@ -1128,10 +1128,10 @@
    1128 1128
         {
    
    1129 1129
           for ( i = 0; i < w; i++ )
    
    1130 1130
           {
    
    1131
    -        FT_Int    index;
    
    1132
    -        FT_16D16  dist;
    
    1133
    -        FT_6D10   final_dist;
    
    1134
    -        FT_Char   sign;
    
    1131
    +        FT_Int       index;
    
    1132
    +        FT_16D16     dist;
    
    1133
    +        FT_SDFFormat final_dist;
    
    1134
    +        FT_Char      sign;
    
    1135 1135
     
    
    1136 1136
     
    
    1137 1137
             index = j * w + i;
    
    ... ... @@ -1144,10 +1144,6 @@
    1144 1144
             dist = square_root( dist );
    
    1145 1145
     #endif
    
    1146 1146
     
    
    1147
    -        /* convert from 16.16 to 6.10 */
    
    1148
    -        dist      /= 64;
    
    1149
    -        final_dist = (FT_6D10)(dist & 0x0000FFFF);
    
    1150
    -
    
    1151 1147
             /* We assume that if the pixel is inside a contour */
    
    1152 1148
             /* its coverage value must be > 127.               */
    
    1153 1149
             sign = worker->distance_map[index].alpha < 127 ? -1 : 1;
    
    ... ... @@ -1156,7 +1152,10 @@
    1156 1152
             if ( worker->params.flip_sign )
    
    1157 1153
               sign = -sign;
    
    1158 1154
     
    
    1159
    -        t_buffer[index] = final_dist * sign;
    
    1155
    +        /* concatenate from 16.16 to appropriate format */
    
    1156
    +        final_dist = map_fixed_to_sdf( dist * sign, spread );
    
    1157
    +
    
    1158
    +        t_buffer[index] = final_dist;
    
    1160 1159
           }
    
    1161 1160
         }
    
    1162 1161
     
    

  • src/sdf/ftsdf.c
    ... ... @@ -2897,6 +2897,10 @@
    2897 2897
       /* `sdf_generate' is not used at the moment */
    
    2898 2898
     #if 0
    
    2899 2899
     
    
    2900
    +  #error "DO NOT USE THIS!"
    
    2901
    +  #error "The function still output 16-bit data which might cause memory"
    
    2902
    +  #error "corruption.  If required I will add this later."
    
    2903
    +
    
    2900 2904
       /**************************************************************************
    
    2901 2905
        *
    
    2902 2906
        * @Function:
    
    ... ... @@ -3193,7 +3197,7 @@
    3193 3197
         FT_Int  sp_sq;            /* max value to check   */
    
    3194 3198
     
    
    3195 3199
         SDF_Contour*  contours;   /* list of all contours */
    
    3196
    -    FT_Short*     buffer;     /* the bitmap buffer    */
    
    3200
    +    FT_SDFFormat* buffer;     /* the bitmap buffer    */
    
    3197 3201
     
    
    3198 3202
         /* This buffer has the same size in indices as the    */
    
    3199 3203
         /* bitmap buffer.  When we check a pixel position for */
    
    ... ... @@ -3202,6 +3206,8 @@
    3202 3206
         /* and also determine the signs properly.             */
    
    3203 3207
         SDF_Signed_Distance*  dists = NULL;
    
    3204 3208
     
    
    3209
    +    const FT_16D16 fixed_spread = FT_INT_16D16( spread );
    
    3210
    +
    
    3205 3211
     
    
    3206 3212
         if ( !shape || !bitmap )
    
    3207 3213
         {
    
    ... ... @@ -3229,12 +3235,12 @@
    3229 3235
         contours = shape->contours;
    
    3230 3236
         width    = (FT_Int)bitmap->width;
    
    3231 3237
         rows     = (FT_Int)bitmap->rows;
    
    3232
    -    buffer   = (FT_Short*)bitmap->buffer;
    
    3238
    +    buffer   = (FT_SDFFormat*)bitmap->buffer;
    
    3233 3239
     
    
    3234 3240
         if ( USE_SQUARED_DISTANCES )
    
    3235
    -      sp_sq = (FT_Int)FT_INT_16D16( spread * spread );
    
    3241
    +      sp_sq = fixed_spread * fixed_spread;
    
    3236 3242
         else
    
    3237
    -      sp_sq = (FT_Int)FT_INT_16D16( spread );
    
    3243
    +      sp_sq = fixed_spread;
    
    3238 3244
     
    
    3239 3245
         if ( width == 0 || rows == 0 )
    
    3240 3246
         {
    
    ... ... @@ -3347,21 +3353,23 @@
    3347 3353
             /* if the pixel is not set                     */
    
    3348 3354
             /* its shortest distance is more than `spread` */
    
    3349 3355
             if ( dists[index].sign == 0 )
    
    3350
    -          dists[index].distance = FT_INT_16D16( spread );
    
    3356
    +          dists[index].distance = fixed_spread;
    
    3351 3357
             else
    
    3352 3358
               current_sign = dists[index].sign;
    
    3353 3359
     
    
    3354 3360
             /* clamp the values */
    
    3355
    -        if ( dists[index].distance > (FT_Int)FT_INT_16D16( spread ) )
    
    3356
    -          dists[index].distance = FT_INT_16D16( spread );
    
    3357
    -
    
    3358
    -        /* convert from 16.16 to 6.10 */
    
    3359
    -        dists[index].distance /= 64;
    
    3360
    -
    
    3361
    -        if ( internal_params.flip_sign )
    
    3362
    -          buffer[index] = (FT_Short)dists[index].distance * -current_sign;
    
    3363
    -        else
    
    3364
    -          buffer[index] = (FT_Short)dists[index].distance * current_sign;
    
    3361
    +        if ( dists[index].distance > fixed_spread )
    
    3362
    +          dists[index].distance = fixed_spread;
    
    3363
    +
    
    3364
    +        /* flip sign if required */
    
    3365
    +        dists[index].distance *= internal_params.flip_sign ?
    
    3366
    +                                   -current_sign :
    
    3367
    +                                    current_sign;
    
    3368
    +
    
    3369
    +        /* concatenate to appropriate format */
    
    3370
    +        buffer[index] = map_fixed_to_sdf(
    
    3371
    +                          dists[index].distance,
    
    3372
    +                          fixed_spread );
    
    3365 3373
           }
    
    3366 3374
         }
    
    3367 3375
     
    
    ... ... @@ -3498,9 +3506,9 @@
    3498 3506
         SDF_Contour*  head;              /* head of the contour list      */
    
    3499 3507
         SDF_Shape     temp_shape;        /* temporary shape               */
    
    3500 3508
     
    
    3501
    -    FT_Memory  memory;               /* to allocate memory            */
    
    3502
    -    FT_6D10*   t;                    /* target bitmap buffer          */
    
    3503
    -    FT_Bool    flip_sign;            /* filp sign?                    */
    
    3509
    +    FT_Memory     memory;            /* to allocate memory            */
    
    3510
    +    FT_SDFFormat* t;                 /* target bitmap buffer          */
    
    3511
    +    FT_Bool       flip_sign;         /* filp sign?                    */
    
    3504 3512
     
    
    3505 3513
         /* orientation of all the separate contours */
    
    3506 3514
         SDF_Contour_Orientation*  orientations;
    
    ... ... @@ -3621,7 +3629,7 @@
    3621 3629
         shape->contours = head;
    
    3622 3630
     
    
    3623 3631
         /* cast the output bitmap buffer */
    
    3624
    -    t = (FT_6D10*)bitmap->buffer;
    
    3632
    +    t = (FT_SDFFormat*)bitmap->buffer;
    
    3625 3633
     
    
    3626 3634
         /* Iterate over all pixels and combine all separate    */
    
    3627 3635
         /* contours.  These are the rules for combining:       */
    
    ... ... @@ -3636,18 +3644,18 @@
    3636 3644
         {
    
    3637 3645
           for ( i = 0; i < width; i++ )
    
    3638 3646
           {
    
    3639
    -        FT_Int   id = j * width + i;         /* index of current pixel    */
    
    3640
    -        FT_Int   c;                          /* contour iterator          */
    
    3647
    +        FT_Int   id = j * width + i;     /* index of current pixel    */
    
    3648
    +        FT_Int   c;                      /* contour iterator          */
    
    3641 3649
     
    
    3642
    -        FT_6D10  val_c  = SHRT_MIN;          /* max clockwise value       */
    
    3643
    -        FT_6D10  val_ac = SHRT_MAX;          /* min counter-clockwise val */
    
    3650
    +        FT_SDFFormat val_c  = 0;         /* max clockwise value       */
    
    3651
    +        FT_SDFFormat val_ac = UCHAR_MAX; /* min counter-clockwise val */
    
    3644 3652
     
    
    3645 3653
     
    
    3646 3654
             /* iterate through all the contours */
    
    3647 3655
             for ( c = 0; c < num_contours; c++ )
    
    3648 3656
             {
    
    3649 3657
               /* current contour value */
    
    3650
    -          FT_6D10  temp = ((FT_6D10*)bitmaps[c].buffer)[id];
    
    3658
    +          FT_SDFFormat temp = ( (FT_SDFFormat*)bitmaps[c].buffer )[id];
    
    3651 3659
     
    
    3652 3660
     
    
    3653 3661
               if ( orientations[c] == SDF_ORIENTATION_CW )
    
    ... ... @@ -3658,7 +3666,10 @@
    3658 3666
     
    
    3659 3667
             /* Finally find the smaller of the two and assign to output. */
    
    3660 3668
             /* Also apply `flip_sign` if set.                            */
    
    3661
    -        t[id] = FT_MIN( val_c, val_ac ) * ( flip_sign ? -1 : 1 );
    
    3669
    +        t[id] = FT_MIN( val_c, val_ac );
    
    3670
    +
    
    3671
    +        if ( flip_sign )
    
    3672
    +          t[id] = invert_sign( t[id] );
    
    3662 3673
           }
    
    3663 3674
         }
    
    3664 3675
     
    
    ... ... @@ -3681,6 +3692,9 @@
    3681 3692
           }
    
    3682 3693
         }
    
    3683 3694
     
    
    3695
    +    /* restore the `flip_sign` property */
    
    3696
    +    internal_params.flip_sign = flip_sign;
    
    3697
    +
    
    3684 3698
         return error;
    
    3685 3699
       }
    
    3686 3700
     
    

  • src/sdf/ftsdfcommon.h
    ... ... @@ -115,7 +115,7 @@ FT_BEGIN_HEADER
    115 115
     
    
    116 116
       typedef FT_Fixed  FT_16D16;      /* 16.16 fixed-point representation  */
    
    117 117
       typedef FT_Fixed  FT_26D6;       /* 26.6 fixed-point representation   */
    
    118
    -  typedef FT_Short  FT_6D10;       /* 6.10 fixed-point representation   */
    
    118
    +  typedef FT_Byte   FT_SDFFormat;  /* format to represent SDF data      */
    
    119 119
     
    
    120 120
       typedef FT_BBox   FT_CBox;       /* control box of a curve            */
    
    121 121
     
    
    ... ... @@ -162,6 +162,75 @@ FT_BEGIN_HEADER
    162 162
         return (FT_16D16)q;
    
    163 163
       }
    
    164 164
     
    
    165
    +  /**************************************************************************
    
    166
    +   *
    
    167
    +   * format and sign manipulating functions
    
    168
    +   *
    
    169
    +   */
    
    170
    +
    
    171
    +  /*
    
    172
    +   * Convert 16.16 fixed point value to the desired output format.
    
    173
    +   * In this case we reduce 16.16 fixed point value to normalized
    
    174
    +   * 8-bit values.
    
    175
    +   * The `max_value` in the parameter is the maximum value in the
    
    176
    +   * distance field map and is equal to the spread.  We normalize
    
    177
    +   * the distances using this value instead of computing the maximum
    
    178
    +   * value for the entire bitmap.
    
    179
    +   * You can use this function to map the 16.16 signed values to any
    
    180
    +   * format required. Do note that the output buffer is 8-bit, so only
    
    181
    +   * use 8-bit format for `FT_SDFFormat`, or increase buffer size in
    
    182
    +   * `ftsdfrend.c`.
    
    183
    +   */
    
    184
    +  static FT_SDFFormat
    
    185
    +  map_fixed_to_sdf( FT_16D16 dist, FT_16D16 max_value )
    
    186
    +  {
    
    187
    +    FT_SDFFormat out;
    
    188
    +    FT_16D16     udist;
    
    189
    +
    
    190
    +
    
    191
    +    /* normalize the distance values */
    
    192
    +    dist = FT_DivFix( dist, max_value );
    
    193
    +
    
    194
    +    udist = dist < 0 ? -dist : dist;
    
    195
    +
    
    196
    +    /* Reduce the distance values to 8 bits, +1/-1 in   */
    
    197
    +    /* 16.16 takes the 16th bit.  So we right shift the */
    
    198
    +    /* number by 9 to make it fit in the 7 bit range.   */
    
    199
    +    /* 1 bit is reserved for the sign.                  */
    
    200
    +    udist >>= 9;
    
    201
    +
    
    202
    +    /* Since char can only store max positive value */
    
    203
    +    /* of 127 we need to make sure it does not wrap */
    
    204
    +    /* around and give a negative value.            */
    
    205
    +    if ( dist > 0 && udist > 127 )
    
    206
    +      udist = 127;
    
    207
    +    if ( dist < 0 && udist > 128 )
    
    208
    +      udist = 128;
    
    209
    +
    
    210
    +    /* Output the data; negative values are from [0, 127] and positive    */
    
    211
    +    /* from [128, 255].  One important thing is that negative values      */
    
    212
    +    /* are inverted here, that means [0, 128] maps to [-128, 0] linearly. */
    
    213
    +    /* More on that in `freetype.h` near `FT_RENDER_MODE_SDF`             */
    
    214
    +    out = dist < 0 ? 128 - (FT_SDFFormat)udist :
    
    215
    +                     (FT_SDFFormat)udist + 128;
    
    216
    +    return out;
    
    217
    +  }
    
    218
    +
    
    219
    +  /*
    
    220
    +   * Invert the signed distance packed into the corresponding format.
    
    221
    +   * So if the values are negative they will become positive in the
    
    222
    +   * chosen format.
    
    223
    +   *
    
    224
    +   * [Note]: This function should only be used after converting the
    
    225
    +   *         16.16 signed distance values to `FT_SDFFormat`, if that
    
    226
    +   *         conversion has not been done, then simply invert the sign
    
    227
    +   *         and use the above function to pack the values.
    
    228
    +   */
    
    229
    +  static FT_SDFFormat
    
    230
    +  invert_sign( FT_SDFFormat dist ) {
    
    231
    +    return 255 - dist;
    
    232
    +  }
    
    233
    +
    
    165 234
     
    
    166 235
     FT_END_HEADER
    
    167 236
     
    

  • src/sdf/ftsdfrend.c
    ... ... @@ -313,9 +313,9 @@
    313 313
         bitmap->width += x_pad * 2;
    
    314 314
     
    
    315 315
         /* ignore the pitch, pixel mode and set custom */
    
    316
    -    bitmap->pixel_mode = FT_PIXEL_MODE_GRAY16;
    
    317
    -    bitmap->pitch      = (int)( bitmap->width * 2 );
    
    318
    -    bitmap->num_grays  = 65535;
    
    316
    +    bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
    
    317
    +    bitmap->pitch      = (int)( bitmap->width );
    
    318
    +    bitmap->num_grays  = 255;
    
    319 319
     
    
    320 320
         /* allocate new buffer */
    
    321 321
         if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) )
    
    ... ... @@ -524,9 +524,9 @@
    524 524
         target.width = bitmap->width + x_pad * 2;
    
    525 525
     
    
    526 526
         /* set up the target bitmap */
    
    527
    -    target.pixel_mode = FT_PIXEL_MODE_GRAY16;
    
    528
    -    target.pitch      = (int)( target.width * 2 );
    
    529
    -    target.num_grays  = 65535;
    
    527
    +    target.pixel_mode = FT_PIXEL_MODE_GRAY;
    
    528
    +    target.pitch      = (int)( target.width );
    
    529
    +    target.num_grays  = 255;
    
    530 530
     
    
    531 531
         if ( FT_ALLOC_MULT( target.buffer, target.rows, target.pitch ) )
    
    532 532
           goto Exit;
    


  • reply via email to

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