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

📄 hints.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 3 页
字号:
               next->link = edge;               edge->flag ^= ISLEFT(ON);               edge->flag &= ~ISAMBIGUOUS(ON);               next->flag ^= ISLEFT(ON);               next->flag &= ~ISAMBIGUOUS(ON);               edge = next;       }}/*:h3.DumpSubPaths() A debug tool.*/ static struct edgelist *before();  /* subroutine of DumpSubPaths             */ static void DumpSubPaths(anchor)       struct edgelist *anchor;{        register struct edgelist *edge,*e,*e2;       pel y;        for (edge = anchor; VALIDEDGE(edge); edge = edge->link) {               if (ISPERMANENT(edge->flag))                       continue;               IfTrace0(TRUE, "BEGIN Subpath\n");               for (e2 = edge; !ISPERMANENT(e2->flag);) {                       if (ISDOWN(e2->flag)) {                               IfTrace1(TRUE, ". Downgoing edge's top at %x\n", e2);                               for (e = e2;; e = e->subpath) {                                       IfTrace4(TRUE, ". . [%5d] %5d    @ %x[%x]\n",                                                e->ymin, *e->xvalues, e, e->flag);                                       for (y=e->ymin+1; y < e->ymax; y++)                                               IfTrace2(TRUE, ". . [%5d] %5d     \"\n", y, e->xvalues[y-e->ymin]);                                       e->flag |= ISPERMANENT(ON);                                       if (ISBREAK(e, e->subpath))                                               break;                               }                       }                       else {                               IfTrace1(TRUE, ". Upgoing edge's top at %x\n", e2);                               for (e = e2; !ISBREAK(e, e->subpath); e = e->subpath) { ; }                               for (;; e=before(e)) {                                       IfTrace4(TRUE, ". . [%5d] %5d    @ %x[%x]\n",                                                e->ymax-1, e->xvalues[e->ymax-1-e->ymin], e, e->flag);                                       for (y=e->ymax-2; y >= e->ymin; y--)                                               IfTrace2(TRUE, ". . [%5d] %5d      \"\n", y, e->xvalues[y-e->ymin]);                                       e->flag |= ISPERMANENT(ON);                                       if (e == e2)                                               break;                               }                       }                       do {                               e2 = before(e2);                       } while (!ISBREAK(before(e2), e2));               }       }} static struct edgelist *before(e)       struct edgelist *e;{       struct edgelist *r;       for (r = e->subpath; r->subpath != e; r = r->subpath) { ; }       return(r);} /*:h2.Fixing Region Continuity Problems Small regions may become disconnected when their connecting segments areless than a pel wide.  This may be correct in some applications, but inmany (especially small font characters), it is more pleasing to keepconnectivity.  ApplyContinuity() (invoked by +CONTINUITY on theInterior() fill rule) fixes connection breaks.  The resulting regionis geometrically less accurate, but may be more pleasing to the eye.*//*Here are some macros which we will need:*/ #define IsValidPel(j) (j!=MINPEL) /*:h3.writeXofY() - Stuffs an X Value Into an "edgelist" writeXofY writes an x value into an edge at position 'y'.  It mustupdate the edge's xmin and xmax.  If there is a possibility that thisnew x might exceed the region's bounds, updating those are theresponsibility of the caller.*/ static void writeXofY(e, y, x)       struct edgelist *e;   /* relevant edgelist                            */       int y;                /* y value                                      */       int x;                /* new x value                                  */{       if (e->xmin > x)  e->xmin = x;       if (e->xmax < x)  e->xmax = x;       e->xvalues[y - e->ymin] = x;} /*-------------------------------------------------------------------------*//* the following three macros tell us whether we are at a birth point, a    *//* death point, or simply in the middle of the character                *//*-------------------------------------------------------------------------*/#define WeAreAtTop(e,i) (ISTOP(e->flag) && e->ymin == i)#define WeAreAtBottom(e,i) (ISBOTTOM(e->flag) && e->ymax-1 == i)#define WeAreInMiddle(e,i) \      ((!ISTOP(e->flag) && !ISBOTTOM(e->flag))||(i < e->ymax-1 && i > e->ymin))/*The following macro tests if two "edgelist" structures are in the sameswath:*/#define SAMESWATH(e1,e2)  (e1->ymin == e2->ymin) /*:h3.CollapseWhiteRun() - Subroutine of ApplyContinuity() When we have a white run with an implied horizontal line above orbelow it, we better have black on the other side of this line.  Thisfunction both tests to see if black is there, and adjusts the endpoints (collapses) the white run as necessary if it is not.  Thegoal is to collapse the white run as little as possible.*/ static void CollapseWhiteRun(anchor, yblack, left, right, ywhite)        struct edgelist *anchor;  /* anchor of edge list                     */        pel yblack;          /* y of (hopefully) black run above or below    */        struct edgelist *left;  /* edgelist at left of WHITE run             */        struct edgelist *right;  /* edgelist at right of WHITE run           */        pel ywhite;          /* y location of white run                      */{       struct edgelist *edge;       struct edgelist *swathstart = anchor;       register pel x;        if (XofY(left, ywhite) >= XofY(right, ywhite))               return;/*Find the swath with 'yblack'.  If we don't find it, completely collapsethe white run and return:*/       while (VALIDEDGE(swathstart)) {               if (yblack < swathstart->ymin)  {                      writeXofY(left, ywhite, XofY(right, ywhite));                      return;               }               if (yblack < swathstart->ymax) break;               swathstart = swathstart->link->link;       }       if(!VALIDEDGE(swathstart)) {               writeXofY(left, ywhite, XofY(right, ywhite));               return;       }/*Now we are in the swath that contains 'y', the reference line aboveor below that we are trying to maintain continuity with.  If blackin this line begins in the middle of our white run, we must collapsethe white run from the left to that point.  If black ends in themiddle of our white run, we must collapse the white run from the rightto that point.*/       for (edge = swathstart; VALIDEDGE(edge); edge = edge->link) {                if (!SAMESWATH(swathstart,edge))                       break;               if( XofY(edge, yblack) > XofY(left, ywhite)) {                       if (ISLEFT(edge->flag)) {                                x = XofY(edge, yblack);                                if (XofY(right, ywhite) < x)                                       x = XofY(right, ywhite);                                writeXofY(left, ywhite, x);                       }                       else {                                x = XofY(edge, yblack);                                while (edge->link != NULL && SAMESWATH(edge, edge->link)                                       && x >= XofY(edge->link, yblack) ) {                                       edge = edge->link->link;                                       x = XofY(edge, yblack);                                }                                if (x < XofY(right, ywhite))                                       writeXofY(right, ywhite, x);                                return;                       }               }       }       writeXofY(left, ywhite, XofY(right, ywhite));} /*:h3.ApplyContinuity() - Fix False Breaks in a Region This is the externally visible routine called from the REGIONS modulewhen the +CONTINUITY flag is on the Interior() fill rule.*/ void ApplyContinuity(R)struct region *R;{ struct edgelist *left; struct edgelist *right; struct edgelist *edge,*e2; pel rightXabove,rightXbelow,leftXabove,leftXbelow; pel leftX,rightX; int i; long newcenter,abovecenter,belowcenter;  FixSubPaths(R); if (RegionDebug >= 3)        DumpSubPaths(R->anchor); left = R->anchor;/* loop through and do all of the easy checking. ( no tops or bottoms) */ while(VALIDEDGE(left)) {  right = left->link;  for(i=left->ymin;i<left->ymax;++i)  {   leftX       = findXofY(left,i);   rightX      = findXofY(right,i);   leftXbelow  = findXofY(left,i+1);   rightXbelow = findXofY(right,i+1);   if(rightX <= leftX)   {/* then, we have a break in a near vertical line */     leftXabove  = findXofY(left,i-1);     rightXabove = findXofY(right,i-1);     if( IsValidPel(leftXabove) && IsValidPel(rightXabove) )     {      abovecenter = leftXabove + rightXabove;     }     else     {      abovecenter = leftX + rightX;     }     if( IsValidPel(leftXbelow) && IsValidPel(rightXbelow) )     {      belowcenter = leftXbelow + rightXbelow;     }     else     {      belowcenter = leftX + rightX;     }     newcenter = abovecenter + belowcenter;     if( newcenter > 4*leftX )     {      rightX = rightX + 1;     }     else if( newcenter < 4*leftX)     {      leftX = leftX - 1;     }     else     {      rightX = rightX + 1;     }     writeXofY(right,i,rightX);     writeXofY(left,i,leftX);     if(rightX > R->xmax) {R->xmax = rightX;}     if(leftX < R->xmin) {R->xmin = leftX;}   }   if( !WeAreAtBottom(left,i) && (leftXbelow>=rightX))   {/* then we have a break in a near horizontal line in the middle */    writeXofY(right,i,leftXbelow);   }   if( !WeAreAtBottom(right,i) && (leftX >=rightXbelow))   {/* then we have a break in a near horizontal line in the middle */    writeXofY(left,i,rightXbelow);   }  }  left = right->link; }/*There may be "implied horizontal lines" between edges that haveimplications for continuity.  This loop looks for white runs thathave implied horizontal lines on the top or bottom, and callsCollapseWhiteRuns to check and fix any continuity problems fromthem.*/      for (edge = R->anchor; VALIDEDGE(edge); edge = edge->link) {              if ((!ISTOP(edge->flag) && !ISBOTTOM(edge->flag)) || ISLEFT(edge->flag))                      continue;  /* at some future date we may want left edge logic here too */              for (e2 = edge->link; VALIDEDGE(e2) && SAMESWATH(edge,e2); e2 = e2->link) {                      if (ISTOP(e2->flag) && ISTOP(edge->flag)                          && NONE != ImpliedHorizontalLine(edge,e2,edge->ymin)) {                              if (ISLEFT(e2->flag))                                      CollapseWhiteRun(R->anchor, edge->ymin-1,                                                       edge, e2, edge->ymin);                      }                      if (ISBOTTOM(e2->flag) && ISBOTTOM(edge->flag)                          && NONE != ImpliedHorizontalLine(edge,e2, edge->ymax)) {                              if (ISLEFT(e2->flag))                                      CollapseWhiteRun(R->anchor, edge->ymax,                                                       edge, e2, edge->ymax-1);                      }              }      }}    

⌨️ 快捷键说明

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