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

📄 ftbbox.c

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 C
📖 第 1 页 / 共 2 页
字号:
    {      FT_Pos  y1 = arc[0];      FT_Pos  y2 = arc[1];      FT_Pos  y3 = arc[2];      FT_Pos  y4 = arc[3];      if ( y1 == y4 )      {        if ( y1 == y2 && y1 == y3 )                         /* Flat */        {          y4 = y1;          goto Test;        }      }      else if ( y1 < y4 )      {        if ( y2 >= y1 && y2 <= y4 && y3 >= y1 && y3 <= y4 ) /* Ascending */          goto Test;      }      else      {        if ( y2 >= y4 && y2 <= y1 && y3 >= y4 && y3 <= y1 ) /* Descending */        {          y2 = y1;          y1 = y4;          y4 = y2;          goto Test;        }      }      /* Unknown direction, split the arc in two */      arc[6] = y4;      arc[1] = y1 = ( y1 + y2 ) / 2;      arc[5] = y4 = ( y4 + y3 ) / 2;      y2 = ( y2 + y3 ) / 2;      arc[2] = y1 = ( y1 + y2 ) / 2;      arc[4] = y4 = ( y4 + y2 ) / 2;      arc[3] = ( y1 + y4 ) / 2;      arc += 3;      goto Suite;   Test:      if ( y1 < *min ) *min = y1;      if ( y4 > *max ) *max = y4;      arc -= 3;    Suite:      ;    } while (arc >= stack);  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    BBox_Cubic_To                                                      */  /*                                                                       */  /* <Description>                                                         */  /*    This function is used as a `cubic_to' emitter during               */  /*    FT_Raster_Decompose().  It checks a cubic Bezier curve with the    */  /*    current bounding box, and computes its extrema if necessary to     */  /*    update it.                                                         */  /*                                                                       */  /* <Input>                                                               */  /*    control1 :: A pointer to the first control point.                  */  /*    control2 :: A pointer to the second control point.                 */  /*    to       :: A pointer to the destination vector.                   */  /*                                                                       */  /* <InOut>                                                               */  /*    user     :: The address of the current walk context.               */  /*                                                                       */  /* <Return>                                                              */  /*    Error code.  0 means success.                                      */  /*                                                                       */  /* <Note>                                                                */  /*    In the case of a non-monotonous arc, we don't compute directly     */  /*    extremum coordinates, we subdivise instead.                        */  /*                                                                       */  static  int  BBox_Cubic_To( FT_Vector*  control1,                      FT_Vector*  control2,                      FT_Vector*  to,                      TBBox_Rec*  user )  {    if ( CHECK_X( control1, user->bbox ) ||         CHECK_X( control2, user->bbox ) ||         CHECK_X( to,       user->bbox ) )        BBox_Cubic_Check( user->last.x,                          control1->x,                          control2->x,                          to->x,                          &user->bbox.xMin,                          &user->bbox.xMax );    if ( CHECK_Y( control1, user->bbox ) ||         CHECK_Y( control2, user->bbox ) ||         CHECK_Y( to,       user->bbox ) )        BBox_Cubic_Check( user->last.y,                          control1->y,                          control2->y,                          to->y,                          &user->bbox.yMin,                          &user->bbox.yMax );    return 0;  }  /*************************************************************************/  /*                                                                       */  /* <Function>                                                            */  /*    FT_Raster_GetBBox                                                  */  /*                                                                       */  /* <Description>                                                         */  /*    Computes the exact bounding box of an outline.  This is slower     */  /*    than computing the control box.  However, it uses an advanced      */  /*    algorithm which returns _very_ quickly when the two boxes          */  /*    coincide.  Otherwise, the outline Bezier arcs are walked over to   */  /*    extract their extrema.                                             */  /*                                                                       */  /* <Input>                                                               */  /*    outline :: A pointer to the source outline.                        */  /*                                                                       */  /* <Output>                                                              */  /*    abbox   :: A pointer to the outline's exact bounding box.          */  /*                                                                       */  /* <Return>                                                              */  /*    Error code.  0 means success.                                      */  /*                                                                       */  EXPORT_FUNC  FT_Error  FT_Raster_GetBBox( FT_Outline*  outline,                               FT_BBox*     abbox )  {    FT_BBox    cbox;    FT_BBox    bbox;    FT_Vector* vec;    FT_UShort  n;    /* if outline is empty, return (0,0,0,0) */    if ( !outline )      return FT_Err_Invalid_Outline;    if ( outline->n_points == 0 || outline->n_contours <= 0 )    {      abbox->xMin = abbox->xMax = 0;      abbox->yMin = abbox->yMax = 0;      return 0;    }    /* We compute the control box as well as the bounding box of  */    /* all `on' points in the outline.  Then, if the two boxes    */    /* coincide, we exit immediately.                             */    vec = outline->points;    bbox.xMin = bbox.xMax = cbox.xMin = cbox.xMax = vec->x;    bbox.yMin = bbox.yMax = cbox.yMin = cbox.yMax = vec->y;    for ( n = 1; n < outline->n_points; n++ )    {      FT_Pos  x = vec->x;      FT_Pos  y = vec->y;      /* update control box */      if ( x < cbox.xMin ) cbox.xMin = x;      if ( x > cbox.xMax ) cbox.xMax = x;      if ( y < cbox.yMin ) cbox.yMin = y;      if ( y > cbox.yMax ) cbox.yMax = y;      if ( FT_CURVE_TAG( outline->tags[n] ) == FT_Curve_Tag_On )      {        /* update bbox for `on' points only */        if ( x < bbox.xMin ) bbox.xMin = x;        if ( x > bbox.xMax ) bbox.xMax = x;        if ( y < bbox.yMin ) bbox.yMin = y;        if ( y > bbox.yMax ) bbox.yMax = y;      }      vec++;    }    /* test two boxes for equality */    if ( cbox.xMin < bbox.xMin || cbox.xMax > bbox.xMax ||         cbox.yMin < bbox.yMin || cbox.yMax > bbox.yMax )    {      /* the two boxes are different, now walk over the outline to */      /* get the Bezier arc extrema.                               */      static FT_Outline_Funcs  interface =      {        (FT_Outline_MoveTo_Func) BBox_Move_To,        (FT_Outline_LineTo_Func) BBox_Move_To,        (FT_Outline_ConicTo_Func)BBox_Conic_To,        (FT_Outline_CubicTo_Func)BBox_Cubic_To      };      FT_Error   error;      TBBox_Rec  user;      user.bbox = bbox;      error = FT_Outline_Decompose( outline, &interface, &user );      if ( error )        return error;      *abbox = user.bbox;    }    else      *abbox = bbox;    return FT_Err_Ok;  }/* END */

⌨️ 快捷键说明

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