Xiaolin Wu的线算法C语言源代码在哪里可以找到?

11

我正在寻找一种优美高效的C语言实现方式,用于Xiaolin Wu反走样线绘制算法。是否有人能够分享此代码?

谢谢!

2个回答

13

谢谢你给我的第二个链接,这正是我想要的。我自己在 Google 上搜索了一下,但不知道为什么没找到这些链接,谢谢! :) - horseyguy
维基百科的伪代码如果行末在行首左侧或上方时无法正常工作(也就是说,它只能按照递增的X、Y坐标来工作)。 - smirkingman

0

想知道实现这里是否正确,因为在

ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY;
      /* Draw all pixels other than the first and last */
while (--DeltaY) {
         ErrorAccTemp = ErrorAcc;   /* remember current accumulated error */
         ErrorAcc += ErrorAdj;      /* calculate error for next pixel */
         if (ErrorAcc <= ErrorAccTemp) {
            /* The error accumulator turned over, so advance the X coord */
            X0 += XDir;
         }
         Y0++; /* Y-major, so always advance Y */
         /* The IntensityBits most significant bits of ErrorAcc give us the
            intensity weighting for this pixel, and the complement of the
            weighting for the paired pixel */
         Weighting = ErrorAcc >> IntensityShift;
         DrawPixel(pDC,X0, Y0, BaseColor + Weighting);
         DrawPixel(pDC,X0 + XDir, Y0,
               BaseColor + (Weighting ^ WeightingComplementMask));
      }

条件 if (ErrorAcc <= ErrorAccTemp) 总是为假。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接