Domanda

Sto cercando un'implementazione bello ed efficiente della linea anti-aliasing disegno algoritmo di Xiaolin Wu in C, qualcuno ha questo codice hanno potuto condividere con me?

Grazie

È stato utile?

Soluzione

pseudo codice .

Google ha molti esempi come questo o questo . E la tua domanda mi ha ricordato questo bell'articolo su antialiasing .

EDIT: E 'il momento di scoprire sito web di Hugo Helias se non lo sanno già.

Altri suggerimenti

qui è corretto, perché in

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));
      }

condizione if (ErrorAcc <= ErrorAccTemp) è sempre false.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top