freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][master] [graph] Complete removal of legac


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype-demos][master] [graph] Complete removal of legacy blitter.
Date: Wed, 17 Nov 2021 03:10:48 +0000

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

Commits:

9 changed files:

Changes:

  • builds/windows/msvc/migs.vcxproj
    ... ... @@ -142,7 +142,6 @@
    142 142
       <ItemGroup>
    
    143 143
         <ClCompile Include="..\..\..\graph\gblblit.c" />
    
    144 144
         <ClCompile Include="..\..\..\graph\gblender.c" />
    
    145
    -    <ClCompile Include="..\..\..\graph\grblit.c" />
    
    146 145
         <ClCompile Include="..\..\..\graph\grdevice.c" />
    
    147 146
         <ClCompile Include="..\..\..\graph\grfill.c" />
    
    148 147
         <ClCompile Include="..\..\..\graph\grfont.c" />
    
    ... ... @@ -166,7 +165,6 @@
    166 165
         <ClInclude Include="..\..\..\graph\gblvbgr.h" />
    
    167 166
         <ClInclude Include="..\..\..\graph\gblvrgb.h" />
    
    168 167
         <ClInclude Include="..\..\..\graph\graph.h" />
    
    169
    -    <ClInclude Include="..\..\..\graph\grblit.h" />
    
    170 168
         <ClInclude Include="..\..\..\graph\grconfig.h" />
    
    171 169
         <ClInclude Include="..\..\..\graph\grdevice.h" />
    
    172 170
         <ClInclude Include="..\..\..\graph\grevents.h" />
    

  • graph/graph.h
    ... ... @@ -194,47 +194,6 @@
    194 194
                                 grBitmap    *bit );
    
    195 195
     
    
    196 196
     
    
    197
    - /**********************************************************************
    
    198
    -  *
    
    199
    -  * <Function>
    
    200
    -  *    grBlitGlyphToBitmap
    
    201
    -  *
    
    202
    -  * <Description>
    
    203
    -  *    writes a given glyph bitmap to a target surface.
    
    204
    -  *
    
    205
    -  * <Input>
    
    206
    -  *    target  :: handle to target bitmap that belongs to surface
    
    207
    -  *    glyph   :: handle to source glyph bitmap
    
    208
    -  *    x       :: position of left-most pixel of glyph image in target surface
    
    209
    -  *    y       :: position of top-most pixel of glyph image in target surface
    
    210
    -  *    color   :: color to be used to draw a monochrome glyph
    
    211
    -  *
    
    212
    -  * <Return>
    
    213
    -  *   Error code. 0 means success
    
    214
    -  *
    
    215
    -  * <Note>
    
    216
    -  *   There are only two supported source pixel modes : monochrome
    
    217
    -  *   and gray. The 8-bit images can have any number of grays between
    
    218
    -  *   2 and 128, and conversions to the target surface is handled
    
    219
    -  *   _automatically_.
    
    220
    -  *
    
    221
    -  *   Note however that you should avoid blitting a gray glyph to a gray
    
    222
    -  *   bitmap with fewer levels of grays, as this would much probably
    
    223
    -  *   give unpleasant results..
    
    224
    -  *
    
    225
    -  *   This function performs clipping.  This function does not implement
    
    226
    -  *   gamma correction.
    
    227
    -  *
    
    228
    -  **********************************************************************/
    
    229
    -
    
    230
    -  extern int
    
    231
    -  grBlitGlyphToBitmap( grBitmap*  target,
    
    232
    -                       grBitmap*  glyph,
    
    233
    -                       grPos      x,
    
    234
    -                       grPos      y,
    
    235
    -                       grColor    color );
    
    236
    -
    
    237
    -
    
    238 197
      /**********************************************************************
    
    239 198
       *
    
    240 199
       * <Function>
    

  • graph/grblit.c deleted
    1
    -/****************************************************************************/
    
    2
    -/*                                                                          */
    
    3
    -/*  The FreeType project -- a free and portable quality TrueType renderer.  */
    
    4
    -/*                                                                          */
    
    5
    -/*  Copyright (C) 1996-2021 by                                              */
    
    6
    -/*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
    
    7
    -/*                                                                          */
    
    8
    -/*  grblit.c: Support for blitting of bitmaps with various depth.           */
    
    9
    -/*                                                                          */
    
    10
    -/****************************************************************************/
    
    11
    -
    
    12
    -#include "grblit.h"
    
    13
    -#include <string.h>
    
    14
    -
    
    15
    -#define  GRAY8
    
    16
    -
    
    17
    -  static
    
    18
    -  int  compute_clips( grBlitter*  blit,
    
    19
    -                      int         x_offset,
    
    20
    -                      int         y_offset )
    
    21
    -  {
    
    22
    -    int  xmin, ymin, xmax, ymax, width, height, target_width;
    
    23
    -
    
    24
    -    /* perform clipping and setup variables */
    
    25
    -    width  = blit->source.width;
    
    26
    -    height = blit->source.rows;
    
    27
    -
    
    28
    -    switch ( blit->source.mode )
    
    29
    -    {
    
    30
    -    case gr_pixel_mode_mono:
    
    31
    -      width = (width + 7) & -8;
    
    32
    -      break;
    
    33
    -
    
    34
    -    case gr_pixel_mode_pal4:
    
    35
    -      width = (width + 1) & -2;
    
    36
    -      break;
    
    37
    -
    
    38
    -    case gr_pixel_mode_lcd:
    
    39
    -    case gr_pixel_mode_lcd2:
    
    40
    -      width /= 3;
    
    41
    -      break;
    
    42
    -
    
    43
    -    case gr_pixel_mode_lcdv:
    
    44
    -    case gr_pixel_mode_lcdv2:
    
    45
    -      height /= 3;
    
    46
    -      break;
    
    47
    -
    
    48
    -    default:
    
    49
    -      ;
    
    50
    -    }
    
    51
    -
    
    52
    -    xmin = x_offset;
    
    53
    -    ymin = y_offset;
    
    54
    -    xmax = xmin + width-1;
    
    55
    -    ymax = ymin + height-1;
    
    56
    -
    
    57
    -    /* clip if necessary */
    
    58
    -    if ( width == 0 || height == 0                ||
    
    59
    -         xmax < 0   || xmin >= blit->target.width ||
    
    60
    -         ymax < 0   || ymin >= blit->target.rows  )
    
    61
    -      return 1;
    
    62
    -
    
    63
    -    /* set up clipping and cursors */
    
    64
    -    blit->yread = 0;
    
    65
    -    if ( ymin < 0 )
    
    66
    -    {
    
    67
    -      blit->yread  -= ymin;
    
    68
    -      height       += ymin;
    
    69
    -      blit->ywrite  = 0;
    
    70
    -    }
    
    71
    -    else
    
    72
    -      blit->ywrite  = ymin;
    
    73
    -
    
    74
    -    if ( ymax >= blit->target.rows )
    
    75
    -      height -= ymax - blit->target.rows + 1;
    
    76
    -
    
    77
    -    blit->xread = 0;
    
    78
    -    if ( xmin < 0 )
    
    79
    -    {
    
    80
    -      blit->xread  -= xmin;
    
    81
    -      width        += xmin;
    
    82
    -      blit->xwrite  = 0;
    
    83
    -    }
    
    84
    -    else
    
    85
    -      blit->xwrite  = xmin;
    
    86
    -
    
    87
    -    target_width = blit->target.width;
    
    88
    -
    
    89
    -    switch ( blit->target.mode )
    
    90
    -    {
    
    91
    -    case gr_pixel_mode_mono:
    
    92
    -      target_width = (target_width + 7) & -8;
    
    93
    -      break;
    
    94
    -    case gr_pixel_mode_pal4:
    
    95
    -      target_width = (target_width + 1) & -2;
    
    96
    -      break;
    
    97
    -
    
    98
    -    default:
    
    99
    -      ;
    
    100
    -    }
    
    101
    -
    
    102
    -    blit->right_clip = xmax - target_width + 1;
    
    103
    -    if ( blit->right_clip > 0 )
    
    104
    -      width -= blit->right_clip;
    
    105
    -    else
    
    106
    -      blit->right_clip = 0;
    
    107
    -
    
    108
    -    blit->width  = width;
    
    109
    -    blit->height = height;
    
    110
    -
    
    111
    -    /* set read and write to the top-left corner of the read */
    
    112
    -    /* and write areas before clipping.                      */
    
    113
    -
    
    114
    -    blit->read  = blit->source.buffer;
    
    115
    -    blit->write = blit->target.buffer;
    
    116
    -
    
    117
    -    blit->read_line  = blit->source.pitch;
    
    118
    -    blit->write_line = blit->target.pitch;
    
    119
    -
    
    120
    -    if ( blit->read_line < 0 )
    
    121
    -      blit->read -= (blit->source.rows-1) * blit->read_line;
    
    122
    -
    
    123
    -    if ( blit->write_line < 0 )
    
    124
    -      blit->write -= (blit->target.rows-1) * blit->write_line;
    
    125
    -
    
    126
    -    /* now go to the start line. Note that we do not move the   */
    
    127
    -    /* x position yet, as this is dependent on the pixel format */
    
    128
    -    blit->read  += blit->yread * blit->read_line;
    
    129
    -    blit->write += blit->ywrite * blit->write_line;
    
    130
    -
    
    131
    -    return 0;
    
    132
    -  }
    
    133
    -
    
    134
    -
    
    135
    -/**************************************************************************/
    
    136
    -/*                                                                        */
    
    137
    -/* <Function> blit_mono_to_mono                                           */
    
    138
    -/*                                                                        */
    
    139
    -/**************************************************************************/
    
    140
    -
    
    141
    -  static
    
    142
    -  void  blit_mono_to_mono( grBlitter*  blit,
    
    143
    -                           grColor     color )
    
    144
    -  {
    
    145
    -    unsigned int  shift;
    
    146
    -    int           left_clip, x, y;
    
    147
    -
    
    148
    -    byte*  read;
    
    149
    -    byte*  write;
    
    150
    -
    
    151
    -    (void)color;   /* unused argument */
    
    152
    -
    
    153
    -    left_clip = ( blit->xread > 0 );
    
    154
    -    shift     = (unsigned int)( blit->xwrite - blit->xread ) & 7;
    
    155
    -
    
    156
    -    read  = blit->read  + (blit->xread >> 3);
    
    157
    -    write = blit->write + (blit->xwrite >> 3);
    
    158
    -
    
    159
    -    if ( shift == 0 )
    
    160
    -    {
    
    161
    -      y = blit->height;
    
    162
    -      do
    
    163
    -      {
    
    164
    -        byte*  _read  = read;
    
    165
    -        byte*  _write = write;
    
    166
    -
    
    167
    -        x = blit->width;
    
    168
    -
    
    169
    -        do
    
    170
    -        {
    
    171
    -          *_write++ |= *_read++;
    
    172
    -          x -= 8;
    
    173
    -        } while ( x > 0 );
    
    174
    -
    
    175
    -        read  += blit->read_line;
    
    176
    -        write += blit->write_line;
    
    177
    -        y--;
    
    178
    -      } while ( y > 0 );
    
    179
    -    }
    
    180
    -    else
    
    181
    -    {
    
    182
    -      int  first, last, count;
    
    183
    -
    
    184
    -
    
    185
    -      first = blit->xwrite >> 3;
    
    186
    -      last  = (blit->xwrite + blit->width-1) >> 3;
    
    187
    -
    
    188
    -      count = last - first;
    
    189
    -
    
    190
    -      if ( blit->right_clip )
    
    191
    -        count++;
    
    192
    -
    
    193
    -      y = blit->height;
    
    194
    -
    
    195
    -      do
    
    196
    -      {
    
    197
    -        unsigned char*  _read  = read;
    
    198
    -        unsigned char*  _write = write;
    
    199
    -        unsigned int    old;
    
    200
    -        unsigned int    shift2 = (8-shift);
    
    201
    -
    
    202
    -        if ( left_clip )
    
    203
    -          old = (unsigned int)(*_read++) << shift2;
    
    204
    -        else
    
    205
    -          old = 0;
    
    206
    -
    
    207
    -        x = count;
    
    208
    -        while ( x > 0 )
    
    209
    -        {
    
    210
    -          unsigned int  val = *_read++;
    
    211
    -
    
    212
    -          *_write++ |= (unsigned char)( (val >> shift) | old );
    
    213
    -          old = val << shift2;
    
    214
    -          x--;
    
    215
    -        }
    
    216
    -
    
    217
    -        if ( !blit->right_clip )
    
    218
    -          *_write |= (unsigned char)old;
    
    219
    -
    
    220
    -        read  += blit->read_line;
    
    221
    -        write += blit->write_line;
    
    222
    -        y--;
    
    223
    -
    
    224
    -      } while ( y > 0 );
    
    225
    -    }
    
    226
    -  }
    
    227
    -
    
    228
    -
    
    229
    -/**************************************************************************/
    
    230
    -/*                                                                        */
    
    231
    -/* <Function> blit_mono_to_pal8                                           */
    
    232
    -/*                                                                        */
    
    233
    -/**************************************************************************/
    
    234
    -
    
    235
    -  static
    
    236
    -  void  blit_mono_to_pal8( grBlitter*  blit,
    
    237
    -                           grColor     color )
    
    238
    -  {
    
    239
    -    int             x, y;
    
    240
    -    unsigned char*  write = blit->write + blit->xwrite;
    
    241
    -    unsigned char*  read  = blit->read  + ( blit->xread >> 3 );
    
    242
    -    unsigned int    mask  = 0x80 >> ( blit->xread & 7 );
    
    243
    -
    
    244
    -    y = blit->height;
    
    245
    -    do
    
    246
    -    {
    
    247
    -      unsigned char*  _write = write;
    
    248
    -      unsigned char*  _read  = read;
    
    249
    -      unsigned int    _mask  = mask;
    
    250
    -      unsigned int     val   = *_read;
    
    251
    -
    
    252
    -      x = blit->width;
    
    253
    -      do
    
    254
    -      {
    
    255
    -        if ( !_mask )
    
    256
    -        {
    
    257
    -          val   = *++_read;
    
    258
    -          _mask = 0x80;
    
    259
    -        }
    
    260
    -
    
    261
    -        if ( val & _mask )
    
    262
    -          *_write = (unsigned char)color.value;
    
    263
    -
    
    264
    -        _mask >>= 1;
    
    265
    -        _write++;
    
    266
    -
    
    267
    -      } while ( --x > 0 );
    
    268
    -
    
    269
    -      read  += blit->read_line;
    
    270
    -      write += blit->write_line;
    
    271
    -      y--;
    
    272
    -    } while ( y > 0 );
    
    273
    -  }
    
    274
    -
    
    275
    -
    
    276
    -/**************************************************************************/
    
    277
    -/*                                                                        */
    
    278
    -/* <Function> blit_mono_to_pal4                                           */
    
    279
    -/*                                                                        */
    
    280
    -/**************************************************************************/
    
    281
    -
    
    282
    -  static
    
    283
    -  void  blit_mono_to_pal4( grBlitter*  blit,
    
    284
    -                           grColor     color )
    
    285
    -  {
    
    286
    -    int             x, y;
    
    287
    -    unsigned char*  write = blit->write + ( blit->xwrite >> 1 );
    
    288
    -    unsigned int    phase = blit->xwrite & 1 ? 0x0F : 0xF0;
    
    289
    -    unsigned char*  read  = blit->read  + ( blit->xread >> 3 );
    
    290
    -    unsigned int    mask  = 0x80 >> ( blit->xread & 7 );
    
    291
    -    unsigned int    col = color.value | ( color.value << 4 );
    
    292
    -
    
    293
    -    y = blit->height;
    
    294
    -    do
    
    295
    -    {
    
    296
    -      unsigned char*  _write = write;
    
    297
    -      unsigned int    _phase = phase;
    
    298
    -      unsigned char*  _read  = read;
    
    299
    -      unsigned int    _mask  = mask;
    
    300
    -      unsigned int     val   = *_read;
    
    301
    -
    
    302
    -      x = blit->width;
    
    303
    -      do
    
    304
    -      {
    
    305
    -        if ( !_mask )
    
    306
    -        {
    
    307
    -          val   = *++_read;
    
    308
    -          _mask = 0x80;
    
    309
    -        }
    
    310
    -
    
    311
    -        if ( val & _mask )
    
    312
    -          *_write = (unsigned char)( (col & _phase) | (*_write & ~_phase) );
    
    313
    -
    
    314
    -        _mask >>= 1;
    
    315
    -        _write += _phase & 1;
    
    316
    -        _phase  = ~_phase;
    
    317
    -        x--;
    
    318
    -      } while ( x > 0 );
    
    319
    -
    
    320
    -      read  += blit->read_line;
    
    321
    -      write += blit->write_line;
    
    322
    -      y--;
    
    323
    -    } while ( y > 0 );
    
    324
    -  }
    
    325
    -
    
    326
    -
    
    327
    -/**************************************************************************/
    
    328
    -/*                                                                        */
    
    329
    -/* <Function> blit_mono_to_rgb16                                          */
    
    330
    -/*                                                                        */
    
    331
    -/**************************************************************************/
    
    332
    -
    
    333
    -  static
    
    334
    -  void  blit_mono_to_rgb16( grBlitter*  blit,
    
    335
    -                            grColor     color )
    
    336
    -  {
    
    337
    -    int              x, y;
    
    338
    -    unsigned char*   write = blit->write + blit->xwrite * 2;
    
    339
    -    unsigned char*   read  = blit->read  + ( blit->xread >> 3 );
    
    340
    -    unsigned int     mask  = 0x80 >> ( blit->xread & 7 );
    
    341
    -
    
    342
    -    y = blit->height;
    
    343
    -    do
    
    344
    -    {
    
    345
    -      unsigned short* _write = (unsigned short*)write;
    
    346
    -      unsigned char*  _read  = read;
    
    347
    -      unsigned int    _mask  = mask;
    
    348
    -      unsigned int     val   = *_read;
    
    349
    -
    
    350
    -      x = blit->width;
    
    351
    -      do
    
    352
    -      {
    
    353
    -        if ( !_mask )
    
    354
    -        {
    
    355
    -          val   = *++_read;
    
    356
    -          _mask = 0x80;
    
    357
    -        }
    
    358
    -
    
    359
    -        if ( val & _mask )
    
    360
    -          *_write = (unsigned short)color.value;
    
    361
    -
    
    362
    -        _mask >>= 1;
    
    363
    -        _write++;
    
    364
    -        x--;
    
    365
    -      } while ( x > 0 );
    
    366
    -
    
    367
    -      read  += blit->read_line;
    
    368
    -      write += blit->write_line;
    
    369
    -      y--;
    
    370
    -    } while ( y > 0 );
    
    371
    -  }
    
    372
    -
    
    373
    -
    
    374
    -/**************************************************************************/
    
    375
    -/*                                                                        */
    
    376
    -/* <Function> blit_mono_to_rgb24                                          */
    
    377
    -/*                                                                        */
    
    378
    -/**************************************************************************/
    
    379
    -
    
    380
    -  static
    
    381
    -  void  blit_mono_to_rgb24( grBlitter*  blit,
    
    382
    -                            grColor     color )
    
    383
    -  {
    
    384
    -    int             x, y;
    
    385
    -    unsigned char*  write = blit->write + blit->xwrite * 3;
    
    386
    -    unsigned char*  read  = blit->read  + ( blit->xread >> 3 );
    
    387
    -    unsigned int    mask  = 0x80 >> ( blit->xread & 7 );
    
    388
    -
    
    389
    -    y = blit->height;
    
    390
    -    do
    
    391
    -    {
    
    392
    -      unsigned char*  _write = write;
    
    393
    -      unsigned char*  _read  = read;
    
    394
    -      unsigned int    _mask  = mask;
    
    395
    -      unsigned int     val   = *_read;
    
    396
    -
    
    397
    -      x = blit->width;
    
    398
    -      do
    
    399
    -      {
    
    400
    -        if ( !_mask )
    
    401
    -        {
    
    402
    -          val   = *++_read;
    
    403
    -          _mask = 0x80;
    
    404
    -        }
    
    405
    -
    
    406
    -        if ( val & _mask )
    
    407
    -        {
    
    408
    -          _write[0] = color.chroma[0];
    
    409
    -          _write[1] = color.chroma[1];
    
    410
    -          _write[2] = color.chroma[2];
    
    411
    -        }
    
    412
    -
    
    413
    -        _mask >>= 1;
    
    414
    -        _write += 3;
    
    415
    -        x--;
    
    416
    -      } while ( x > 0 );
    
    417
    -
    
    418
    -      read  += blit->read_line;
    
    419
    -      write += blit->write_line;
    
    420
    -      y--;
    
    421
    -    } while ( y > 0 );
    
    422
    -  }
    
    423
    -
    
    424
    -
    
    425
    -/**************************************************************************/
    
    426
    -/*                                                                        */
    
    427
    -/* <Function> blit_mono_to_rgb32                                          */
    
    428
    -/*                                                                        */
    
    429
    -/**************************************************************************/
    
    430
    -
    
    431
    -  static
    
    432
    -  void  blit_mono_to_rgb32( grBlitter*  blit,
    
    433
    -                            grColor     color )
    
    434
    -  {
    
    435
    -    int             x, y;
    
    436
    -    unsigned char*  write = blit->write + blit->xwrite * 4;
    
    437
    -    unsigned char*  read  = blit->read  + ( blit->xread >> 3 );
    
    438
    -    unsigned int    mask  = 0x80 >> ( blit->xread & 7 );
    
    439
    -
    
    440
    -    y = blit->height;
    
    441
    -    do
    
    442
    -    {
    
    443
    -      uint32_t*       _write = (uint32_t*)write;
    
    444
    -      unsigned char*  _read  = read;
    
    445
    -      unsigned int    _mask  = mask;
    
    446
    -      unsigned int     val   = *_read;
    
    447
    -
    
    448
    -      x = blit->width;
    
    449
    -      do
    
    450
    -      {
    
    451
    -        if ( !_mask )
    
    452
    -        {
    
    453
    -          val   = *++_read;
    
    454
    -          _mask = 0x80;
    
    455
    -        }
    
    456
    -
    
    457
    -        if ( val & _mask )
    
    458
    -          *_write = color.value;
    
    459
    -
    
    460
    -        _mask >>= 1;
    
    461
    -        _write++;
    
    462
    -        x--;
    
    463
    -
    
    464
    -      } while ( x > 0 );
    
    465
    -
    
    466
    -      read  += blit->read_line;
    
    467
    -      write += blit->write_line;
    
    468
    -      y--;
    
    469
    -
    
    470
    -    } while ( y > 0 );
    
    471
    -  }
    
    472
    -
    
    473
    -
    
    474
    -  static
    
    475
    -  const grBlitterFunc  gr_mono_blitters[gr_pixel_mode_max] =
    
    476
    -  {
    
    477
    -    0,
    
    478
    -    blit_mono_to_mono,
    
    479
    -    blit_mono_to_pal4,
    
    480
    -    blit_mono_to_pal8,
    
    481
    -    blit_mono_to_pal8,
    
    482
    -    blit_mono_to_rgb16,
    
    483
    -    blit_mono_to_rgb16,
    
    484
    -    blit_mono_to_rgb24,
    
    485
    -    blit_mono_to_rgb32
    
    486
    -  };
    
    487
    -
    
    488
    -
    
    489
    -  /*******************************************************************/
    
    490
    -  /*                                                                 */
    
    491
    -  /*                    Saturation tables                            */
    
    492
    -  /*                                                                 */
    
    493
    -  /*******************************************************************/
    
    494
    -
    
    495
    -  typedef struct grSaturation_
    
    496
    -  {
    
    497
    -    int          count;
    
    498
    -    const byte*  table;
    
    499
    -
    
    500
    -  } grSaturation;
    
    501
    -
    
    502
    -
    
    503
    -  static
    
    504
    -  const byte  gr_saturation_5[8] = { 0, 1, 2, 3, 4, 4, 4, 4 };
    
    505
    -
    
    506
    -
    
    507
    -  static
    
    508
    -  const byte  gr_saturation_17[32] =
    
    509
    -  {
    
    510
    -     0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
    
    511
    -    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    
    512
    -  };
    
    513
    -
    
    514
    -
    
    515
    -  static
    
    516
    -  grSaturation  gr_saturations[ GR_MAX_SATURATIONS ] =
    
    517
    -  {
    
    518
    -    {  5, gr_saturation_5  },
    
    519
    -    { 17, gr_saturation_17 }
    
    520
    -  };
    
    521
    -
    
    522
    -  static
    
    523
    -  int  gr_num_saturations = 2;
    
    524
    -
    
    525
    -  static
    
    526
    -  grSaturation*  gr_last_saturation = gr_saturations;
    
    527
    -
    
    528
    -
    
    529
    -  static const byte*
    
    530
    -  grGetSaturation( int  num_grays )
    
    531
    -  {
    
    532
    -    /* first of all, scan the current saturations table */
    
    533
    -    grSaturation*  sat   = gr_saturations;
    
    534
    -    grSaturation*  limit = sat + gr_num_saturations;
    
    535
    -
    
    536
    -    if ( num_grays < 2 )
    
    537
    -    {
    
    538
    -      grError = gr_err_bad_argument;
    
    539
    -      return NULL;
    
    540
    -    }
    
    541
    -
    
    542
    -    for ( ; sat < limit; sat++ )
    
    543
    -    {
    
    544
    -      if ( sat->count == num_grays )
    
    545
    -      {
    
    546
    -        gr_last_saturation = sat;
    
    547
    -        return sat->table;
    
    548
    -      }
    
    549
    -    }
    
    550
    -
    
    551
    -    /* not found, simply create a new entry if there is room */
    
    552
    -    if (gr_num_saturations < GR_MAX_SATURATIONS)
    
    553
    -    {
    
    554
    -      int    i;
    
    555
    -      byte*  table;
    
    556
    -
    
    557
    -      table = (byte*)malloc( (size_t)( 3 * num_grays - 1 ) * sizeof ( byte ) );
    
    558
    -      if (!table)
    
    559
    -        return NULL;
    
    560
    -
    
    561
    -      sat->count = num_grays;
    
    562
    -      sat->table = table;
    
    563
    -
    
    564
    -      for ( i = 0; i < num_grays; i++ )
    
    565
    -        table[i] = (byte)i;
    
    566
    -
    
    567
    -      memset( table+num_grays, num_grays-1, 2*num_grays-1 );
    
    568
    -
    
    569
    -      gr_num_saturations++;
    
    570
    -      gr_last_saturation = sat;
    
    571
    -      return table;
    
    572
    -    }
    
    573
    -    grError = gr_err_saturation_overflow;
    
    574
    -    return NULL;
    
    575
    -  }
    
    576
    -
    
    577
    -
    
    578
    -
    
    579
    -  /*******************************************************************/
    
    580
    -  /*                                                                 */
    
    581
    -  /*                    conversion tables                            */
    
    582
    -  /*                                                                 */
    
    583
    -  /*******************************************************************/
    
    584
    -
    
    585
    -  typedef struct grConversion_
    
    586
    -  {
    
    587
    -    int          target_grays;
    
    588
    -    int          source_grays;
    
    589
    -    const byte*  table;
    
    590
    -
    
    591
    -  } grConversion;
    
    592
    -
    
    593
    -
    
    594
    -
    
    595
    -  static
    
    596
    -  const byte  gr_gray5_to_gray17[5] = { 0, 4, 8, 12, 16 };
    
    597
    -
    
    598
    -
    
    599
    -  static
    
    600
    -  const byte  gr_gray5_to_gray128[5] = { 0, 32, 64, 96, 127 };
    
    601
    -
    
    602
    -
    
    603
    -  static
    
    604
    -  const byte  gr_gray17_to_gray128[17] =
    
    605
    -  {
    
    606
    -    0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 127
    
    607
    -  };
    
    608
    -
    
    609
    -  static
    
    610
    -  grConversion  gr_conversions[ GR_MAX_CONVERSIONS ] =
    
    611
    -  {
    
    612
    -    {  17,  5, gr_gray5_to_gray17   },
    
    613
    -    { 128,  5, gr_gray5_to_gray128  },
    
    614
    -    { 128, 17, gr_gray17_to_gray128 }
    
    615
    -  };
    
    616
    -
    
    617
    -  static
    
    618
    -  int  gr_num_conversions = 3;
    
    619
    -
    
    620
    -  static
    
    621
    -  grConversion*  gr_last_conversion = gr_conversions;
    
    622
    -
    
    623
    -
    
    624
    -  static const byte*
    
    625
    -  grGetConversion( int  target_grays,
    
    626
    -                   int  source_grays )
    
    627
    -  {
    
    628
    -    grConversion*  conv  = gr_conversions;
    
    629
    -    grConversion*  limit = conv + gr_num_conversions;
    
    630
    -
    
    631
    -    if ( target_grays < 2 || source_grays < 2 )
    
    632
    -    {
    
    633
    -      grError = gr_err_bad_argument;
    
    634
    -      return NULL;
    
    635
    -    }
    
    636
    -
    
    637
    -    /* otherwise, scan table */
    
    638
    -    for ( ; conv < limit; conv++ )
    
    639
    -    {
    
    640
    -      if ( conv->target_grays == target_grays &&
    
    641
    -           conv->source_grays == source_grays )
    
    642
    -      {
    
    643
    -        gr_last_conversion = conv;
    
    644
    -        return conv->table;
    
    645
    -      }
    
    646
    -    }
    
    647
    -
    
    648
    -    /* not found, add a new conversion to the table */
    
    649
    -    if (gr_num_conversions < GR_MAX_CONVERSIONS)
    
    650
    -    {
    
    651
    -      byte*  table;
    
    652
    -      int    n;
    
    653
    -
    
    654
    -      table = (byte*)malloc( (size_t)source_grays * sizeof ( byte ) );
    
    655
    -      if (!table)
    
    656
    -        return NULL;
    
    657
    -
    
    658
    -      conv->target_grays = target_grays;
    
    659
    -      conv->source_grays = source_grays;
    
    660
    -      conv->table        = table;
    
    661
    -
    
    662
    -      for ( n = 0; n < source_grays; n++ )
    
    663
    -        table[n] = (byte)(n*(target_grays-1) / (source_grays-1));
    
    664
    -
    
    665
    -      gr_num_conversions++;
    
    666
    -      gr_last_conversion = conv;
    
    667
    -      return table;
    
    668
    -    }
    
    669
    -    grError = gr_err_conversion_overflow;
    
    670
    -    return NULL;
    
    671
    -  }
    
    672
    -
    
    673
    -
    
    674
    -
    
    675
    -
    
    676
    -/**************************************************************************/
    
    677
    -/*                                                                        */
    
    678
    -/* <Function> blit_gray_to_gray                                           */
    
    679
    -/*                                                                        */
    
    680
    -/**************************************************************************/
    
    681
    -
    
    682
    -  static
    
    683
    -  void  blit_gray_to_gray( grBlitter*   blit,
    
    684
    -                           const byte*  saturation,
    
    685
    -                           const byte*  conversion )
    
    686
    -  {
    
    687
    -    int             y;
    
    688
    -    unsigned char*  read;
    
    689
    -    unsigned char*  write;
    
    690
    -#ifdef GR_CONFIG_GRAY_SKIP_WHITE
    
    691
    -    int  max = blit->source.grays - 1;
    
    692
    -    int  max2 = blit-target.grays - 1;
    
    693
    -#endif
    
    694
    -
    
    695
    -    read  = blit->read  + blit->xread;
    
    696
    -    write = blit->write + blit->xwrite;
    
    697
    -
    
    698
    -    y = blit->height;
    
    699
    -    do
    
    700
    -    {
    
    701
    -      unsigned char*  _read  = read;
    
    702
    -      unsigned char*  _write = write;
    
    703
    -      int             x      = blit->width;
    
    704
    -
    
    705
    -      while (x > 0)
    
    706
    -      {
    
    707
    -#ifdef GR_CONFIG_GRAY_SKIP_WHITE
    
    708
    -        int  val = *_read;
    
    709
    -
    
    710
    -        if (val)
    
    711
    -        {
    
    712
    -          if (val == max)
    
    713
    -            *_write = (byte)max2;
    
    714
    -          else
    
    715
    -            *_write = saturation[ (int)*_write + conversion[ *_read ] ];
    
    716
    -        }
    
    717
    -#else
    
    718
    -        *_write = saturation[ (int)*_write + conversion[ *_read ] ];
    
    719
    -#endif
    
    720
    -        _write++;
    
    721
    -        _read++;
    
    722
    -        x--;
    
    723
    -      }
    
    724
    -
    
    725
    -      read  += blit->read_line;
    
    726
    -      write += blit->write_line;
    
    727
    -      y--;
    
    728
    -    }
    
    729
    -    while (y > 0);
    
    730
    -  }
    
    731
    -
    
    732
    -
    
    733
    -/**************************************************************************/
    
    734
    -/*                                                                        */
    
    735
    -/* <Function> blit_gray_to_gray_simple                                    */
    
    736
    -/*                                                                        */
    
    737
    -/**************************************************************************/
    
    738
    -
    
    739
    -  static
    
    740
    -  void  blit_gray_to_gray_simple( grBlitter*   blit,
    
    741
    -                                  const byte*  saturation )
    
    742
    -  {
    
    743
    -    int             y;
    
    744
    -    unsigned char*  read;
    
    745
    -    unsigned char*  write;
    
    746
    -#ifdef GR_CONFIG_GRAY_SKIP_WHITE
    
    747
    -    int  max = blit->source.grays - 1;
    
    748
    -#endif
    
    749
    -
    
    750
    -    read  = blit->read  + blit->xread;
    
    751
    -    write = blit->write + blit->xwrite;
    
    752
    -
    
    753
    -    y = blit->height;
    
    754
    -    do
    
    755
    -    {
    
    756
    -      unsigned char*  _read  = read;
    
    757
    -      unsigned char*  _write = write;
    
    758
    -      int             x      = blit->width;
    
    759
    -
    
    760
    -      while (x > 0)
    
    761
    -      {
    
    762
    -#ifdef GR_CONFIG_GRAY_SKIP_WHITE
    
    763
    -        int  val = *_read;
    
    764
    -
    
    765
    -        if (val)
    
    766
    -        {
    
    767
    -          if (val == max)
    
    768
    -            *_write = val;
    
    769
    -          else
    
    770
    -            *_write = saturation[ (int)*_write + *_read ];
    
    771
    -        }
    
    772
    -#else
    
    773
    -        *_write = saturation[ (int)*_write + *_read ];
    
    774
    -#endif
    
    775
    -        _write++;
    
    776
    -        _read++;
    
    777
    -        x--;
    
    778
    -      }
    
    779
    -
    
    780
    -      read  += blit->read_line;
    
    781
    -      write += blit->write_line;
    
    782
    -      y--;
    
    783
    -    }
    
    784
    -    while (y > 0);
    
    785
    -  }
    
    786
    -
    
    787
    -
    
    788
    -
    
    789
    -#define compose_pixel_full( a, b, n0, n1, n2, max )    \
    
    790
    -  do                                                   \
    
    791
    -  {                                                    \
    
    792
    -    int  d, half = max >> 1;                           \
    
    793
    -                                                       \
    
    794
    -                                                       \
    
    795
    -    d = (int)b.chroma[0] - a.chroma[0];                \
    
    796
    -    a.chroma[0] += (unsigned char)((n0*d + half)/max); \
    
    797
    -                                                       \
    
    798
    -    d = (int)b.chroma[1] - a.chroma[1];                \
    
    799
    -    a.chroma[1] += (unsigned char)((n1*d + half)/max); \
    
    800
    -                                                       \
    
    801
    -    d = (int)b.chroma[2] - a.chroma[2];                \
    
    802
    -    a.chroma[2] += (unsigned char)((n2*d + half)/max); \
    
    803
    -  } while ( 0 )
    
    804
    -
    
    805
    -#define compose_pixel( a, b, n, max )  \
    
    806
    -    compose_pixel_full( a, b, n, n, n, max )
    
    807
    -
    
    808
    -
    
    809
    -#define extract555( pixel, color )                           \
    
    810
    -   color.chroma[0] = (unsigned char)((pixel >> 10) & 0x1F);  \
    
    811
    -   color.chroma[1] = (unsigned char)((pixel >>  5) & 0x1F);  \
    
    812
    -   color.chroma[2] = (unsigned char)((pixel      ) & 0x1F)
    
    813
    -
    
    814
    -
    
    815
    -#define extract565( pixel, color )                           \
    
    816
    -   color.chroma[0] = (unsigned char)((pixel >> 11) & 0x1F);  \
    
    817
    -   color.chroma[1] = (unsigned char)((pixel >>  5) & 0x3F);  \
    
    818
    -   color.chroma[2] = (unsigned char)((pixel      ) & 0x1F)
    
    819
    -
    
    820
    -
    
    821
    -#define inject555( color )                          \
    
    822
    -   (unsigned short)( ( color.chroma[0] << 10 ) |    \
    
    823
    -                     ( color.chroma[1] <<  5 ) |    \
    
    824
    -                       color.chroma[2]           )
    
    825
    -
    
    826
    -
    
    827
    -#define inject565( color )                          \
    
    828
    -   (unsigned short)( ( color.chroma[0] << 11 ) |    \
    
    829
    -                     ( color.chroma[1] <<  5 ) |    \
    
    830
    -                       color.chroma[2]           )
    
    831
    -
    
    832
    -
    
    833
    -/**************************************************************************/
    
    834
    -/*                                                                        */
    
    835
    -/* <Function> blit_gray_to_555                                            */
    
    836
    -/*                                                                        */
    
    837
    -/**************************************************************************/
    
    838
    -
    
    839
    -#ifdef GRAY8
    
    840
    -  static
    
    841
    -  void  blit_gray8_to_555( grBlitter*  blit,
    
    842
    -                           grColor     color )
    
    843
    -  {
    
    844
    -    int             y;
    
    845
    -    int             sr = color.value & 0x7C00;
    
    846
    -    int             sg = color.value & 0x03E0;
    
    847
    -    int             sb = color.value & 0x001F;
    
    848
    -    unsigned char*  read;
    
    849
    -    unsigned char*  write;
    
    850
    -
    
    851
    -    read   = blit->read  + blit->xread;
    
    852
    -    write  = blit->write + 2*blit->xwrite;
    
    853
    -
    
    854
    -    y = blit->height;
    
    855
    -    do
    
    856
    -    {
    
    857
    -      unsigned char*   _read  = read;
    
    858
    -      unsigned short*  _write = (unsigned short*)write;
    
    859
    -      int              x      = blit->width;
    
    860
    -
    
    861
    -      while (x > 0)
    
    862
    -      {
    
    863
    -        unsigned char  val = *_read;
    
    864
    -
    
    865
    -        if (val)
    
    866
    -        {
    
    867
    -          if (val >= 254 )
    
    868
    -            *_write = (unsigned short)( sr | sg | sb );
    
    869
    -          else if ( val >= 2 )
    
    870
    -          {
    
    871
    -            /* compose gray value */
    
    872
    -            int   pix = (int)*_write;
    
    873
    -            int   dr  = pix & 0x7C00;
    
    874
    -            int   dg  = pix & 0x03E0;
    
    875
    -            int   db  = pix & 0x001F;
    
    876
    -
    
    877
    -            dr += ((sr-dr)*val) >> 8;
    
    878
    -            dr &= 0x7C00;
    
    879
    -
    
    880
    -            dg += ((sg-dg)*val) >> 8;
    
    881
    -            dg &= 0x03E0;
    
    882
    -
    
    883
    -            db += ((sb-db)*val) >> 8;
    
    884
    -            db &= 0x001F;
    
    885
    -
    
    886
    -            *_write = (unsigned short)( dr | dg | db );
    
    887
    -          }
    
    888
    -        }
    
    889
    -        _write ++;
    
    890
    -        _read  ++;
    
    891
    -        x--;
    
    892
    -      }
    
    893
    -
    
    894
    -      read  += blit->read_line;
    
    895
    -      write += blit->write_line;
    
    896
    -      y--;
    
    897
    -    }
    
    898
    -    while (y > 0);
    
    899
    -
    
    900
    -  }
    
    901
    -#endif /* GRAY8 */
    
    902
    -
    
    903
    -  static
    
    904
    -  void  blit_gray_to_555( grBlitter*  blit,
    
    905
    -                          grColor     color,
    
    906
    -                          int         max )
    
    907
    -  {
    
    908
    -    int             y;
    
    909
    -    unsigned char*  read;
    
    910
    -    unsigned char*  write;
    
    911
    -
    
    912
    -    read   = blit->read  + blit->xread;
    
    913
    -    write  = blit->write + 2*blit->xwrite;
    
    914
    -
    
    915
    -    /* scale down R:G:B triplet */
    
    916
    -    color.chroma[0] >>= 3;
    
    917
    -    color.chroma[1] >>= 3;
    
    918
    -    color.chroma[2] >>= 3;
    
    919
    -
    
    920
    -    y = blit->height;
    
    921
    -    do
    
    922
    -    {
    
    923
    -      unsigned char*   _read  = read;
    
    924
    -      unsigned short*  _write = (unsigned short*)write;
    
    925
    -      int              x      = blit->width;
    
    926
    -
    
    927
    -      while (x > 0)
    
    928
    -      {
    
    929
    -        int  val = *_read;
    
    930
    -
    
    931
    -        if (val)
    
    932
    -        {
    
    933
    -          if (val == max)
    
    934
    -            *_write = inject555( color );
    
    935
    -          else
    
    936
    -          {
    
    937
    -            /* compose gray value */
    
    938
    -            unsigned short  pix16 = *_write;
    
    939
    -            grColor         pix;
    
    940
    -
    
    941
    -            extract555( pix16, pix );
    
    942
    -
    
    943
    -            compose_pixel( pix, color, val, max );
    
    944
    -            *_write = inject555( pix );
    
    945
    -          }
    
    946
    -        }
    
    947
    -        _write ++;
    
    948
    -        _read  ++;
    
    949
    -        x--;
    
    950
    -      }
    
    951
    -
    
    952
    -      read  += blit->read_line;
    
    953
    -      write += blit->write_line;
    
    954
    -      y--;
    
    955
    -    }
    
    956
    -    while (y > 0);
    
    957
    -  }
    
    958
    -
    
    959
    -
    
    960
    -/**************************************************************************/
    
    961
    -/*                                                                        */
    
    962
    -/* <Function> blit_gray_to_565                                            */
    
    963
    -/*                                                                        */
    
    964
    -/**************************************************************************/
    
    965
    -
    
    966
    -#ifdef GRAY8
    
    967
    -  static
    
    968
    -  void  blit_gray8_to_565( grBlitter*  blit,
    
    969
    -                           grColor     color )
    
    970
    -  {
    
    971
    -    int             y;
    
    972
    -    int             sr = color.value & 0xF800;
    
    973
    -    int             sg = color.value & 0x07E0;
    
    974
    -    int             sb = color.value & 0x001F;
    
    975
    -    unsigned char*  read;
    
    976
    -    unsigned char*  write;
    
    977
    -
    
    978
    -    read   = blit->read  + blit->xread;
    
    979
    -    write  = blit->write + 2*blit->xwrite;
    
    980
    -
    
    981
    -    y = blit->height;
    
    982
    -    do
    
    983
    -    {
    
    984
    -      unsigned char*   _read  = read;
    
    985
    -      unsigned short*  _write = (unsigned short*)write;
    
    986
    -      int              x      = blit->width;
    
    987
    -
    
    988
    -      while (x > 0)
    
    989
    -      {
    
    990
    -        unsigned char  val = *_read;
    
    991
    -
    
    992
    -        if (val)
    
    993
    -        {
    
    994
    -          if (val >= 254 )
    
    995
    -            *_write = (unsigned short)( sr | sg | sb );
    
    996
    -          else if ( val >= 2 )
    
    997
    -          {
    
    998
    -            /* compose gray value */
    
    999
    -            int   pix = (int)*_write;
    
    1000
    -            int   dr  = pix & 0xF800;
    
    1001
    -            int   dg  = pix & 0x07E0;
    
    1002
    -            int   db  = pix & 0x001F;
    
    1003
    -
    
    1004
    -            dr += ((sr-dr)*val) >> 8;
    
    1005
    -            dr &= 0xF800;
    
    1006
    -
    
    1007
    -            dg += ((sg-dg)*val) >> 8;
    
    1008
    -            dg &= 0x07E0;
    
    1009
    -
    
    1010
    -            db += ((sb-db)*val) >> 8;
    
    1011
    -            db &= 0x001F;
    
    1012
    -
    
    1013
    -            *_write = (unsigned short)( dr | dg | db );
    
    1014
    -          }
    
    1015
    -        }
    
    1016
    -        _write ++;
    
    1017
    -        _read  ++;
    
    1018
    -        x--;
    
    1019
    -      }
    
    1020
    -
    
    1021
    -      read  += blit->read_line;
    
    1022
    -      write += blit->write_line;
    
    1023
    -      y--;
    
    1024
    -    }
    
    1025
    -    while (y > 0);
    
    1026
    -  }
    
    1027
    -#endif
    
    1028
    -
    
    1029
    -  static
    
    1030
    -  void  blit_gray_to_565( grBlitter*  blit,
    
    1031
    -                          grColor     color,
    
    1032
    -                          int         max )
    
    1033
    -  {
    
    1034
    -    int             y;
    
    1035
    -    unsigned char*  read;
    
    1036
    -    unsigned char*  write;
    
    1037
    -
    
    1038
    -    read   = blit->read  + blit->xread;
    
    1039
    -    write  = blit->write + 2*blit->xwrite;
    
    1040
    -
    
    1041
    -    /* scale down R:G:B triplet */
    
    1042
    -    color.chroma[0] >>= 3;
    
    1043
    -    color.chroma[1] >>= 2;
    
    1044
    -    color.chroma[2] >>= 3;
    
    1045
    -
    
    1046
    -    y = blit->height;
    
    1047
    -    do
    
    1048
    -    {
    
    1049
    -      unsigned char*   _read  = read;
    
    1050
    -      unsigned short*  _write = (unsigned short*)write;
    
    1051
    -      int              x      = blit->width;
    
    1052
    -
    
    1053
    -      while (x > 0)
    
    1054
    -      {
    
    1055
    -        int  val = *_read;
    
    1056
    -
    
    1057
    -        if (val)
    
    1058
    -        {
    
    1059
    -          if (val == max)
    
    1060
    -            *_write = inject565( color );
    
    1061
    -          else
    
    1062
    -          {
    
    1063
    -            /* compose gray value */
    
    1064
    -            unsigned short  pix16 = *_write;
    
    1065
    -            grColor         pix;
    
    1066
    -
    
    1067
    -            extract565( pix16, pix );
    
    1068
    -
    
    1069
    -            compose_pixel( pix, color, val, max );
    
    1070
    -            *_write = inject565( pix );
    
    1071
    -          }
    
    1072
    -        }
    
    1073
    -        _write ++;
    
    1074
    -        _read  ++;
    
    1075
    -        x--;
    
    1076
    -      }
    
    1077
    -
    
    1078
    -      read  += blit->read_line;
    
    1079
    -      write += blit->write_line;
    
    1080
    -      y--;
    
    1081
    -    }
    
    1082
    -    while (y > 0);
    
    1083
    -  }
    
    1084
    -
    
    1085
    -
    
    1086
    -/**************************************************************************/
    
    1087
    -/*                                                                        */
    
    1088
    -/* <Function> blit_gray_to_24                                             */
    
    1089
    -/*                                                                        */
    
    1090
    -/**************************************************************************/
    
    1091
    -
    
    1092
    -#ifdef GRAY8
    
    1093
    -  static void
    
    1094
    -  blit_gray8_to_24( grBlitter*  blit,
    
    1095
    -                    grColor     color )
    
    1096
    -  {
    
    1097
    -    int             y;
    
    1098
    -    int             sr = color.chroma[0];
    
    1099
    -    int             sg = color.chroma[1];
    
    1100
    -    int             sb = color.chroma[2];
    
    1101
    -    unsigned char*  read;
    
    1102
    -    unsigned char*  write;
    
    1103
    -
    
    1104
    -    read   = blit->read  + blit->xread;
    
    1105
    -    write  = blit->write + 3*blit->xwrite;
    
    1106
    -
    
    1107
    -    y = blit->height;
    
    1108
    -    do
    
    1109
    -    {
    
    1110
    -      unsigned char*  _read  = read;
    
    1111
    -      unsigned char*  _write = write;
    
    1112
    -      int             x      = blit->width;
    
    1113
    -
    
    1114
    -      while (x > 0)
    
    1115
    -      {
    
    1116
    -        unsigned char  val = *_read;
    
    1117
    -
    
    1118
    -        if (val)
    
    1119
    -        {
    
    1120
    -          if (val >= 254)
    
    1121
    -          {
    
    1122
    -            _write[0] = (unsigned char)sr;
    
    1123
    -            _write[1] = (unsigned char)sg;
    
    1124
    -            _write[2] = (unsigned char)sb;
    
    1125
    -          }
    
    1126
    -          else if ( val >= 2 )
    
    1127
    -          {
    
    1128
    -            int  dr = _write[0];
    
    1129
    -            int  dg = _write[1];
    
    1130
    -            int  db = _write[2];
    
    1131
    -
    
    1132
    -            dr += ((sr-dr)*val) >> 8;
    
    1133
    -            dg += ((sg-dg)*val) >> 8;
    
    1134
    -            db += ((sb-db)*val) >> 8;
    
    1135
    -
    
    1136
    -            _write[0] = (unsigned char)dr;
    
    1137
    -            _write[1] = (unsigned char)dg;
    
    1138
    -            _write[2] = (unsigned char)db;
    
    1139
    -          }
    
    1140
    -        }
    
    1141
    -        _write += 3;
    
    1142
    -        _read  ++;
    
    1143
    -        x--;
    
    1144
    -      }
    
    1145
    -
    
    1146
    -      read  += blit->read_line;
    
    1147
    -      write += blit->write_line;
    
    1148
    -      y--;
    
    1149
    -    }
    
    1150
    -    while (y > 0);
    
    1151
    -  }
    
    1152
    -#endif /* GRAY8 */
    
    1153
    -
    
    1154
    -
    
    1155
    -  static
    
    1156
    -  void  blit_gray_to_24( grBlitter*  blit,
    
    1157
    -                         grColor     color,
    
    1158
    -                         int         max )
    
    1159
    -  {
    
    1160
    -    int             y;
    
    1161
    -    unsigned char*  read;
    
    1162
    -    unsigned char*  write;
    
    1163
    -
    
    1164
    -    read   = blit->read  + blit->xread;
    
    1165
    -    write  = blit->write + 3*blit->xwrite;
    
    1166
    -
    
    1167
    -    y = blit->height;
    
    1168
    -    do
    
    1169
    -    {
    
    1170
    -      unsigned char*  _read  = read;
    
    1171
    -      unsigned char*  _write = write;
    
    1172
    -      int             x      = blit->width;
    
    1173
    -
    
    1174
    -      while (x > 0)
    
    1175
    -      {
    
    1176
    -        int  val = *_read;
    
    1177
    -
    
    1178
    -        if (val)
    
    1179
    -        {
    
    1180
    -          if (val == max)
    
    1181
    -          {
    
    1182
    -            _write[0] = color.chroma[0];
    
    1183
    -            _write[1] = color.chroma[1];
    
    1184
    -            _write[2] = color.chroma[2];
    
    1185
    -          }
    
    1186
    -          else
    
    1187
    -          {
    
    1188
    -            /* compose gray value */
    
    1189
    -            grColor pix;
    
    1190
    -
    
    1191
    -            pix.chroma[0] = _write[0];
    
    1192
    -            pix.chroma[1] = _write[1];
    
    1193
    -            pix.chroma[2] = _write[2];
    
    1194
    -
    
    1195
    -            compose_pixel( pix, color, val, max );
    
    1196
    -
    
    1197
    -            _write[0] = pix.chroma[0];
    
    1198
    -            _write[1] = pix.chroma[1];
    
    1199
    -            _write[2] = pix.chroma[2];
    
    1200
    -          }
    
    1201
    -        }
    
    1202
    -        _write += 3;
    
    1203
    -        _read  ++;
    
    1204
    -        x--;
    
    1205
    -      }
    
    1206
    -
    
    1207
    -      read  += blit->read_line;
    
    1208
    -      write += blit->write_line;
    
    1209
    -      y--;
    
    1210
    -    }
    
    1211
    -    while (y > 0);
    
    1212
    -  }
    
    1213
    -
    
    1214
    -
    
    1215
    -/**************************************************************************/
    
    1216
    -/*                                                                        */
    
    1217
    -/* <Function> blit_gray_to_32                                             */
    
    1218
    -/*                                                                        */
    
    1219
    -/**************************************************************************/
    
    1220
    -
    
    1221
    -  static
    
    1222
    -  void  blit_gray_to_32( grBlitter*  blit,
    
    1223
    -                         grColor     color,
    
    1224
    -                         int         max )
    
    1225
    -  {
    
    1226
    -    int             y;
    
    1227
    -    unsigned char*  read;
    
    1228
    -    unsigned char*  write;
    
    1229
    -
    
    1230
    -    read   = blit->read  + blit->xread;
    
    1231
    -    write  = blit->write + 4*blit->xwrite;
    
    1232
    -
    
    1233
    -    y = blit->height;
    
    1234
    -    do
    
    1235
    -    {
    
    1236
    -      unsigned char*  _read  = read;
    
    1237
    -      unsigned char*  _write = write;
    
    1238
    -      int             x      = blit->width;
    
    1239
    -
    
    1240
    -      while (x > 0)
    
    1241
    -      {
    
    1242
    -        int  val = *_read;
    
    1243
    -
    
    1244
    -        if (val)
    
    1245
    -        {
    
    1246
    -          if (val == max)
    
    1247
    -          {
    
    1248
    -            _write[0] = color.chroma[0];
    
    1249
    -            _write[1] = color.chroma[1];
    
    1250
    -            _write[2] = color.chroma[2];
    
    1251
    -            _write[3] = color.chroma[3];
    
    1252
    -          }
    
    1253
    -          else
    
    1254
    -          {
    
    1255
    -            /* compose gray value */
    
    1256
    -            grColor pix;
    
    1257
    -
    
    1258
    -            pix.chroma[0] = _write[0];
    
    1259
    -            pix.chroma[1] = _write[1];
    
    1260
    -            pix.chroma[2] = _write[2];
    
    1261
    -
    
    1262
    -            compose_pixel( pix, color, val, max );
    
    1263
    -
    
    1264
    -            _write[0] = pix.chroma[0];
    
    1265
    -            _write[1] = pix.chroma[1];
    
    1266
    -            _write[2] = pix.chroma[2];
    
    1267
    -          }
    
    1268
    -        }
    
    1269
    -        _write += 4;
    
    1270
    -        _read  ++;
    
    1271
    -        x--;
    
    1272
    -      }
    
    1273
    -
    
    1274
    -      read  += blit->read_line;
    
    1275
    -      write += blit->write_line;
    
    1276
    -      y--;
    
    1277
    -    }
    
    1278
    -    while (y > 0);
    
    1279
    -  }
    
    1280
    -
    
    1281
    -
    
    1282
    -  static
    
    1283
    -  void  blit_gray8_to_32( grBlitter*  blit,
    
    1284
    -                          grColor     color )
    
    1285
    -  {
    
    1286
    -    blit_gray_to_32( blit, color, 255 );
    
    1287
    -  }
    
    1288
    -
    
    1289
    -
    
    1290
    -/**************************************************************************/
    
    1291
    -/*                                                                        */
    
    1292
    -/* <Function> blit_lcd_to_24                                              */
    
    1293
    -/*                                                                        */
    
    1294
    -/**************************************************************************/
    
    1295
    -
    
    1296
    -#ifdef GRAY8
    
    1297
    -  static void
    
    1298
    -  blit_lcd8_to_24( grBlitter*  blit,
    
    1299
    -                   grColor     color )
    
    1300
    -  {
    
    1301
    -    int             y;
    
    1302
    -    int             sr = color.chroma[0];
    
    1303
    -    int             sg = color.chroma[1];
    
    1304
    -    int             sb = color.chroma[2];
    
    1305
    -    unsigned char*  read;
    
    1306
    -    unsigned char*  write;
    
    1307
    -
    
    1308
    -    read   = blit->read  + 3*blit->xread;
    
    1309
    -    write  = blit->write + 3*blit->xwrite;
    
    1310
    -
    
    1311
    -    y = blit->height;
    
    1312
    -    do
    
    1313
    -    {
    
    1314
    -      unsigned char*  _read  = read;
    
    1315
    -      unsigned char*  _write = write;
    
    1316
    -      int             x      = blit->width;
    
    1317
    -
    
    1318
    -      while (x > 0)
    
    1319
    -      {
    
    1320
    -        int  val0 = _read[0];
    
    1321
    -        int  val1 = _read[1];
    
    1322
    -        int  val2 = _read[2];
    
    1323
    -
    
    1324
    -        if ( val0 | val1 | val2 )
    
    1325
    -        {
    
    1326
    -          if ( val0 == val1 &&
    
    1327
    -               val0 == val2 &&
    
    1328
    -               val0 == 255  )
    
    1329
    -          {
    
    1330
    -            _write[0] = (unsigned char)sr;
    
    1331
    -            _write[1] = (unsigned char)sg;
    
    1332
    -            _write[2] = (unsigned char)sb;
    
    1333
    -          }
    
    1334
    -          else
    
    1335
    -          {
    
    1336
    -            /* compose gray value */
    
    1337
    -            int   dr, dg, db;
    
    1338
    -
    
    1339
    -            dr  = _write[0];
    
    1340
    -            dr += (sr-dr)*val0 >> 8;
    
    1341
    -
    
    1342
    -            dg  = _write[1];
    
    1343
    -            dg += (sg-dg)*val1 >> 8;
    
    1344
    -
    
    1345
    -            db  = _write[2];
    
    1346
    -            db += (sb-db)*val2 >> 8;
    
    1347
    -
    
    1348
    -            _write[0] = (unsigned char)dr;
    
    1349
    -            _write[1] = (unsigned char)dg;
    
    1350
    -            _write[2] = (unsigned char)db;
    
    1351
    -          }
    
    1352
    -        }
    
    1353
    -        _write += 3;
    
    1354
    -        _read  += 3;
    
    1355
    -        x--;
    
    1356
    -      }
    
    1357
    -
    
    1358
    -      read  += blit->read_line;
    
    1359
    -      write += blit->write_line;
    
    1360
    -      y--;
    
    1361
    -    }
    
    1362
    -    while (y > 0);
    
    1363
    -  }
    
    1364
    -#endif /* GRAY8 */
    
    1365
    -
    
    1366
    -  static void
    
    1367
    -  blit_lcd_to_24( grBlitter*  blit,
    
    1368
    -                  grColor     color,
    
    1369
    -                  int         max )
    
    1370
    -  {
    
    1371
    -    int             y;
    
    1372
    -    unsigned char*  read;
    
    1373
    -    unsigned char*  write;
    
    1374
    -
    
    1375
    -    read   = blit->read  + 3*blit->xread;
    
    1376
    -    write  = blit->write + 3*blit->xwrite;
    
    1377
    -
    
    1378
    -    y = blit->height;
    
    1379
    -    do
    
    1380
    -    {
    
    1381
    -      unsigned char*  _read  = read;
    
    1382
    -      unsigned char*  _write = write;
    
    1383
    -      int             x      = blit->width;
    
    1384
    -
    
    1385
    -      while (x > 0)
    
    1386
    -      {
    
    1387
    -        int  val0 = _read[0];
    
    1388
    -        int  val1 = _read[1];
    
    1389
    -        int  val2 = _read[2];
    
    1390
    -
    
    1391
    -        if ( val0 | val1 | val2 )
    
    1392
    -        {
    
    1393
    -          if ( val0 == val1 &&
    
    1394
    -               val0 == val2 &&
    
    1395
    -               val0 == max  )
    
    1396
    -          {
    
    1397
    -            _write[0] = color.chroma[0];
    
    1398
    -            _write[1] = color.chroma[1];
    
    1399
    -            _write[2] = color.chroma[2];
    
    1400
    -          }
    
    1401
    -          else
    
    1402
    -          {
    
    1403
    -            /* compose gray value */
    
    1404
    -            grColor pix;
    
    1405
    -
    
    1406
    -            pix.chroma[0] = _write[0];
    
    1407
    -            pix.chroma[1] = _write[1];
    
    1408
    -            pix.chroma[2] = _write[2];
    
    1409
    -
    
    1410
    -            compose_pixel_full( pix, color, val0, val1, val2, max );
    
    1411
    -
    
    1412
    -            _write[0] = pix.chroma[0];
    
    1413
    -            _write[1] = pix.chroma[1];
    
    1414
    -            _write[2] = pix.chroma[2];
    
    1415
    -          }
    
    1416
    -        }
    
    1417
    -        _write += 3;
    
    1418
    -        _read  += 3;
    
    1419
    -        x--;
    
    1420
    -      }
    
    1421
    -
    
    1422
    -      read  += blit->read_line;
    
    1423
    -      write += blit->write_line;
    
    1424
    -      y--;
    
    1425
    -    }
    
    1426
    -    while (y > 0);
    
    1427
    -  }
    
    1428
    -
    
    1429
    -
    
    1430
    -#ifdef GRAY8
    
    1431
    -  static void
    
    1432
    -  blit_lcd28_to_24( grBlitter*  blit,
    
    1433
    -                    grColor     color )
    
    1434
    -  {
    
    1435
    -    int             y;
    
    1436
    -    int             sr = color.chroma[0];
    
    1437
    -    int             sg = color.chroma[1];
    
    1438
    -    int             sb = color.chroma[2];
    
    1439
    -    unsigned char*  read;
    
    1440
    -    unsigned char*  write;
    
    1441
    -
    
    1442
    -    read   = blit->read  + 3*blit->xread;
    
    1443
    -    write  = blit->write + 3*blit->xwrite;
    
    1444
    -
    
    1445
    -    y = blit->height;
    
    1446
    -    do
    
    1447
    -    {
    
    1448
    -      unsigned char*  _read  = read;
    
    1449
    -      unsigned char*  _write = write;
    
    1450
    -      int             x      = blit->width;
    
    1451
    -
    
    1452
    -      while (x > 0)
    
    1453
    -      {
    
    1454
    -        int  val0 = _read[2];
    
    1455
    -        int  val1 = _read[1];
    
    1456
    -        int  val2 = _read[0];
    
    1457
    -
    
    1458
    -        if ( val0 | val1 | val2 )
    
    1459
    -        {
    
    1460
    -          if ( val0 == val1 &&
    
    1461
    -               val0 == val2 &&
    
    1462
    -               val0 == 255  )
    
    1463
    -          {
    
    1464
    -            _write[0] = (unsigned char)sr;
    
    1465
    -            _write[1] = (unsigned char)sg;
    
    1466
    -            _write[2] = (unsigned char)sb;
    
    1467
    -          }
    
    1468
    -          else
    
    1469
    -          {
    
    1470
    -            /* compose gray value */
    
    1471
    -            int   dr, dg, db;
    
    1472
    -
    
    1473
    -            dr  = _write[0];
    
    1474
    -            dr += (sr-dr)*val0 >> 8;
    
    1475
    -
    
    1476
    -            dg  = _write[1];
    
    1477
    -            dg += (sg-dg)*val1 >> 8;
    
    1478
    -
    
    1479
    -            db  = _write[2];
    
    1480
    -            db += (sb-db)*val2 >> 8;
    
    1481
    -
    
    1482
    -            _write[0] = (unsigned char)dr;
    
    1483
    -            _write[1] = (unsigned char)dg;
    
    1484
    -            _write[2] = (unsigned char)db;
    
    1485
    -          }
    
    1486
    -        }
    
    1487
    -        _write += 3;
    
    1488
    -        _read  += 3;
    
    1489
    -        x--;
    
    1490
    -      }
    
    1491
    -
    
    1492
    -      read  += blit->read_line;
    
    1493
    -      write += blit->write_line;
    
    1494
    -      y--;
    
    1495
    -    }
    
    1496
    -    while (y > 0);
    
    1497
    -  }
    
    1498
    -#endif /* GRAY8 */
    
    1499
    -
    
    1500
    -  static void
    
    1501
    -  blit_lcd2_to_24( grBlitter*  blit,
    
    1502
    -                   grColor     color,
    
    1503
    -                   int         max )
    
    1504
    -  {
    
    1505
    -    int             y;
    
    1506
    -    unsigned char*  read;
    
    1507
    -    unsigned char*  write;
    
    1508
    -
    
    1509
    -    read   = blit->read  + 3*blit->xread;
    
    1510
    -    write  = blit->write + 3*blit->xwrite;
    
    1511
    -
    
    1512
    -    y = blit->height;
    
    1513
    -    do
    
    1514
    -    {
    
    1515
    -      unsigned char*  _read  = read;
    
    1516
    -      unsigned char*  _write = write;
    
    1517
    -      int             x      = blit->width;
    
    1518
    -
    
    1519
    -      while (x > 0)
    
    1520
    -      {
    
    1521
    -        int  val0 = _read[2];
    
    1522
    -        int  val1 = _read[1];
    
    1523
    -        int  val2 = _read[0];
    
    1524
    -
    
    1525
    -        if ( val0 | val1 | val2 )
    
    1526
    -        {
    
    1527
    -          if ( val0 == val1 &&
    
    1528
    -               val0 == val2 &&
    
    1529
    -               val0 == max  )
    
    1530
    -          {
    
    1531
    -            _write[0] = color.chroma[0];
    
    1532
    -            _write[1] = color.chroma[1];
    
    1533
    -            _write[2] = color.chroma[2];
    
    1534
    -          }
    
    1535
    -          else
    
    1536
    -          {
    
    1537
    -            /* compose gray value */
    
    1538
    -            grColor pix;
    
    1539
    -
    
    1540
    -            pix.chroma[0] = _write[0];
    
    1541
    -            pix.chroma[1] = _write[1];
    
    1542
    -            pix.chroma[2] = _write[2];
    
    1543
    -
    
    1544
    -            compose_pixel_full( pix, color, val0, val1, val2, max );
    
    1545
    -
    
    1546
    -            _write[0] = pix.chroma[0];
    
    1547
    -            _write[1] = pix.chroma[1];
    
    1548
    -            _write[2] = pix.chroma[2];
    
    1549
    -          }
    
    1550
    -        }
    
    1551
    -        _write += 3;
    
    1552
    -        _read  += 3;
    
    1553
    -        x--;
    
    1554
    -      }
    
    1555
    -
    
    1556
    -      read  += blit->read_line;
    
    1557
    -      write += blit->write_line;
    
    1558
    -      y--;
    
    1559
    -    }
    
    1560
    -    while (y > 0);
    
    1561
    -  }
    
    1562
    -
    
    1563
    -
    
    1564
    -/**************************************************************************/
    
    1565
    -/*                                                                        */
    
    1566
    -/* <Function> blit_lcdv_to_24                                             */
    
    1567
    -/*                                                                        */
    
    1568
    -/**************************************************************************/
    
    1569
    -
    
    1570
    -  static void
    
    1571
    -  blit_lcdv_to_24( grBlitter*  blit,
    
    1572
    -                   grColor     color,
    
    1573
    -                   int         max )
    
    1574
    -  {
    
    1575
    -    int             y;
    
    1576
    -    unsigned char*  read;
    
    1577
    -    unsigned char*  write;
    
    1578
    -    long            line;
    
    1579
    -
    
    1580
    -    read   = blit->read  + blit->xread;
    
    1581
    -    write  = blit->write + 3*blit->xwrite;
    
    1582
    -    line   = blit->read_line;
    
    1583
    -
    
    1584
    -    y = blit->height;
    
    1585
    -    do
    
    1586
    -    {
    
    1587
    -      unsigned char*  _read  = read;
    
    1588
    -      unsigned char*  _write = write;
    
    1589
    -      int             x      = blit->width;
    
    1590
    -
    
    1591
    -      while (x > 0)
    
    1592
    -      {
    
    1593
    -        int  val0 = _read[0*line];
    
    1594
    -        int  val1 = _read[1*line];
    
    1595
    -        int  val2 = _read[2*line];
    
    1596
    -
    
    1597
    -        if ( val0 | val1 | val2 )
    
    1598
    -        {
    
    1599
    -          if ( val0 == val1 &&
    
    1600
    -               val0 == val2 &&
    
    1601
    -               val0 == max  )
    
    1602
    -          {
    
    1603
    -            _write[0] = color.chroma[0];
    
    1604
    -            _write[1] = color.chroma[1];
    
    1605
    -            _write[2] = color.chroma[2];
    
    1606
    -          }
    
    1607
    -          else
    
    1608
    -          {
    
    1609
    -            /* compose gray value */
    
    1610
    -            grColor pix;
    
    1611
    -
    
    1612
    -            pix.chroma[0] = _write[0];
    
    1613
    -            pix.chroma[1] = _write[1];
    
    1614
    -            pix.chroma[2] = _write[2];
    
    1615
    -
    
    1616
    -            compose_pixel_full( pix, color, val0, val1, val2, max );
    
    1617
    -
    
    1618
    -            _write[0] = pix.chroma[0];
    
    1619
    -            _write[1] = pix.chroma[1];
    
    1620
    -            _write[2] = pix.chroma[2];
    
    1621
    -          }
    
    1622
    -        }
    
    1623
    -        _write += 3;
    
    1624
    -        _read  += 1;
    
    1625
    -        x--;
    
    1626
    -      }
    
    1627
    -
    
    1628
    -      read  += 3*line;
    
    1629
    -      write += blit->write_line;
    
    1630
    -      y--;
    
    1631
    -    }
    
    1632
    -    while (y > 0);
    
    1633
    -  }
    
    1634
    -
    
    1635
    -
    
    1636
    -  static void
    
    1637
    -  blit_lcdv2_to_24( grBlitter*  blit,
    
    1638
    -                    grColor     color,
    
    1639
    -                    int         max )
    
    1640
    -  {
    
    1641
    -    int             y;
    
    1642
    -    unsigned char*  read;
    
    1643
    -    unsigned char*  write;
    
    1644
    -    long            line;
    
    1645
    -
    
    1646
    -    read   = blit->read  + blit->xread;
    
    1647
    -    write  = blit->write + 3*blit->xwrite;
    
    1648
    -    line   = blit->read_line;
    
    1649
    -
    
    1650
    -    y = blit->height;
    
    1651
    -    do
    
    1652
    -    {
    
    1653
    -      unsigned char*  _read  = read;
    
    1654
    -      unsigned char*  _write = write;
    
    1655
    -      int             x      = blit->width;
    
    1656
    -
    
    1657
    -      while (x > 0)
    
    1658
    -      {
    
    1659
    -        int  val0 = _read[2*line];
    
    1660
    -        int  val1 = _read[1*line];
    
    1661
    -        int  val2 = _read[0*line];
    
    1662
    -
    
    1663
    -        if ( val0 | val1 | val2 )
    
    1664
    -        {
    
    1665
    -          if ( val0 == val1 &&
    
    1666
    -               val0 == val2 &&
    
    1667
    -               val0 == max  )
    
    1668
    -          {
    
    1669
    -            _write[0] = color.chroma[0];
    
    1670
    -            _write[1] = color.chroma[1];
    
    1671
    -            _write[2] = color.chroma[2];
    
    1672
    -          }
    
    1673
    -          else
    
    1674
    -          {
    
    1675
    -            /* compose gray value */
    
    1676
    -            grColor pix;
    
    1677
    -
    
    1678
    -            pix.chroma[0] = _write[0];
    
    1679
    -            pix.chroma[1] = _write[1];
    
    1680
    -            pix.chroma[2] = _write[2];
    
    1681
    -
    
    1682
    -            compose_pixel_full( pix, color, val0, val1, val2, max );
    
    1683
    -
    
    1684
    -            _write[0] = pix.chroma[0];
    
    1685
    -            _write[1] = pix.chroma[1];
    
    1686
    -            _write[2] = pix.chroma[2];
    
    1687
    -          }
    
    1688
    -        }
    
    1689
    -        _write += 3;
    
    1690
    -        _read  += 1;
    
    1691
    -        x--;
    
    1692
    -      }
    
    1693
    -
    
    1694
    -      read  += 3*line;
    
    1695
    -      write += blit->write_line;
    
    1696
    -      y--;
    
    1697
    -    }
    
    1698
    -    while (y > 0);
    
    1699
    -  }
    
    1700
    -
    
    1701
    -
    
    1702
    -  typedef  void (*grColorGlyphBlitter)( grBlitter*  blit,
    
    1703
    -                                        grColor     color,
    
    1704
    -                                        int         max_gray );
    
    1705
    -
    
    1706
    -  static
    
    1707
    -  const grColorGlyphBlitter  gr_color_blitters[gr_pixel_mode_max] =
    
    1708
    -  {
    
    1709
    -    0,
    
    1710
    -    0,
    
    1711
    -    0,
    
    1712
    -    0,
    
    1713
    -    0,
    
    1714
    -    blit_gray_to_555,
    
    1715
    -    blit_gray_to_565,
    
    1716
    -    blit_gray_to_24,
    
    1717
    -    blit_gray_to_32
    
    1718
    -  };
    
    1719
    -
    
    1720
    -#ifdef GRAY8
    
    1721
    -  typedef  void (*grGray8GlyphBlitter)( grBlitter*  blit,
    
    1722
    -                                        grColor     color );
    
    1723
    -
    
    1724
    -  static
    
    1725
    -  const grGray8GlyphBlitter  gr_gray8_blitters[gr_pixel_mode_max] =
    
    1726
    -  {
    
    1727
    -    0,
    
    1728
    -    0,
    
    1729
    -    0,
    
    1730
    -    0,
    
    1731
    -    0,
    
    1732
    -    blit_gray8_to_555,
    
    1733
    -    blit_gray8_to_565,
    
    1734
    -    blit_gray8_to_24,
    
    1735
    -    blit_gray8_to_32
    
    1736
    -  };
    
    1737
    -#endif
    
    1738
    -
    
    1739
    -
    
    1740
    -  int
    
    1741
    -  grBlitGlyphToBitmap( grBitmap*  target,
    
    1742
    -                       grBitmap*  glyph,
    
    1743
    -                       grPos      x,
    
    1744
    -                       grPos      y,
    
    1745
    -                       grColor    color )
    
    1746
    -  {
    
    1747
    -    grBlitter    blit;
    
    1748
    -    grPixelMode  mode;
    
    1749
    -
    
    1750
    -
    
    1751
    -    /* check arguments */
    
    1752
    -    if ( !target || !glyph )
    
    1753
    -    {
    
    1754
    -      grError = gr_err_bad_argument;
    
    1755
    -      return -1;
    
    1756
    -    }
    
    1757
    -
    
    1758
    -    if ( !glyph->rows || !glyph->width )
    
    1759
    -    {
    
    1760
    -      /* nothing to do */
    
    1761
    -      return 0;
    
    1762
    -    }
    
    1763
    -
    
    1764
    -    /* set up blitter and compute clipping.  Return immediately if needed */
    
    1765
    -    blit.source = *glyph;
    
    1766
    -    blit.target = *target;
    
    1767
    -    mode        = target->mode;
    
    1768
    -
    
    1769
    -    if ( compute_clips( &blit, x, y ) )
    
    1770
    -      return 0;
    
    1771
    -
    
    1772
    -    switch ( glyph->mode )
    
    1773
    -    {
    
    1774
    -    case gr_pixel_mode_mono:     /* handle monochrome bitmap blitting */
    
    1775
    -      if ( mode <= gr_pixel_mode_none || mode >= gr_pixel_mode_max )
    
    1776
    -      {
    
    1777
    -        grError = gr_err_bad_source_depth;
    
    1778
    -        return -1;
    
    1779
    -      }
    
    1780
    -
    
    1781
    -      gr_mono_blitters[mode]( &blit, color );
    
    1782
    -      break;
    
    1783
    -
    
    1784
    -    case gr_pixel_mode_gray:
    
    1785
    -      if ( glyph->grays > 1 )
    
    1786
    -      {
    
    1787
    -        int          target_grays = target->grays;
    
    1788
    -        int          source_grays = glyph->grays;
    
    1789
    -        const byte*  saturation;
    
    1790
    -
    
    1791
    -
    
    1792
    -        if ( mode == gr_pixel_mode_gray && target_grays > 1 )
    
    1793
    -        {
    
    1794
    -          /* rendering into a gray target - use special composition */
    
    1795
    -          /* routines..                                             */
    
    1796
    -          if ( gr_last_saturation->count == target_grays )
    
    1797
    -            saturation = gr_last_saturation->table;
    
    1798
    -          else
    
    1799
    -          {
    
    1800
    -            saturation = grGetSaturation( target_grays );
    
    1801
    -            if ( !saturation )
    
    1802
    -              return -3;
    
    1803
    -          }
    
    1804
    -
    
    1805
    -          if ( target_grays == source_grays )
    
    1806
    -            blit_gray_to_gray_simple( &blit, saturation );
    
    1807
    -          else
    
    1808
    -          {
    
    1809
    -            const byte*  conversion;
    
    1810
    -
    
    1811
    -
    
    1812
    -            if ( gr_last_conversion->target_grays == target_grays &&
    
    1813
    -                 gr_last_conversion->source_grays == source_grays )
    
    1814
    -              conversion = gr_last_conversion->table;
    
    1815
    -            else
    
    1816
    -            {
    
    1817
    -              conversion = grGetConversion( target_grays, source_grays );
    
    1818
    -              if ( !conversion )
    
    1819
    -                return -3;
    
    1820
    -            }
    
    1821
    -
    
    1822
    -            blit_gray_to_gray( &blit, saturation, conversion );
    
    1823
    -          }
    
    1824
    -        }
    
    1825
    -        else
    
    1826
    -        {
    
    1827
    -          /* rendering into a color target */
    
    1828
    -          if ( mode <= gr_pixel_mode_gray ||
    
    1829
    -               mode >= gr_pixel_mode_max  )
    
    1830
    -          {
    
    1831
    -            grError = gr_err_bad_target_depth;
    
    1832
    -            return -1;
    
    1833
    -          }
    
    1834
    -
    
    1835
    -#ifdef GRAY8
    
    1836
    -          if ( source_grays == 256 )
    
    1837
    -            gr_gray8_blitters[mode]( &blit, color );
    
    1838
    -          else
    
    1839
    -#endif /* GRAY8 */
    
    1840
    -          gr_color_blitters[mode]( &blit, color, source_grays - 1 );
    
    1841
    -        }
    
    1842
    -      }
    
    1843
    -      break;
    
    1844
    -
    
    1845
    -    case gr_pixel_mode_lcd:
    
    1846
    -      if ( mode == gr_pixel_mode_rgb24 )
    
    1847
    -      {
    
    1848
    -#ifdef GRAY8
    
    1849
    -        if ( glyph->grays == 256 )
    
    1850
    -          blit_lcd8_to_24( &blit, color );
    
    1851
    -        else
    
    1852
    -#endif
    
    1853
    -        if ( glyph->grays > 1 )
    
    1854
    -          blit_lcd_to_24( &blit, color, glyph->grays-1 );
    
    1855
    -      }
    
    1856
    -      break;
    
    1857
    -
    
    1858
    -
    
    1859
    -    case gr_pixel_mode_lcdv:
    
    1860
    -      if ( glyph->grays > 1 && mode == gr_pixel_mode_rgb24 )
    
    1861
    -      {
    
    1862
    -        blit_lcdv_to_24( &blit, color, glyph->grays-1 );
    
    1863
    -        break;
    
    1864
    -      }
    
    1865
    -      /* fall through */
    
    1866
    -
    
    1867
    -    case gr_pixel_mode_lcd2:
    
    1868
    -      if ( mode == gr_pixel_mode_rgb24 )
    
    1869
    -      {
    
    1870
    -#ifdef GRAY8
    
    1871
    -        if ( glyph->grays == 256 )
    
    1872
    -          blit_lcd28_to_24( &blit, color );
    
    1873
    -        else
    
    1874
    -#endif
    
    1875
    -        if ( glyph->grays > 1 )
    
    1876
    -          blit_lcd2_to_24( &blit, color, glyph->grays-1 );
    
    1877
    -      }
    
    1878
    -      break;
    
    1879
    -
    
    1880
    -    case gr_pixel_mode_lcdv2:
    
    1881
    -      if ( mode == gr_pixel_mode_rgb24 )
    
    1882
    -      {
    
    1883
    -        if ( glyph->grays > 1 )
    
    1884
    -          blit_lcdv2_to_24( &blit, color, glyph->grays-1 );
    
    1885
    -      }
    
    1886
    -      break;
    
    1887
    -
    
    1888
    -    default:
    
    1889
    -      /* we don't support the blitting of bitmaps of the following  */
    
    1890
    -      /* types : pal4, pal8, rgb555, rgb565, rgb24, rgb32           */
    
    1891
    -      /*                                                            */
    
    1892
    -      grError = gr_err_bad_source_depth;
    
    1893
    -      return -2;
    
    1894
    -    }
    
    1895
    -
    
    1896
    -    return 0;
    
    1897
    -  }
    
    1898
    -
    
    1899
    -
    
    1900
    -  void
    
    1901
    -  grBlitClean( void )
    
    1902
    -  {
    
    1903
    -    while ( gr_num_saturations > 2 )
    
    1904
    -      free( (byte*)gr_saturations[gr_num_saturations--].table );
    
    1905
    -
    
    1906
    -    while ( gr_num_conversions > 3 )
    
    1907
    -      free( (byte*)gr_conversions[gr_num_conversions--].table );
    
    1908
    -  }
    
    1909
    -
    
    1910
    -
    
    1911
    -/* End */

  • graph/grblit.h deleted
    1
    -/****************************************************************************/
    
    2
    -/*                                                                          */
    
    3
    -/*  The FreeType project -- a free and portable quality TrueType renderer.  */
    
    4
    -/*                                                                          */
    
    5
    -/*  Copyright (C) 1996-2021 by                                              */
    
    6
    -/*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
    
    7
    -/*                                                                          */
    
    8
    -/*  blitter.h: Support for blitting of bitmaps with various depth.          */
    
    9
    -/*                                                                          */
    
    10
    -/****************************************************************************/
    
    11
    -
    
    12
    -#ifndef GRBLIT_H_
    
    13
    -#define GRBLIT_H_
    
    14
    -
    
    15
    -#include "grobjs.h"
    
    16
    -
    
    17
    -  int  grBlitMono( grBitmap*  target,
    
    18
    -                   grBitmap*  source,
    
    19
    -                   int        x_offset,
    
    20
    -                   int        y_offset,
    
    21
    -                   grColor    color );
    
    22
    -
    
    23
    -
    
    24
    -#endif /* GRBLIT_H_ */
    
    25
    -
    
    26
    -
    
    27
    -/* End */

  • graph/grconfig.h
    ... ... @@ -2,7 +2,5 @@
    2 2
     #define GRCONFIG_H_
    
    3 3
     
    
    4 4
     #define GR_FONT_SIZE        14
    
    5
    -#define GR_MAX_SATURATIONS  8
    
    6
    -#define GR_MAX_CONVERSIONS  16
    
    7 5
     
    
    8 6
     #endif /* GRCONFIG_H_ */

  • graph/grfont.c
    ... ... @@ -561,7 +561,7 @@
    561 561
           return;
    
    562 562
     
    
    563 563
         gr_charcell.buffer = font[charcode];
    
    564
    -    grBlitGlyphToBitmap( target, &gr_charcell, x, y, color );
    
    564
    +    grBlitGlyphToSurface( (grSurface*)target, &gr_charcell, x, y, color );
    
    565 565
       }
    
    566 566
     
    
    567 567
     
    
    ... ... @@ -575,7 +575,7 @@
    575 575
         while ( *string )
    
    576 576
         {
    
    577 577
           gr_charcell.buffer = font[*(unsigned char*)string++];
    
    578
    -      grBlitGlyphToBitmap( target, &gr_charcell, x, y, color );
    
    578
    +      grBlitGlyphToSurface( (grSurface*)target, &gr_charcell, x, y, color );
    
    579 579
           x += 8;
    
    580 580
         }
    
    581 581
       }
    

  • graph/meson.build
    ... ... @@ -20,8 +20,6 @@ graph_sources = files([
    20 20
       'gblender.c',
    
    21 21
       'gblender.h',
    
    22 22
       'graph.h',
    
    23
    -  'grblit.c',
    
    24
    -  'grblit.h',
    
    25 23
       'grconfig.h',
    
    26 24
       'grdevice.c',
    
    27 25
       'grdevice.h',
    

  • graph/rules.mk
    ... ... @@ -19,7 +19,6 @@ GRAPH_H := $(GRAPH)/gblany.h \
    19 19
                $(GRAPH)/gblblit.h   \
    
    20 20
                $(GRAPH)/gblender.h  \
    
    21 21
                $(GRAPH)/graph.h     \
    
    22
    -           $(GRAPH)/grblit.h    \
    
    23 22
                $(GRAPH)/grconfig.h  \
    
    24 23
                $(GRAPH)/grdevice.h  \
    
    25 24
                $(GRAPH)/grevents.h  \
    
    ... ... @@ -31,7 +30,6 @@ GRAPH_H := $(GRAPH)/gblany.h \
    31 30
     
    
    32 31
     GRAPH_OBJS := $(OBJ_DIR_2)/gblblit.$(O)   \
    
    33 32
                   $(OBJ_DIR_2)/gblender.$(O)  \
    
    34
    -              $(OBJ_DIR_2)/grblit.$(O)    \
    
    35 33
                   $(OBJ_DIR_2)/grdevice.$(O)  \
    
    36 34
                   $(OBJ_DIR_2)/grfill.$(O)    \
    
    37 35
                   $(OBJ_DIR_2)/grfont.$(O)    \
    

  • vms_make.com
    ... ... @@ -103,8 +103,7 @@ OBJDIR = [.objs]
    103 103
     # include paths
    
    104 104
     INCLUDES = /include=([-.freetype2.include],[.graph],[.src])
    
    105 105
     
    
    106
    -GRAPHOBJ = $(OBJDIR)grblit.obj,  \
    
    107
    -           $(OBJDIR)grobjs.obj,  \
    
    106
    +GRAPHOBJ = $(OBJDIR)grobjs.obj,  \
    
    108 107
                $(OBJDIR)grfont.obj,  \
    
    109 108
                $(OBJDIR)grinit.obj,  \
    
    110 109
                $(OBJDIR)grdevice.obj,\
    
    ... ... @@ -112,8 +111,7 @@ GRAPHOBJ = $(OBJDIR)grblit.obj, \
    112 111
                $(OBJDIR)gblender.obj, \
    
    113 112
                $(OBJDIR)gblblit.obj,$(OBJDIR)grfill.obj
    
    114 113
     
    
    115
    -GRAPHOBJ64 = $(OBJDIR)grblit_64.obj,  \
    
    116
    -           $(OBJDIR)grobjs_64.obj,  \
    
    114
    +GRAPHOBJ64 = $(OBJDIR)grobjs_64.obj,  \
    
    117 115
                $(OBJDIR)grfont_64.obj,  \
    
    118 116
                $(OBJDIR)grinit_64.obj,  \
    
    119 117
                $(OBJDIR)grdevice_64.obj,\
    
    ... ... @@ -272,7 +270,6 @@ $(OBJDIR)ftmemchk.obj : $(SRCDIR)ftmemchk.c
    272 270
     $(OBJDIR)ftdump.obj    : $(SRCDIR)ftdump.c
    
    273 271
     $(OBJDIR)testname.obj  : $(SRCDIR)testname.c
    
    274 272
     $(OBJDIR)ftview.obj    : $(SRCDIR)ftview.c
    
    275
    -$(OBJDIR)grblit.obj    : $(GRAPHSRC)grblit.c
    
    276 273
     $(OBJDIR)grobjs.obj    : $(GRAPHSRC)grobjs.c
    
    277 274
     $(OBJDIR)grfont.obj    : $(GRAPHSRC)grfont.c
    
    278 275
     $(OBJDIR)gblender.obj  : $(GRAPHSRC)gblender.c
    


  • reply via email to

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