11

我正在寻找一个用 C 语言来实现吴晓林的抗锯齿线条绘制算法的一个很好且有效的实现,有人有这个代码可以与我分享吗?

谢谢

4

2 回答 2

13

维基百科有伪代码

谷歌有很多这样例子。你的问题让我想起了这篇关于抗锯齿的好文章。

编辑:如果您还不知道Hugo Helias 的网站,是时候发现它了。

于 2009-12-14T15:01:11.907 回答
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)总是假的。

于 2019-02-27T09:46:59.830 回答