⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ttraster.c

📁 神龙卡开发原代码
💻 C
📖 第 1 页 / 共 5 页
字号:
          /*   - P_Left is the successor of P_Right in that contour */          /*   - y is the bottom of P_Left                          */          /*                                                        */          /* FIXXXME : uncommenting this line solves the disappearing */          /*           bit problem in the '7' of verdana 10pts, but   */          /*           makes a new one in the 'C' of arial 14pts      */          /* if ( x2-x1 < ras.precision_half ) */          {            /* upper stub test */            if ( left->next == right && left->height <= 0 ) return;            /* lower stub test */            if ( right->next == left && left->start == y ) return;          }          /* check that the rightmost pixel isn't set */          e1 = TRUNC( e1 );          c1 = (Short)(e1 >> 3);          f1 = e1 &  7;          if ( e1 >= 0 && e1 < ras.bWidth &&               ras.bTarget[ras.traceOfs + c1] & (0x80 >> f1) )            return;          if ( ras.dropOutControl == 2 )            e1 = e2;          else            e1 = CEILING( (x1 + x2 + 1) / 2 );          break;        default:          return;  /* unsupported mode */        }      }      else        return;    }    e1 = TRUNC( e1 );    if ( e1 >= 0 && e1 < ras.bWidth )    {      c1 = (Short)(e1 >> 3);      f1 = e1 & 7;      if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1;      if ( ras.gray_max_x < c1 ) ras.gray_max_x = c1;      ras.bTarget[ras.traceOfs + c1] |= (Char)(0x80 >> f1);    }  }  static void Vertical_Sweep_Step( RAS_ARG )  {    ras.traceOfs += ras.traceIncr;  }/***********************************************************************//*                                                                     *//*  Horizontal Sweep Procedure Set :                                   *//*                                                                     *//*  These three routines are used during the horizontal black/white    *//*  sweep phase by the generic Draw_Sweep() function.                  *//*                                                                     *//***********************************************************************/  static void  Horizontal_Sweep_Init( RAS_ARGS Short*  min, Short*  max )  {    /* nothing, really */  }  static void  Horizontal_Sweep_Span( RAS_ARGS Short       y,                                               TT_F26Dot6  x1,                                               TT_F26Dot6  x2,                                               PProfile    left,                                               PProfile    right )  {    Long  e1, e2;    PByte bits;    Byte  f1;    if ( x2-x1 < ras.precision )    {      e1 = CEILING( x1 );      e2 = FLOOR  ( x2 );      if ( e1 == e2 )      {        bits = ras.bTarget + (y >> 3);        f1   = (Byte)(0x80 >> (y  & 7));        e1 = TRUNC( e1 );        if ( e1 >= 0 && e1 < ras.target.rows )        {          if ( ras.target.flow == TT_Flow_Down )            bits[(ras.target.rows-1 - e1) * ras.target.cols] |= f1;          else            bits[e1 * ras.target.cols] |= f1;        }      }    }#if 0      e2 = TRUNC( e2 );      if ( e2 >= 0 && e2 < ras.target.rows )        if ( ras.target.flow == TT_Flow_Down )          bits[(ras.target.rows-1-e2) * ras.target.cols] |= f1;        else          bits[e2 * ras.target.cols] |= f1;#endif  }  static void  Horizontal_Sweep_Drop( RAS_ARGS Short       y,                                               TT_F26Dot6  x1,                                               TT_F26Dot6  x2,                                               PProfile    left,                                               PProfile    right )  {    Long  e1, e2;    PByte bits;    Byte  f1;    /* During the horizontal sweep, we only take care of drop-outs */    e1 = CEILING( x1 );    e2 = FLOOR  ( x2 );    if ( e1 > e2 )    {      if ( e1 == e2 + ras.precision )      {        switch ( ras.dropOutControl )        {        case 1:          e1 = e2;          break;        case 4:          e1 = CEILING( (x1 + x2 + 1) / 2 );          break;        case 2:        case 5:          /* Drop-out Control Rule #4 */          /* The spec is not very clear regarding rule #4.  It      */          /* presents a method that is way too costly to implement  */          /* while the general idea seems to get rid of 'stubs'.    */          /*                                                        */          /* rightmost stub test */          if ( left->next == right && left->height <= 0 ) return;          /* leftmost stub test */          if ( right->next == left && left->start == y ) return;          /* check that the rightmost pixel isn't set */          e1 = TRUNC( e1 );          bits = ras.bTarget + (y >> 3);          f1   = (Byte)(0x80 >> (y &  7));          if ( ras.target.flow == TT_Flow_Down )            bits += (ras.target.rows-1-e1) * ras.target.cols;          else            bits += e1 * ras.target.cols;          if ( e1 >= 0              &&               e1 < ras.target.rows &&               *bits & f1 )            return;          if ( ras.dropOutControl == 2 )            e1 = e2;          else            e1 = CEILING( (x1 + x2 + 1) / 2 );          break;        default:          return;  /* unsupported mode */        }      }      else        return;    }    bits = ras.bTarget + (y >> 3);    f1   = (Byte)(0x80 >> (y  & 7));    e1 = TRUNC( e1 );    if ( e1 >= 0 && e1 < ras.target.rows )    {      if (ras.target.flow==TT_Flow_Down)        bits[(ras.target.rows-1-e1) * ras.target.cols] |= f1;      else        bits[e1 * ras.target.cols] |= f1;    }  }  static void Horizontal_Sweep_Step( RAS_ARG )  {    /* Nothing, really */  }#ifdef TT_CONFIG_OPTION_GRAY_SCALING/***********************************************************************//*                                                                     *//*  Vertical Gray Sweep Procedure Set:                                 *//*                                                                     *//*  These two routines are used during the vertical gray-levels        *//*  sweep phase by the generic Draw_Sweep() function.                  *//*                                                                     *//*                                                                     *//*  NOTES:                                                             *//*                                                                     *//*  - The target pixmap's width *must* be a multiple of 4.             *//*                                                                     *//*  - you have to use the function Vertical_Sweep_Span() for           *//*    the gray span call.                                              *//*                                                                     *//***********************************************************************/  static void  Vertical_Gray_Sweep_Init( RAS_ARGS Short*  min, Short*  max )  {    *min = *min & -2;    *max = ( *max + 3 ) & -2;    ras.traceOfs = 0;    switch ( ras.target.flow )    {    case TT_Flow_Up:      ras.traceG  = (*min / 2) * ras.target.cols;      ras.traceIncr = ras.target.cols;      break;    default:      ras.traceG    = (ras.target.rows-1 - *min/2) * ras.target.cols;      ras.traceIncr = -ras.target.cols;    }    ras.gray_min_x =  ras.target.cols;    ras.gray_max_x = -ras.target.cols;  }  static void  Vertical_Gray_Sweep_Step( RAS_ARG )  {    Int    c1, c2;    PByte  pix, bit, bit2;    Int*   count = ras.count_table;    Byte*  grays;    ras.traceOfs += ras.gray_width;    if ( ras.traceOfs > ras.gray_width )    {      pix   = ras.gTarget + ras.traceG + ras.gray_min_x * 4;      grays = ras.grays;      if ( ras.gray_max_x >= 0 )      {        if ( ras.gray_max_x >= ras.target.width )          ras.gray_max_x = ras.target.width-1;        if ( ras.gray_min_x < 0 )          ras.gray_min_x = 0;        bit   = ras.bTarget + ras.gray_min_x;        bit2  = bit + ras.gray_width;        c1 = ras.gray_max_x - ras.gray_min_x;        while ( c1 >= 0 )        {          c2 = count[*bit] + count[*bit2];          if ( c2 )          {            pix[0] = grays[(c2 & 0xF000) >> 12];            pix[1] = grays[(c2 & 0x0F00) >>  8];            pix[2] = grays[(c2 & 0x00F0) >>  4];            pix[3] = grays[(c2 & 0x000F)      ];            *bit  = 0;            *bit2 = 0;          }          bit ++;          bit2++;          pix += 4;          c1  --;        }      }      ras.traceOfs = 0;      ras.traceG  += ras.traceIncr;      ras.gray_min_x =  ras.target.cols;      ras.gray_max_x = -ras.target.cols;    }  }  static void  Horizontal_Gray_Sweep_Span( RAS_ARGS Short       y,                                                    TT_F26Dot6  x1,                                                    TT_F26Dot6  x2,                                                    PProfile    left,                                                    PProfile    right )  {    /* nothing, really */  }  static void  Horizontal_Gray_Sweep_Drop( RAS_ARGS Short       y,                                                    TT_F26Dot6  x1,                                                    TT_F26Dot6  x2,                                                    PProfile    left,                                                    PProfile    right )  {    Long  e1, e2;    PByte pixel;    Byte  color;    /* During the horizontal sweep, we only take care of drop-outs */    e1 = CEILING( x1 );    e2 = FLOOR  ( x2 );    if ( e1 > e2 )    {      if ( e1 == e2 + ras.precision )      {        switch ( ras.dropOutControl )        {        case 1:          e1 = e2;          break;        case 4:          e1 = CEILING( (x1 + x2 + 1) / 2 );          break;        case 2:        case 5:          /* Drop-out Control Rule #4 */          /* The spec is not very clear regarding rule #4.  It      */          /* presents a method that is way too costly to implement  */          /* while the general idea seems to get rid of 'stubs'.    */          /*                                                        */          /* rightmost stub test */          if ( left->next == right && left->height <= 0 ) return;          /* leftmost stub test */          if ( right->next == left && left->start == y ) return;          if ( ras.dropOutControl == 2 )            e1 = e2;          else            e1 = CEILING( (x1 + x2 + 1) / 2 );          break;        default:          return;  /* unsupported mode */        }      }      else        return;    }    if ( e1 >= 0 )    {      if ( x2 - x1 >= ras.precision_half )        color = ras.grays[2];      else        color = ras.grays[1];      e1 = TRUNC( e1 ) / 2;      if ( e1 < ras.target.rows )      {        if ( ras.target.flow == TT_Flow_Down )          pixel = ras.gTarget +                  (ras.target.rows - 1 - e1) * ras.target.cols + y / 2;        else          pixel = ras.gTarget +                  e1 * ras.target.cols + y / 2;        if (pixel[0] == ras.grays[0])          pixel[0] = color;      }    }  }#endif /* TT_CONFIG_OPTION_GRAY_SCALING *//********************************************************************//*                

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -